You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ka...@apache.org on 2014/03/07 00:37:09 UTC

git commit: [HELIX-394] Make cluster event thread a daemon thread, fix test

Repository: helix
Updated Branches:
  refs/heads/master 6a2a5f67c -> 15c191b21


[HELIX-394] Make cluster event thread a daemon thread, fix test


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

Branch: refs/heads/master
Commit: 15c191b21291cce76ba121f0b4337f7a78daee57
Parents: 6a2a5f6
Author: Kanak Biscuitwala <ka...@apache.org>
Authored: Thu Mar 6 15:34:14 2014 -0800
Committer: Kanak Biscuitwala <ka...@apache.org>
Committed: Thu Mar 6 15:36:19 2014 -0800

----------------------------------------------------------------------
 .../integration/TestReelectedPipelineCorrectness.java   | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/15c191b2/helix-core/src/test/java/org/apache/helix/integration/TestReelectedPipelineCorrectness.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestReelectedPipelineCorrectness.java b/helix-core/src/test/java/org/apache/helix/integration/TestReelectedPipelineCorrectness.java
index 78927f9..a1f1868 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestReelectedPipelineCorrectness.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestReelectedPipelineCorrectness.java
@@ -42,6 +42,9 @@ import org.testng.annotations.Test;
  * to ensure that the controller can verify its cache. That's what this test is for.
  */
 public class TestReelectedPipelineCorrectness extends ZkUnitTestBase {
+  private static final int CHECK_INTERVAL = 50;
+  private static final int CHECK_TIMEOUT = 10000;
+
   @Test
   public void testReelection() throws Exception {
     final int NUM_CONTROLLERS = 2;
@@ -100,6 +103,15 @@ public class TestReelectedPipelineCorrectness extends ZkUnitTestBase {
     // Disable the leader, resulting in a leader election
     HelixDataAccessor accessor = participants[0].getHelixDataAccessor();
     LiveInstance leader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
+    int totalWait = 0;
+    while (leader == null && totalWait < CHECK_TIMEOUT) {
+      Thread.sleep(CHECK_INTERVAL);
+      totalWait += CHECK_INTERVAL;
+      leader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
+    }
+    if (totalWait >= CHECK_TIMEOUT) {
+      Assert.fail("No leader was ever elected!");
+    }
     String leaderId = leader.getId();
     String standbyId = (leaderId.equals("controller_0")) ? "controller_1" : "controller_0";
     HelixAdmin admin = setupTool.getClusterManagementTool();