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



##########
File path: 
helix-core/src/test/java/org/apache/helix/integration/task/TestJobFailure.java
##########
@@ -118,8 +118,15 @@ public void testNormalJobFailure(String comment, 
List<String> taskStates,
   }
 
   private Map<String, Map<String, String>> createPartitionConfig(List<String> 
taskStates,
-      List<String> expectedTaskEndingStates) {
+      List<String> expectedTaskEndingStates) throws Exception {
     Map<String, Map<String, String>> targetPartitionConfigs = new HashMap<>();
+    // Make sure external view has been created for the resource
+    Assert.assertTrue(TestHelper.verify(() -> {
+      ExternalView externalView =
+          
_manager.getClusterManagmentTool().getResourceExternalView(CLUSTER_NAME, 
DB_NAME);
+      return (externalView != null);

Review comment:
       Parentheses aren't needed here.

##########
File path: 
helix-core/src/test/java/org/apache/helix/integration/task/TestRebalanceRunningTask.java
##########
@@ -261,6 +263,31 @@ 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

Review comment:
       Nit: "two masters exist on two different instances"

##########
File path: 
helix-core/src/test/java/org/apache/helix/integration/task/TestRebalanceRunningTask.java
##########
@@ -261,6 +263,31 @@ 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);
+      if (externalView == null) {
+        return false;
+      }
+      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:
       Parentheses not needed?

##########
File path: 
helix-core/src/test/java/org/apache/helix/integration/task/TestRebalanceRunningTask.java
##########
@@ -261,6 +263,31 @@ 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<>();

Review comment:
       Could we declare it as Set instead of HashSet here?

##########
File path: 
helix-core/src/test/java/org/apache/helix/integration/task/TestTaskSchedulingTwoCurrentStates.java
##########
@@ -138,6 +139,18 @@ public void testTargetedTaskTwoCurrentStates() throws 
Exception {
     JobQueue.Builder jobQueue = TaskTestUtil.buildJobQueue(jobQueueName);
     jobQueue.enqueueJob("JOB0", jobBuilder0);
 
+    // Make sure master has been correctly switched to Participant1
+    boolean isMasterSwitchedToCorrectInstance = TestHelper.verify(() -> {
+      ExternalView externalView =
+          
_gSetupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, 
DATABASE);
+      if (externalView == null) {
+        return false;
+      }
+      Map<String, String> stateMap = externalView.getStateMap(DATABASE + "_0");
+      return "MASTER".equals(stateMap.get(PARTICIPANT_PREFIX + "_" + 
(_startPort + 1)));

Review comment:
       Do we need to do a null check on stateMap here?




----------------------------------------------------------------
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