Repository: helix
Updated Branches:
  refs/heads/helix-0.6.x d83fb5801 -> 5dc6fe7c3


[HELIX-580] Fix test: TestBatchMessage#testSubMsgExecutionFail, rb=32173


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

Branch: refs/heads/helix-0.6.x
Commit: 5dc6fe7c393db2e60f22025d41b39425e075ae29
Parents: d83fb58
Author: zzhang <[email protected]>
Authored: Tue Mar 17 14:12:04 2015 -0700
Committer: zzhang <[email protected]>
Committed: Tue Mar 17 14:12:04 2015 -0700

----------------------------------------------------------------------
 .../helix/integration/TestBatchMessage.java     | 27 ++++++++++++++------
 1 file changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/5dc6fe7c/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
----------------------------------------------------------------------
diff --git 
a/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java 
b/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
index 03fc85b..fc966f6 100644
--- 
a/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
+++ 
b/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
@@ -26,6 +26,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.I0Itec.zkclient.IZkChildListener;
+import org.apache.helix.HelixDefinedState;
 import org.apache.helix.TestHelper;
 import org.apache.helix.ZNRecord;
 import org.apache.helix.HelixProperty.HelixPropertyAttribute;
@@ -217,22 +218,32 @@ public class TestBatchMessage extends 
ZkIntegrationTestBase {
 
     // enable batch message
     ZKHelixDataAccessor accessor =
-        new ZKHelixDataAccessor(clusterName, new 
ZkBaseDataAccessor<ZNRecord>(_gZkClient));
+        new ZKHelixDataAccessor(clusterName, _baseAccessor);
     Builder keyBuilder = accessor.keyBuilder();
     IdealState idealState = 
accessor.getProperty(keyBuilder.idealStates("TestDB0"));
     idealState.setBatchMessageMode(true);
     accessor.setProperty(keyBuilder.idealStates("TestDB0"), idealState);
 
-    ClusterControllerManager controller =
-        new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
+    // get MASTER for errPartition
+    String errPartition = "TestDB0_0";
+    String masterOfPartition0 = null;
+    for (Map.Entry<String, String> entry : 
idealState.getInstanceStateMap(errPartition).entrySet()) {
+      if (entry.getValue().equals("MASTER")) {
+        masterOfPartition0 = entry.getKey();
+        break;
+      }
+    }
+    Assert.assertNotNull(masterOfPartition0);
+
+    ClusterControllerManager controller = new 
ClusterControllerManager(ZK_ADDR, clusterName);
     controller.syncStart();
 
     for (int i = 0; i < n; i++) {
       String instanceName = "localhost_" + (12918 + i);
 
-      if (i == 1) {
+      if (instanceName.equals(masterOfPartition0)) {
         Map<String, Set<String>> errPartitions = new HashMap<String, 
Set<String>>();
-        errPartitions.put("SLAVE-MASTER", TestHelper.setOf("TestDB0_4"));
+        errPartitions.put("SLAVE-MASTER", TestHelper.setOf("TestDB0_0"));
         participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, 
instanceName);
         participants[i].setTransition(new ErrTransition(errPartitions));
       } else {
@@ -243,16 +254,16 @@ public class TestBatchMessage extends 
ZkIntegrationTestBase {
 
     Map<String, Map<String, String>> errStates = new HashMap<String, 
Map<String, String>>();
     errStates.put("TestDB0", new HashMap<String, String>());
-    errStates.get("TestDB0").put("TestDB0_4", "localhost_12919");
+    errStates.get("TestDB0").put(errPartition, masterOfPartition0);
     boolean result =
         ClusterStateVerifier.verifyByPolling(new 
ClusterStateVerifier.BestPossAndExtViewZkVerifier(
             ZK_ADDR, clusterName, errStates));
     Assert.assertTrue(result);
 
     Map<String, Set<String>> errorStateMap = new HashMap<String, 
Set<String>>();
-    errorStateMap.put("TestDB0_4", TestHelper.setOf("localhost_12919"));
+    errorStateMap.put(errPartition, TestHelper.setOf(masterOfPartition0));
 
-    // verify "TestDB0_4", "localhost_12919" is in ERROR state
+    // verify "TestDB0_0", masterOfPartition0 is in ERROR state
     TestHelper.verifyState(clusterName, ZK_ADDR, errorStateMap, "ERROR");
 
     System.out.println("END " + clusterName + " at " + new 
Date(System.currentTimeMillis()));

Reply via email to