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 Tue, 05 Feb 2013 23:38:37 GMT
Updated Branches:
  refs/heads/master a1bf1244f -> c3de04f61


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/c3de04f6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-helix/tree/c3de04f6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-helix/diff/c3de04f6

Branch: refs/heads/master
Commit: c3de04f61208f91e026dafc5ea0169c96c35d9d5
Parents: a1bf124
Author: zzhang <zzhang5@uci.edu>
Authored: Tue Feb 5 15:38:28 2013 -0800
Committer: zzhang <zzhang5@uci.edu>
Committed: Tue Feb 5 15:38:28 2013 -0800

----------------------------------------------------------------------
 .../TestAddStateModelFactoryAfterConnect.java      |   29 ++++++++++-----
 1 files changed, 20 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/c3de04f6/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java
b/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java
index 83a2ac9..d3f560f 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java
@@ -19,7 +19,9 @@ package org.apache.helix.integration;
  * under the License.
  */
 
+import java.util.ArrayList;
 import java.util.Date;
+import java.util.List;
 
 import org.apache.helix.TestHelper;
 import org.apache.helix.ZNRecord;
@@ -29,6 +31,7 @@ import org.apache.helix.manager.zk.ZkBaseDataAccessor;
 import org.apache.helix.mock.controller.ClusterController;
 import org.apache.helix.mock.participant.MockParticipant;
 import org.apache.helix.mock.participant.MockParticipant.MockMSModelFactory;
+import org.apache.helix.model.CurrentState;
 import org.apache.helix.model.ExternalView;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.tools.ClusterSetup;
@@ -41,7 +44,7 @@ import org.testng.annotations.Test;
 public class TestAddStateModelFactoryAfterConnect extends ZkIntegrationTestBase
 {
   @Test
-  public void testAddStateModelFactoryAfterConnect() throws Exception
+  public void testBasic() throws Exception
   {
     // Logger.getRootLogger().setLevel(Level.INFO);
     String className = TestHelper.getTestClassName();
@@ -97,18 +100,26 @@ public class TestAddStateModelFactoryAfterConnect extends ZkIntegrationTestBase
 
     // external view for TestDB1 should be empty
     ExternalView extView = null;
-    long start = System.currentTimeMillis();
-    while (extView == null)
+    for (int i = 0; i < 10; i++)
     {
-      Thread.sleep(50);
+      Thread.sleep(100);
       extView = accessor.getProperty(keyBuilder.externalView("TestDB1"));
 
-      long now = System.currentTimeMillis();
-      if (now - start > 5000)
-      {
-        Assert.fail("Timeout waiting for an empty external view of TestDB1. extView: " +
extView);
-      }
+      if (extView != null)
+    	  break;
     }
+
+    if (extView == null) {
+    	// output current-state for debug
+    	List<CurrentState> curStates = new ArrayList<CurrentState>();
+    	for (int i = 0; i < n; i++) {
+    		CurrentState curState = accessor.getProperty(keyBuilder.currentState(participants[i].getInstanceName(),

+    				participants[i].getManager().getSessionId(), "TestDB1"));
+    		curStates.add(curState);
+    	}
+    	Assert.fail("Timeout waiting for an empty external view of TestDB1. curStates: " + curStates);
+    }
+
     Assert.assertEquals(extView.getRecord().getMapFields().size(),
                         0,
                         "External view for TestDB1 should be empty since TestDB1 is added
without a state model factory");


Mime
View raw message