incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefane...@apache.org
Subject svn commit: r1499970 - in /sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl: cluster/ClusterLoadTest.java setup/Instance.java
Date Fri, 05 Jul 2013 11:23:35 GMT
Author: stefanegli
Date: Fri Jul  5 11:23:34 2013
New Revision: 1499970

URL: http://svn.apache.org/r1499970
Log:
SLING-2945 : using different repository paths to avoid potential concurrency problem with
repository deletion between testruns

Modified:
    sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterLoadTest.java
    sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java

Modified: sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterLoadTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterLoadTest.java?rev=1499970&r1=1499969&r2=1499970&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterLoadTest.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterLoadTest.java
Fri Jul  5 11:23:34 2013
@@ -38,7 +38,7 @@ public class ClusterLoadTest {
     
     @Test
     public void testFramework() throws Exception {
-		Instance firstInstance = Instance.newStandaloneInstance("firstInstance", true, 2, 0);
+		Instance firstInstance = Instance.newStandaloneInstance("/var/discovery/impl/ClusterLoadTest/testFramework/",
"firstInstance", false, 2, 0);
 		instances.add(firstInstance);
     	Thread.sleep(2000);
     	// without any heartbeat action, the discovery service reports its local instance
@@ -54,7 +54,7 @@ public class ClusterLoadTest {
                 .getClusterViewService().getClusterView().getInstances().get(0)
                 .getClass());
         
-        Instance secondInstance = Instance.newClusterInstance("secondInstance", firstInstance,
false, 2, 0);
+        Instance secondInstance = Instance.newClusterInstance("/var/discovery/impl/ClusterLoadTest/testFramework/",
"secondInstance", firstInstance, false, 2, 0);
         instances.add(secondInstance);
         secondInstance.startHeartbeats(1);
         Thread.sleep(2000);
@@ -96,11 +96,11 @@ public class ClusterLoadTest {
 		if (size<2) {
 			fail("can only test 2 or more instances");
 		}
-		Instance firstInstance = Instance.newStandaloneInstance("firstInstance", true, 2, 0);
+		Instance firstInstance = Instance.newStandaloneInstance("/var/discovery/impl/ClusterLoadTest/doTest-"+size+"-"+loopCnt+"/",
"firstInstance", false, 2, 0);
 		firstInstance.startHeartbeats(1);
 		instances.add(firstInstance);
 		for(int i=1; i<size; i++) {
-			Instance subsequentInstance = Instance.newClusterInstance("subsequentInstance-"+i, firstInstance,
false, 2, 0);
+			Instance subsequentInstance = Instance.newClusterInstance("/var/discovery/impl/ClusterLoadTest/doTest-"+size+"-"+loopCnt+"/",
"subsequentInstance-"+i, firstInstance, false, 2, 0);
 			instances.add(subsequentInstance);
 			subsequentInstance.startHeartbeats(1);
 		}
@@ -147,14 +147,17 @@ public class ClusterLoadTest {
 			}
 			
 			// start/stop heartbeats accordingly
+			logger.info("Starting/Stopping heartbeats with count="+instances.size());
 			for (Iterator<Instance> it = instances.iterator(); it.hasNext();) {
 				Instance instance = it.next();
 				if (random.nextBoolean()) {
 					logger.info("Starting heartbeats with "+instance.slingId);
 					instance.startHeartbeats(1);
+					logger.info("Started heartbeats with "+instance.slingId);
 				} else {
 					logger.info("Stopping heartbeats with "+instance.slingId);
 					instance.stopHeartbeats();
+					logger.info("Stopped heartbeats with "+instance.slingId);
 				}
 			}
 			

Modified: sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java?rev=1499970&r1=1499969&r2=1499970&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java
Fri Jul  5 11:23:34 2013
@@ -150,10 +150,10 @@ public class Instance {
     private Instance(String debugName,
             ResourceResolverFactory resourceResolverFactory, boolean resetRepo)
             throws Exception {
-    	this(debugName, resourceResolverFactory, resetRepo, 20, 1);
+    	this("/var/discovery/impl/", debugName, resourceResolverFactory, resetRepo, 20, 1);
     }
     
-    private Instance(String debugName,
+    private Instance(String discoveryResourcePath, String debugName,
             ResourceResolverFactory resourceResolverFactory, boolean resetRepo,
             final int heartbeatTimeout, final int minEventDelay)
             throws Exception {
@@ -174,6 +174,7 @@ public class Instance {
             	return minEventDelay;
             }
         };
+        PrivateAccessor.setField(config, "discoveryResourcePath", discoveryResourcePath);
         
         clusterViewService = OSGiFactory.createClusterViewServiceImpl(slingId,
                 resourceResolverFactory, config);
@@ -261,11 +262,11 @@ public class Instance {
         return new Instance(debugName, resourceResolverFactory, false);
     }
 
-    public static Instance newStandaloneInstance(String debugName,
+    public static Instance newStandaloneInstance(String discoveryResourcePath, String debugName,
             boolean resetRepo, int heartbeatTimeout, int minEventDelay) throws Exception
{
         ResourceResolverFactory resourceResolverFactory = MockFactory
                 .mockResourceResolverFactory();
-        return new Instance(debugName, resourceResolverFactory, resetRepo, heartbeatTimeout,
minEventDelay);
+        return new Instance(discoveryResourcePath, debugName, resourceResolverFactory, resetRepo,
heartbeatTimeout, minEventDelay);
     }
     
     public static Instance newStandaloneInstance(String debugName,
@@ -275,9 +276,9 @@ public class Instance {
         return new Instance(debugName, resourceResolverFactory, resetRepo);
     }
 
-    public static Instance newClusterInstance(String debugName, Instance other,
+    public static Instance newClusterInstance(String discoveryResourcePath, String debugName,
Instance other,
             boolean resetRepo, int heartbeatTimeout, int minEventDelay) throws Exception
{
-        return new Instance(debugName, other.resourceResolverFactory, resetRepo, heartbeatTimeout,
minEventDelay);
+        return new Instance(discoveryResourcePath, debugName, other.resourceResolverFactory,
resetRepo, heartbeatTimeout, minEventDelay);
     }
 
     public static Instance newClusterInstance(String debugName, Instance other,
@@ -305,19 +306,26 @@ public class Instance {
     }
 
     public void runHeartbeatOnce() {
-    	System.err.println("Instance ["+slingId+"] issues a heartbeat now "+new Date());
+    	logger.info("Instance ["+slingId+"] issues a heartbeat now "+new Date());
         heartbeatHandler.run();
     }
     
     public void startHeartbeats(int intervalInSeconds) throws IllegalAccessException, InvocationTargetException
{
+    	logger.info("startHeartbeats: intervalInSeconds="+intervalInSeconds);
     	if (heartbeatRunner!=null) {
+    		logger.info("startHeartbeats: stopping first...");
     		heartbeatRunner.stop();
+    		logger.info("startHeartbeats: stopped.");
     	}
+		logger.info("startHeartbeats: activating...");
     	OSGiMock.activate(heartbeatHandler);
+		logger.info("startHeartbeats: initializing...");
     	heartbeatRunner = new HeartbeatRunner(intervalInSeconds);
     	Thread th = new Thread(heartbeatRunner, "Test-Heartbeat-Runner");
     	th.setDaemon(true);
+		logger.info("startHeartbeats: starting thread...");
     	th.start();
+		logger.info("startHeartbeats: done.");
     }
     
 	public boolean isHeartbeatRunning() {



Mime
View raw message