incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1600664 - in /sling/trunk/bundles/extensions/discovery/impl: pom.xml src/test/java/org/apache/sling/discovery/impl/topology/LargeTopologyWithHubTest.java src/test/java/org/apache/sling/discovery/impl/topology/TopologyTestHelper.java
Date Thu, 05 Jun 2014 13:58:09 GMT
Author: bdelacretaz
Date: Thu Jun  5 13:58:08 2014
New Revision: 1600664

URL: http://svn.apache.org/r1600664
Log:
SLING-3495 - use RetryRule to give LargeTopologyWithHubTest a better chance of passing on
slow boxes

Modified:
    sling/trunk/bundles/extensions/discovery/impl/pom.xml
    sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/topology/LargeTopologyWithHubTest.java
    sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/topology/TopologyTestHelper.java

Modified: sling/trunk/bundles/extensions/discovery/impl/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/pom.xml?rev=1600664&r1=1600663&r2=1600664&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/pom.xml (original)
+++ sling/trunk/bundles/extensions/discovery/impl/pom.xml Thu Jun  5 13:58:08 2014
@@ -207,7 +207,7 @@
         <dependency>
         	<groupId>org.apache.sling</groupId>
         	<artifactId>org.apache.sling.commons.testing</artifactId>
-        	<version>2.0.14</version>
+        	<version>2.0.16</version>
         	<scope>test</scope>
             <exclusions>
                 <!-- slf4j simple implementation logs INFO + higher to stdout (we don't
want that behaviour) -->

Modified: sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/topology/LargeTopologyWithHubTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/topology/LargeTopologyWithHubTest.java?rev=1600664&r1=1600663&r2=1600664&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/topology/LargeTopologyWithHubTest.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/topology/LargeTopologyWithHubTest.java
Thu Jun  5 13:58:08 2014
@@ -22,8 +22,12 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.sling.commons.testing.junit.Retry;
+import org.apache.sling.commons.testing.junit.RetryRule;
 import org.apache.sling.discovery.impl.setup.Instance;
-import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -32,34 +36,44 @@ public class LargeTopologyWithHubTest {
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
-    private final List<Instance> instances = new LinkedList<Instance>();
+    private static List<Instance> instances;
+    private static Instance hub;
+    private static List<String> slingIds;
+    private static final int TEST_SIZE = 100;
     
-    @After
-    public void tearDown() throws Exception {
-        for (Iterator<Instance> it = instances.iterator(); it.hasNext();) {
-            final Instance instance = it.next();
-            instance.stop();
-        }
-    }
-    
-    @Test
-    public void testLargeTopologyWithHub() throws Throwable {
-        logger.info("testLargeTopologyWithHub: start");
-        final int TEST_SIZE = 100;
-        Instance hub = TopologyTestHelper.createInstance(instances, "hub");
+    @Rule
+    public final RetryRule retryRule = new RetryRule();
+
+    @BeforeClass
+    public static void setup() throws Throwable {
+        instances = new LinkedList<Instance>();
+        hub = TopologyTestHelper.createInstance(instances, "hub");
         
-        List<String> slingIds = new LinkedList<String>();
+        slingIds = new LinkedList<String>();
         slingIds.add(hub.getSlingId());
         for(int i=0; i<TEST_SIZE; i++) {
-//            logger.info("testLargeTopologyWithHub: adding instance "+i);
             Instance instance = TopologyTestHelper.createInstance(instances, "instance"+i);
-//            logger.info("testLargeTopologyWithHub: adding connector "+i);
             new Connector(instance, hub);
             slingIds.add(instance.getSlingId());
         }
+    }
+    
+    @AfterClass
+    public static void tearDown() throws Exception {
+        for (Iterator<Instance> it = instances.iterator(); it.hasNext();) {
+            final Instance instance = it.next();
+            instance.stop();
+        }
+    }
+    
+    @Test
+    @Retry(timeoutMsec=30000, intervalMsec=500)
+    public void testLargeTopologyWithHub() {
         logger.info("testLargeTopologyWithHub: checking if all connectors are registered");
-        TopologyTestHelper.assertTopologyConsistsOf(hub.getDiscoveryService().getTopology(),
slingIds.toArray(new String[slingIds.size()]));
+        TopologyTestHelper.assertTopologyConsistsOf(
+                hub.getDiscoveryService().getTopology(), 
+                slingIds.toArray(new String[slingIds.size()]));
         logger.info("testLargeTopologyWithHub: end");
     }
 
-}
+}
\ No newline at end of file

Modified: sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/topology/TopologyTestHelper.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/topology/TopologyTestHelper.java?rev=1600664&r1=1600663&r2=1600664&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/topology/TopologyTestHelper.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/topology/TopologyTestHelper.java
Thu Jun  5 13:58:08 2014
@@ -124,7 +124,7 @@ public class TopologyTestHelper {
     
     public static void assertTopologyConsistsOf(TopologyView topology, String... slingIds)
{
         assertNotNull(topology);
-        assertEquals(topology.getInstances().size(), slingIds.length);
+        assertEquals(slingIds.length, topology.getInstances().size());
         for(int i=0; i<slingIds.length; i++) {
             final String aSlingId = slingIds[i];
             final Set<?> instances = topology.getInstances();



Mime
View raw message