brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [16/21] incubator-brooklyn git commit: Fix failing integration tests
Date Mon, 09 Nov 2015 12:55:25 GMT
Fix failing integration tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/76d480fd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/76d480fd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/76d480fd

Branch: refs/heads/master
Commit: 76d480fdb31f2f2bf8ec5798aa1a364f0b2521da
Parents: 35a227f
Author: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Authored: Fri Nov 6 12:20:48 2015 +0200
Committer: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Committed: Fri Nov 6 16:20:23 2015 +0200

----------------------------------------------------------------------
 .../brooklyn/core/mgmt/ha/OsgiManager.java      |  3 +-
 .../apache/brooklyn/util/core/osgi/Osgis.java   | 39 +++++++++-----------
 .../core/mgmt/osgi/OsgiStandaloneTest.java      |  8 ++--
 .../mysql/MySqlClusterIntegrationTest.java      |  5 +--
 .../database/mysql/MySqlClusterTestHelper.java  | 36 +++++++++++++++++-
 .../rt/felix/EmbeddedFelixFramework.java        | 12 ++++++
 6 files changed, 71 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/76d480fd/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
index 0e941bd..b6f85f1 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
@@ -36,6 +36,7 @@ import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.BrooklynVersion;
 import org.apache.brooklyn.core.server.BrooklynServerConfig;
 import org.apache.brooklyn.core.server.BrooklynServerPaths;
+import org.apache.brooklyn.rt.felix.EmbeddedFelixFramework;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.collections.MutableSet;
 import org.apache.brooklyn.util.core.osgi.Osgis;
