brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [03/13] brooklyn-library git commit: fix failing test by not destroying app on stop
Date Mon, 07 Mar 2016 09:32:33 GMT
fix failing test by not destroying app on stop

also update deprecated test utils usage


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

Branch: refs/heads/master
Commit: b04591b0c4efd07ed939c0a5d318c6e81e96c92f
Parents: dddc28e
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Wed Feb 24 21:41:45 2016 -0800
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed Feb 24 21:41:45 2016 -0800

----------------------------------------------------------------------
 .../cassandra/CassandraDatacenterTest.java      | 14 ++++++-------
 .../ControlledDynamicWebAppClusterTest.java     | 22 +++++++++++---------
 2 files changed, 19 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/b04591b0/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterTest.java
b/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterTest.java
index 2c978b2..7e32569 100644
--- a/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterTest.java
+++ b/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterTest.java
@@ -28,11 +28,11 @@ import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.location.LocationSpec;
 import org.apache.brooklyn.core.entity.Attributes;
+import org.apache.brooklyn.core.entity.EntityAsserts;
 import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
 import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
 import org.apache.brooklyn.entity.software.base.EmptySoftwareProcessSshDriver;
 import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
-import org.apache.brooklyn.test.EntityTestUtils;
 import org.apache.brooklyn.util.core.ResourceUtils;
 import org.apache.brooklyn.util.core.text.TemplateProcessor;
 import org.apache.brooklyn.util.javalang.JavaClassNames;
@@ -75,7 +75,7 @@ public class CassandraDatacenterTest extends BrooklynAppUnitTestSupport
{
         EmptySoftwareProcess e1 = (EmptySoftwareProcess) Iterables.get(cluster.getMembers(),
0);
         EmptySoftwareProcess e2 = (EmptySoftwareProcess) Iterables.get(cluster.getMembers(),
1);
         
-        EntityTestUtils.assertAttributeEqualsEventually(cluster, CassandraDatacenter.CURRENT_SEEDS,
ImmutableSet.<Entity>of(e1, e2));
+        EntityAsserts.assertAttributeEqualsEventually(cluster, CassandraDatacenter.CURRENT_SEEDS,
ImmutableSet.<Entity>of(e1, e2));
     }
     
     @Test(groups="Integration") // because takes approx 2 seconds
@@ -93,7 +93,7 @@ public class CassandraDatacenterTest extends BrooklynAppUnitTestSupport
{
         app.start(ImmutableList.of(loc));
         EmptySoftwareProcess e1 = (EmptySoftwareProcess) Iterables.get(cluster.getMembers(),
0);
         EmptySoftwareProcess e2 = (EmptySoftwareProcess) Iterables.get(cluster.getMembers(),
1);
-        EntityTestUtils.assertAttributeEqualsEventually(cluster, CassandraDatacenter.CURRENT_SEEDS,
ImmutableSet.<Entity>of(e1, e2));
+        EntityAsserts.assertAttributeEqualsEventually(cluster, CassandraDatacenter.CURRENT_SEEDS,
ImmutableSet.<Entity>of(e1, e2));
         log.debug("Test "+JavaClassNames.niceClassAndMethod()+", cluster "+cluster+" has
"+cluster.getMembers()+"; e1="+e1+" e2="+e2);
         
         // calling the driver stop for this entity will cause SERVICE_UP to become false,
and stay false
@@ -104,13 +104,13 @@ public class CassandraDatacenterTest extends BrooklynAppUnitTestSupport
{
         if (fast)
             e1.sensors().set(Attributes.SERVICE_UP, false);
         
-        EntityTestUtils.assertAttributeEqualsEventually(cluster, CassandraDatacenter.CURRENT_SEEDS,
ImmutableSet.<Entity>of(e2));
+        EntityAsserts.assertAttributeEqualsEventually(cluster, CassandraDatacenter.CURRENT_SEEDS,
ImmutableSet.<Entity>of(e2));
 
         cluster.resize(3);
         EmptySoftwareProcess e3 = (EmptySoftwareProcess) Iterables.getOnlyElement(Sets.difference(ImmutableSet.copyOf(cluster.getMembers()),
ImmutableSet.of(e1,e2)));
         log.debug("Test "+JavaClassNames.niceClassAndMethod()+", cluster "+cluster+" has
"+cluster.getMembers()+"; e3="+e3);
         try {
-            EntityTestUtils.assertAttributeEqualsEventually(cluster, CassandraDatacenter.CURRENT_SEEDS,
ImmutableSet.<Entity>of(e2, e3));
+            EntityAsserts.assertAttributeEqualsEventually(cluster, CassandraDatacenter.CURRENT_SEEDS,
ImmutableSet.<Entity>of(e2, e3));
         } finally {
             log.debug("Test "+JavaClassNames.niceClassAndMethod()+", cluster "+cluster+"
has "+cluster.getMembers()+"; seeds "+cluster.getAttribute(CassandraDatacenter.CURRENT_SEEDS));
         }
@@ -121,8 +121,8 @@ public class CassandraDatacenterTest extends BrooklynAppUnitTestSupport
{
             ((EmptySoftwareProcessSshDriver)(((EmptySoftwareProcess)e1).getDriver())).launch();
             if (fast)
                 e1.sensors().set(Attributes.SERVICE_UP, true);
-            EntityTestUtils.assertAttributeEqualsEventually(e1, CassandraNode.SERVICE_UP,
true);
-            EntityTestUtils.assertAttributeEqualsContinually(cluster, CassandraDatacenter.CURRENT_SEEDS,
ImmutableSet.<Entity>of(e2, e3));
+            EntityAsserts.assertAttributeEqualsEventually(e1, CassandraNode.SERVICE_UP, true);
+            EntityAsserts.assertAttributeEqualsContinually(cluster, CassandraDatacenter.CURRENT_SEEDS,
ImmutableSet.<Entity>of(e2, e3));
         }
     }
     

http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/b04591b0/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
b/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
index b12e6f9..daa53fd 100644
--- a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
@@ -26,6 +26,8 @@ import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.entity.Group;
 import org.apache.brooklyn.core.entity.Attributes;
 import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.EntityAsserts;
+import org.apache.brooklyn.core.entity.StartableApplication;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
 import org.apache.brooklyn.entity.group.BasicGroup;
@@ -34,15 +36,14 @@ import org.apache.brooklyn.entity.proxy.LoadBalancer;
 import org.apache.brooklyn.entity.proxy.TrackingAbstractController;
 import org.apache.brooklyn.entity.software.base.SoftwareProcess;
 import org.apache.brooklyn.entity.webapp.jboss.JBoss7Server;
+import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
 import org.apache.brooklyn.test.Asserts;
-import org.apache.brooklyn.test.EntityTestUtils;
 import org.apache.brooklyn.test.entity.TestJavaWebAppEntity;
 import org.apache.brooklyn.test.support.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
@@ -77,12 +78,12 @@ public class ControlledDynamicWebAppClusterTest extends BrooklynAppUnitTestSuppo
                 .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war",
getTestWar())));
         app.start(locs);
 
-        EntityTestUtils.assertAttributeEqualsEventually(controller, AbstractController.SERVICE_UP,
true);
+        EntityAsserts.assertAttributeEqualsEventually(controller, AbstractController.SERVICE_UP,
true);
         assertEquals(cluster.getController(), controller);
 
         // Stopping cluster should not stop controller (because it didn't create it)
         cluster.stop();
-        EntityTestUtils.assertAttributeEquals(controller, AbstractController.SERVICE_UP,
true);
+        EntityAsserts.assertAttributeEquals(controller, AbstractController.SERVICE_UP, true);
     }
     
     @Test
