brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [15/25] git commit: More testing nginx-rebind doesn’t lose members
Date Sun, 01 Jun 2014 20:15:30 GMT
More testing nginx-rebind doesn’t lose members


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

Branch: refs/heads/master
Commit: f768fd5bfc0599de4b81f246a4af3d4d375cee44
Parents: 57e670c
Author: Aled Sage <aled.sage@gmail.com>
Authored: Wed May 28 19:16:32 2014 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Fri May 30 10:24:39 2014 +0100

----------------------------------------------------------------------
 .../proxy/nginx/NginxRebindIntegrationTest.java | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f768fd5b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
index 8064483..19bca33 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
@@ -8,6 +8,7 @@ import static org.testng.Assert.assertEquals;
 import java.io.File;
 import java.net.URL;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -18,6 +19,7 @@ import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import brooklyn.entity.Entity;
 import brooklyn.entity.Group;
 import brooklyn.entity.basic.ApplicationBuilder;
 import brooklyn.entity.basic.BasicGroup;
@@ -31,12 +33,14 @@ import brooklyn.entity.webapp.jboss.JBoss7Server;
 import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
 import brooklyn.management.ManagementContext;
 import brooklyn.management.internal.LocalManagementContext;
+import brooklyn.test.Asserts;
 import brooklyn.test.WebAppMonitor;
 import brooklyn.test.entity.TestApplication;
 import brooklyn.util.internal.TimeExtras;
 
 import com.google.common.base.Predicates;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.io.Files;
 
@@ -163,7 +167,9 @@ public class NginxRebindIntegrationTest {
         origApp.start(ImmutableList.of(localhostProvisioningLocation));
         
         String rootUrl = origNginx.getAttribute(NginxController.ROOT_URL);
-
+        JBoss7Server origJboss = (JBoss7Server) Iterables.getOnlyElement(origServerPool.getMembers());
+        assertEquals(origNginx.getAttribute(NginxController.SERVER_POOL_TARGETS).keySet(),
ImmutableSet.of(origJboss));
+        
         assertHttpStatusCodeEventuallyEquals(rootUrl, 200);
         WebAppMonitor monitor = newWebAppMonitor(rootUrl, 200);
         final String origConfigFile = origNginx.getConfigFile();
@@ -172,9 +178,17 @@ public class NginxRebindIntegrationTest {
         newApp = rebind();
         ManagementContext newManagementContext = newApp.getManagementContext();
         final NginxController newNginx = (NginxController) Iterables.find(newApp.getChildren(),
Predicates.instanceOf(NginxController.class));
-        DynamicCluster newServerPool = (DynamicCluster) newManagementContext.getEntityManager().getEntity(origServerPool.getId());
-        JBoss7Server newJboss = (JBoss7Server) Iterables.getOnlyElement(newServerPool.getMembers());
+        final DynamicCluster newServerPool = (DynamicCluster) newManagementContext.getEntityManager().getEntity(origServerPool.getId());
+        final JBoss7Server newJboss = (JBoss7Server) Iterables.getOnlyElement(newServerPool.getMembers());
 
+        // Expect continually to have same nginx members; should not lose them temporarily!
+        Asserts.succeedsContinually(new Runnable() {
+            public void run() {
+                Map<Entity, String> newNginxMemebers = newNginx.getAttribute(NginxController.SERVER_POOL_TARGETS);
+                assertEquals(newNginxMemebers.keySet(), ImmutableSet.of(newJboss));
+            }});
+        
+        
         assertAttributeEqualsEventually(newNginx, SoftwareProcess.SERVICE_UP, true);
         assertHttpStatusCodeEventuallyEquals(rootUrl, 200);
 


Mime
View raw message