@@ -190,7 +191,7 @@ public class OsgiManager {
                     Class<T> clazz;
                     //Extension bundles don't support loadClass.
                     //Instead load from the app classpath.
-                    if (Osgis.isExtensionBundle(b)) {
+                    if (EmbeddedFelixFramework.isExtensionBundle(b)) {
                         @SuppressWarnings("unchecked")
                         Class<T> c = (Class<T>)Class.forName(type);
                         clazz = c;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/76d480fd/core/src/main/java/org/apache/brooklyn/util/core/osgi/Osgis.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/util/core/osgi/Osgis.java b/core/src/main/java/org/apache/brooklyn/util/core/osgi/Osgis.java
index 6d5dc91..be24dc1 100644
--- a/core/src/main/java/org/apache/brooklyn/util/core/osgi/Osgis.java
+++ b/core/src/main/java/org/apache/brooklyn/util/core/osgi/Osgis.java
@@ -26,40 +26,37 @@ import java.net.URISyntaxException;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
-import java.util.Set;
+import java.util.Map;
 import java.util.jar.JarInputStream;
 import java.util.jar.Manifest;
 
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Version;
-import org.osgi.framework.launch.Framework;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.brooklyn.api.catalog.CatalogItem.CatalogBundle;
 import org.apache.brooklyn.rt.felix.EmbeddedFelixFramework;
 import org.apache.brooklyn.util.collections.MutableList;
-import org.apache.brooklyn.util.collections.MutableSet;
 import org.apache.brooklyn.util.core.ResourceUtils;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.guava.Maybe;
 import org.apache.brooklyn.util.net.Urls;
 import org.apache.brooklyn.util.os.Os;
-import org.apache.brooklyn.util.osgi.VersionedName;
+import org.apache.brooklyn.util.osgi.OsgiUtils;
 import org.apache.brooklyn.util.stream.Streams;
 import org.apache.brooklyn.util.text.Strings;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Function;
 import com.google.common.base.Joiner;
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
-import java.util.Map;
-import org.apache.brooklyn.util.osgi.OsgiUtils;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.launch.FrameworkFactory;
 
 /** 
  * utilities for working with osgi.
@@ -71,9 +68,6 @@ import org.osgi.framework.launch.FrameworkFactory;
 public class Osgis {
     private static final Logger LOG = LoggerFactory.getLogger(Osgis.class);
 
-    private static final String EXTENSION_PROTOCOL = "system";
-    private static final Set<String> SYSTEM_BUNDLES = MutableSet.of();
-
     /** @deprecated since 0.9.0, replaced with {@link org.apache.brooklyn.util.osgi.VersionedName}
*/
     @Deprecated
     public static class VersionedName extends org.apache.brooklyn.util.osgi.VersionedName
{
@@ -246,6 +240,7 @@ public class Osgis {
             return Joiner.on(";").join(parts);
         }
         
+        @Override
         public String toString() {
             return getClass().getCanonicalName()+"["+getConstraintsDescription()+"]";
         }
@@ -444,7 +439,7 @@ public class Osgis {
         String versionedId = OsgiUtils.getVersionedId(manifest);
         for (Bundle installedBundle : framework.getBundleContext().getBundles()) {
             if (versionedId.equals(OsgiUtils.getVersionedId(installedBundle))) {
-                if (SYSTEM_BUNDLES.contains(versionedId)) {
+                if (EmbeddedFelixFramework.isSystemBundle(installedBundle)) {
                     LOG.debug("Already have system bundle "+versionedId+" from "+installedBundle+"/"+installedBundle.getLocation()+"
when requested "+url+"; not installing");
                     // "System bundles" (ie things on the classpath) cannot be overridden
                     return installedBundle;
@@ -462,10 +457,10 @@ public class Osgis {
         return ResourceUtils.create(Osgis.class).getResourceFromUrl(url);
     }
     
+    /** @deprecated since 0.9.0, replaced with {@link EmbeddedFelixFramework#isExtensionBundle(Bundle)}
*/
+    @Deprecated
     public static boolean isExtensionBundle(Bundle bundle) {
-        String location = bundle.getLocation();
-        return location != null && 
-                EXTENSION_PROTOCOL.equals(Urls.getProtocol(location));
+        return EmbeddedFelixFramework.isExtensionBundle(bundle);
     }
 
     /** @deprecated since 0.9.0, replaced with {@link OsgiUtils#parseOsgiIdentifier(java.lang.String)
} */

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/76d480fd/core/src/test/java/org/apache/brooklyn/core/mgmt/osgi/OsgiStandaloneTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/osgi/OsgiStandaloneTest.java
b/core/src/test/java/org/apache/brooklyn/core/mgmt/osgi/OsgiStandaloneTest.java
index e48ff70..524e248 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/osgi/OsgiStandaloneTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/osgi/OsgiStandaloneTest.java
@@ -19,8 +19,8 @@
 package org.apache.brooklyn.core.mgmt.osgi;
 
 
-import org.apache.brooklyn.util.osgi.OsgiTestResources;
 import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.rt.felix.EmbeddedFelixFramework;
 import org.apache.brooklyn.test.support.TestResourceUnavailableException;
 import org.apache.brooklyn.util.core.ResourceUtils;
 import org.apache.brooklyn.util.core.osgi.OsgiTestBase;
@@ -29,6 +29,7 @@ import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.maven.MavenArtifact;
 import org.apache.brooklyn.util.maven.MavenRetriever;
 import org.apache.brooklyn.util.net.Urls;
+import org.apache.brooklyn.util.osgi.OsgiTestResources;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.slf4j.Logger;
@@ -84,8 +85,7 @@ public class OsgiStandaloneTest extends OsgiTestBase {
         Assert.assertEquals(Entity.class, bundleCls.getClassLoader().loadClass(Entity.class.getName()));
     }
 
-    // FIXME re-enable
-    @Test(enabled = false)
+    @Test
     public void testDuplicateBundle() throws Exception {
         MavenArtifact artifact = new MavenArtifact("org.apache.brooklyn", "brooklyn-api",
"jar", "0.9.0-SNAPSHOT"); // BROOKLYN_VERSION
         String localUrl = MavenRetriever.localUrl(artifact);
@@ -106,7 +106,7 @@ public class OsgiStandaloneTest extends OsgiTestBase {
         //Make sure that we still get the initially loaded
         //bundle after trying to install the same version.
         Bundle bundle = install(url);
-        Assert.assertTrue(Osgis.isExtensionBundle(bundle));
+        Assert.assertTrue(EmbeddedFelixFramework.isExtensionBundle(bundle));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/76d480fd/software/database/src/test/java/org/apache/brooklyn/entity/database/mysql/MySqlClusterIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/org/apache/brooklyn/entity/database/mysql/MySqlClusterIntegrationTest.java
b/software/database/src/test/java/org/apache/brooklyn/entity/database/mysql/MySqlClusterIntegrationTest.java
index c93de8c..baaefe4 100644
--- a/software/database/src/test/java/org/apache/brooklyn/entity/database/mysql/MySqlClusterIntegrationTest.java
+++ b/software/database/src/test/java/org/apache/brooklyn/entity/database/mysql/MySqlClusterIntegrationTest.java
@@ -35,7 +35,6 @@ import org.apache.brooklyn.entity.database.mysql.MySqlCluster.MySqlMaster;
 import org.apache.brooklyn.entity.software.base.SoftwareProcess;
 import org.apache.brooklyn.location.ssh.SshMachineLocation;
 import org.apache.brooklyn.test.Asserts;
-import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.core.task.ssh.SshTasks;
 import org.apache.brooklyn.util.os.Os;
 import org.apache.brooklyn.util.ssh.BashCommands;
@@ -74,7 +73,7 @@ public class MySqlClusterIntegrationTest extends BrooklynAppLiveTestSupport
{
             Location loc = getLocation();
             EntitySpec<MySqlCluster> clusterSpec = EntitySpec.create(MySqlCluster.class)
                     .configure(MySqlMaster.MASTER_CREATION_SCRIPT_CONTENTS, MySqlClusterTestHelper.CREATION_SCRIPT)
-                    .configure(MySqlNode.MYSQL_SERVER_CONF, MutableMap.<String, Object>of("skip-name-resolve",""));
+                    .configure(MySqlNode.MYSQL_SERVER_CONF, MySqlClusterTestHelper.minimalMemoryConfig());
             MySqlCluster cluster = MySqlClusterTestHelper.initCluster(app, loc, clusterSpec);
             MySqlNode master = (MySqlNode) cluster.getAttribute(MySqlCluster.FIRST);
             purgeLogs(cluster, master);
@@ -108,7 +107,7 @@ public class MySqlClusterIntegrationTest extends BrooklynAppLiveTestSupport
{
             Location loc = getLocation();
             EntitySpec<MySqlCluster> clusterSpec = EntitySpec.create(MySqlCluster.class)
                     .configure(MySqlMaster.MASTER_CREATION_SCRIPT_CONTENTS, MySqlClusterTestHelper.CREATION_SCRIPT)
-                    .configure(MySqlNode.MYSQL_SERVER_CONF, MutableMap.<String, Object>of("skip-name-resolve",""))
+                    .configure(MySqlNode.MYSQL_SERVER_CONF, MySqlClusterTestHelper.minimalMemoryConfig())
                     .configure(MySqlCluster.SLAVE_REPLICATE_DO_DB, ImmutableList.of("feedback",
"items", "mysql"))
                     .configure(MySqlCluster.SLAVE_REPLICATE_DUMP_DB, ImmutableList.of("feedback",
"items", "mysql"));
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/76d480fd/software/database/src/test/java/org/apache/brooklyn/entity/database/mysql/MySqlClusterTestHelper.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/org/apache/brooklyn/entity/database/mysql/MySqlClusterTestHelper.java
b/software/database/src/test/java/org/apache/brooklyn/entity/database/mysql/MySqlClusterTestHelper.java
index d99e119..71c0165 100644
--- a/software/database/src/test/java/org/apache/brooklyn/entity/database/mysql/MySqlClusterTestHelper.java
+++ b/software/database/src/test/java/org/apache/brooklyn/entity/database/mysql/MySqlClusterTestHelper.java
@@ -92,14 +92,46 @@ public class MySqlClusterTestHelper {
         test(app, location, EntitySpec.create(MySqlCluster.class)
                 .configure(MySqlCluster.INITIAL_SIZE, 2)
                 .configure(MySqlNode.CREATION_SCRIPT_CONTENTS, CREATION_SCRIPT)
-                .configure(MySqlNode.MYSQL_SERVER_CONF, MutableMap.<String, Object>of("skip-name-resolve","")));
+                .configure(MySqlNode.MYSQL_SERVER_CONF, minimalMemoryConfig()));
+    }
+
+    public static MutableMap<String, Object> minimalMemoryConfig() {
+        // http://www.tocker.ca/2014/03/10/configuring-mysql-to-use-minimal-memory.html
+        return MutableMap.<String, Object>of()
+                .add("skip-name-resolve","")
+                .add("performance_schema","0")
+                .add("innodb_buffer_pool_size","5M")
+                .add("innodb_log_buffer_size","256K")
+                .add("query_cache_size","0")
+                .add("max_connections","10")
+                .add("key_buffer_size","8")
+                .add("thread_cache_size","0")
+                .add("host_cache_size","0")
+                .add("innodb_ft_cache_size","1600000")
+                .add("innodb_ft_total_cache_size","32000000")
+
+                // per thread or per operation settings
+                .add("thread_stack","131072")
+                .add("sort_buffer_size","32K")
+                .add("read_buffer_size","8200")
+                .add("read_rnd_buffer_size","8200")
+                .add("max_heap_table_size","16K")
+                .add("tmp_table_size","1K")
+                .add("bulk_insert_buffer_size","0")
+                .add("join_buffer_size","128")
+                .add("net_buffer_length","1K")
+                .add("innodb_sort_buffer_size","64K")
+
+                // settings that relate to the binary log (if enabled)
+                .add("binlog_cache_size","4K")
+                .add("binlog_stmt_cache_size","4K");
     }
 
     public static void testMasterInit(TestApplication app, Location location) throws Exception
{
         test(app, location, EntitySpec.create(MySqlCluster.class)
                 .configure(MySqlCluster.INITIAL_SIZE, 2)
                 .configure(MySqlMaster.MASTER_CREATION_SCRIPT_CONTENTS, CREATION_SCRIPT)
-                .configure(MySqlNode.MYSQL_SERVER_CONF, MutableMap.<String, Object>of("skip-name-resolve","")));
+                .configure(MySqlNode.MYSQL_SERVER_CONF, minimalMemoryConfig()));
     }
 
     public static void test(TestApplication app, Location location, EntitySpec<MySqlCluster>
clusterSpec) throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/76d480fd/utils/rt-felix/src/main/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFramework.java
----------------------------------------------------------------------
diff --git a/utils/rt-felix/src/main/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFramework.java
b/utils/rt-felix/src/main/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFramework.java
index 6d2bb5f..2bc467a 100644
--- a/utils/rt-felix/src/main/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFramework.java
+++ b/utils/rt-felix/src/main/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFramework.java
@@ -35,6 +35,7 @@ import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.collections.MutableSet;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.exceptions.ReferenceWithError;
+import org.apache.brooklyn.util.net.Urls;
 import org.apache.brooklyn.util.osgi.OsgiUtils;
 import org.apache.brooklyn.util.time.Duration;
 import org.apache.brooklyn.util.time.Time;
@@ -255,4 +256,15 @@ public class EmbeddedFelixFramework {
         return atts.containsKey(new Attributes.Name(Constants.BUNDLE_MANIFESTVERSION));
     }
 
+    public static boolean isSystemBundle(Bundle bundle) {
+        String versionedId = OsgiUtils.getVersionedId( bundle );
+        return SYSTEM_BUNDLES.contains(versionedId);
+    }
+
+    public static boolean isExtensionBundle(Bundle bundle) {
+        String location = bundle.getLocation();
+        return location != null && 
+                EXTENSION_PROTOCOL.equals(Urls.getProtocol(location));
+    }
+
 }


Mime
View raw message