alirezazamani commented on a change in pull request #981:
URL: https://github.com/apache/helix/pull/981#discussion_r417692442



##########
File path: 
helix-core/src/test/java/org/apache/helix/integration/task/TestRebalanceRunningTask.java
##########
@@ -261,6 +263,28 @@ public void 
testFixedTargetTaskAndDisabledRebalanceAndNodeAdded() throws Interru
         new 
BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient)
             .setResources(Sets.newHashSet(DATABASE)).build();
     Assert.assertTrue(clusterVerifier.verify(10 * 1000));
+
+    // Wait until master is switched to new instance and two masters existed 
on two different instance
+    boolean isMasterOnTwoDifferentNodes = TestHelper.verify(() -> {
+      HashSet<String> masterInstances = new HashSet<>();
+      ExternalView externalView =
+          
_gSetupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, 
DATABASE);
+      Map<String, String> stateMap0 = externalView.getStateMap(DATABASE + 
"_0");
+      Map<String, String> stateMap1 = externalView.getStateMap(DATABASE + 
"_1");
+      for (Map.Entry<String, String> entry : stateMap0.entrySet()) {
+        if (entry.getValue().equals("MASTER")) {
+          masterInstances.add(entry.getKey());
+        }
+      }
+      for (Map.Entry<String, String> entry : stateMap1.entrySet()) {
+        if (entry.getValue().equals("MASTER")) {
+          masterInstances.add(entry.getKey());
+        }
+      }
+      return (masterInstances.size() == 2);

Review comment:
       Please note that we want to make sure that the master for two different 
resources are existed in two different instances. Counter is also possible. 
However, I still think this implementation in more readable. Specially 
considering that this only a test.

##########
File path: 
helix-core/src/test/java/org/apache/helix/integration/task/TestRebalanceRunningTask.java
##########
@@ -261,6 +263,28 @@ public void 
testFixedTargetTaskAndDisabledRebalanceAndNodeAdded() throws Interru
         new 
BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient)
             .setResources(Sets.newHashSet(DATABASE)).build();
     Assert.assertTrue(clusterVerifier.verify(10 * 1000));
+
+    // Wait until master is switched to new instance and two masters existed 
on two different instance
+    boolean isMasterOnTwoDifferentNodes = TestHelper.verify(() -> {
+      HashSet<String> masterInstances = new HashSet<>();
+      ExternalView externalView =
+          
_gSetupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, 
DATABASE);
+      Map<String, String> stateMap0 = externalView.getStateMap(DATABASE + 
"_0");
+      Map<String, String> stateMap1 = externalView.getStateMap(DATABASE + 
"_1");
+      for (Map.Entry<String, String> entry : stateMap0.entrySet()) {
+        if (entry.getValue().equals("MASTER")) {
+          masterInstances.add(entry.getKey());
+        }
+      }
+      for (Map.Entry<String, String> entry : stateMap1.entrySet()) {
+        if (entry.getValue().equals("MASTER")) {
+          masterInstances.add(entry.getKey());
+        }
+      }
+      return (masterInstances.size() == 2);

Review comment:
       Please note that we want to make sure that the master for two different 
resources are existed in two different instances. Counter is also possible. 
However, I still think this implementation in more readable. Specially 
considering that this is only a test.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to