@@ -115,12 +116,12 @@ public class ControlledDynamicWebAppClusterTest extends BrooklynAppUnitTestSuppo
         app.start(locs);
         LoadBalancer controller = cluster.getController();
         
-        EntityTestUtils.assertAttributeEqualsEventually(controller, AbstractController.SERVICE_UP,
true);
+        EntityAsserts.assertAttributeEqualsEventually(controller, AbstractController.SERVICE_UP,
true);
         assertEquals(controller.getDisplayName(), "mycustom");
 
         // Stopping cluster should stop the controller (because it created it)
         cluster.stop();
-        EntityTestUtils.assertAttributeEquals(controller, AbstractController.SERVICE_UP,
false);
+        EntityAsserts.assertAttributeEquals(controller, AbstractController.SERVICE_UP, false);
     }
     
     @Test
@@ -128,10 +129,11 @@ public class ControlledDynamicWebAppClusterTest extends BrooklynAppUnitTestSuppo
         SoftwareProcess n = app.createAndManageChild(EntitySpec.create(TestJavaWebAppEntity.class));
         app.start(locs);
 
-        EntityTestUtils.assertAttributeEqualsEventually(n, AbstractController.SERVICE_UP,
true);
-        
+        EntityAsserts.assertAttributeEqualsEventually(n, AbstractController.SERVICE_UP, true);
+
+        app.config().set(StartableApplication.DESTROY_ON_STOP, false);
         app.stop();
-        EntityTestUtils.assertAttributeEqualsEventually(n, AbstractController.SERVICE_UP,
false);
+        EntityAsserts.assertAttributeEqualsEventually(n, AbstractController.SERVICE_UP, false);
     }
     
     @Test
@@ -205,6 +207,6 @@ public class ControlledDynamicWebAppClusterTest extends BrooklynAppUnitTestSuppo
         Entities.unmanage(controller);
         
         cluster.stop();
-        EntityTestUtils.assertAttributeEquals(cluster, ControlledDynamicWebAppCluster.SERVICE_STATE_ACTUAL,
Lifecycle.STOPPED);
+        EntityAsserts.assertAttributeEquals(cluster, ControlledDynamicWebAppCluster.SERVICE_STATE_ACTUAL,
Lifecycle.STOPPED);
     }
 }


Mime
View raw message