helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject git commit: HELIX-41: fix intermittent test failures
Date Mon, 11 Feb 2013 18:33:58 GMT
Updated Branches:
  refs/heads/master 73a8e9858 -> 76aa2b660


HELIX-41: fix intermittent test failures


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

Branch: refs/heads/master
Commit: 76aa2b660342fa5ac2ba9afedfdbf93825480fac
Parents: 73a8e98
Author: zzhang <zzhang5@uci.edu>
Authored: Mon Feb 11 10:33:48 2013 -0800
Committer: zzhang <zzhang5@uci.edu>
Committed: Mon Feb 11 10:33:48 2013 -0800

----------------------------------------------------------------------
 .../integration/TestZkCallbackHandlerLeak.java     |   25 +++++++++++---
 1 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/76aa2b66/helix-core/src/test/java/org/apache/helix/integration/TestZkCallbackHandlerLeak.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestZkCallbackHandlerLeak.java
b/helix-core/src/test/java/org/apache/helix/integration/TestZkCallbackHandlerLeak.java
index 5c3229a..457791c 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestZkCallbackHandlerLeak.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestZkCallbackHandlerLeak.java
@@ -153,13 +153,22 @@ public class TestZkCallbackHandlerLeak extends ZkUnitTestBase {
 	    ZkHelixTestManager controllerManager = controller.getManager();
 	    ZkHelixTestManager participantManager = participants[0].getManager();
 
-	    // printHandlers(controllerManager);
+	    // wait until we get all the listeners registered
 	    int controllerHandlerNb = controllerManager.getHandlers().size();
 	    int particHandlerNb = participantManager.getHandlers().size();
-	    Assert.assertEquals(controllerHandlerNb, 9, "HelixController should have 9 (5+2n) callback
handlers for 2 (n) participant, but was " 
-	    		+ printHandlers(controllerManager));
-	    Assert.assertEquals(particHandlerNb, 2, "HelixParticipant should have 2 (msg+cur-state)
callback handlers, but was "
-	    		+ printHandlers(participantManager));
+	    for (int i = 0; i < 10; i++) {
+	    	if (controllerHandlerNb == 9 && particHandlerNb == 2)
+	    		break;
+	    	Thread.sleep(100);
+	    	controllerHandlerNb = controllerManager.getHandlers().size();
+	    	particHandlerNb = participantManager.getHandlers().size();
+	    }
+    	Assert.assertEquals(controllerHandlerNb, 9, "HelixController should have 9 (5+2n) callback
handlers for 2 participant, but was " 
+    	    		+ controllerHandlerNb + ", "
+    	    		+ printHandlers(controllerManager));
+    	Assert.assertEquals(particHandlerNb, 2, "HelixParticipant should have 2 (msg+cur-state)
callback handlers, but was " 
+    	    		+ particHandlerNb + ", "
+    	    		+ printHandlers(participantManager));
 
 
 	    // expire controller
@@ -191,13 +200,17 @@ public class TestZkCallbackHandlerLeak extends ZkUnitTestBase {
 	{
 		StringBuilder sb = new StringBuilder();
 	    List<CallbackHandler> handlers = manager.getHandlers();
-    	sb.append("\n" + manager.getInstanceName() + " cb-handler#: " + handlers.size());
+    	sb.append(manager.getInstanceName() + " has " + handlers.size() + " cb-handlers. [");
     	
 	    for (int i = 0; i < handlers.size(); i++) {
 	    	CallbackHandler handler = handlers.get(i);
 	    	String path = handler.getPath();
 	    	sb.append(path.substring(manager.getClusterName().length() + 1) + ": " + handler.getListener());
+	    	if (i < (handlers.size() - 1) ) {
+	    		sb.append(", ");
+	    	}
 	    }
+	    sb.append("]");
 	    
 	    return sb.toString();
     }


Mime
View raw message