Source:
public void testFixedTargetTaskAndDisabledRebalanceAndNodeAdded() throws Exception { WORKFLOW = TestHelper.getTestMethodName(); JobConfig.Builder jobBuilder = new JobConfig.Builder().setWorkflow(WORKFLOW).setTargetResource(DATABASE) .setTargetPartitionStates(Sets.newHashSet(MasterSlaveSMD.States.MASTER.name())) .setNumConcurrentTasksPerInstance(100).setFailureThreshold(2).setMaxAttemptsPerTask(2) .setCommand(MockTask.TASK_COMMAND) .setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "99999999")); Workflow.Builder workflowBuilder = new Workflow.Builder(WORKFLOW).addJob(JOB, jobBuilder); _driver.start(workflowBuilder.build()); Assert.assertTrue(checkTasksOnSameInstances()); System.out.println("Start new participant"); startParticipant(_initialNumNodes); ZkHelixClusterVerifier clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient) .setResources(Sets.newHashSet(DATABASE)).build(); Assert.assertTrue(clusterVerifier.verify(10 * 1000)); 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); }, TestHelper.WAIT_DURATION); Assert.assertTrue(isMasterOnTwoDifferentNodes); Assert.assertTrue(checkTasksOnDifferentInstances()); }

Target:
public void testFixedTargetTaskAndDisabledRebalanceAndNodeAdded() throws Exception { WORKFLOW = TestHelper.getTestMethodName(); JobConfig.Builder jobBuilder = new JobConfig.Builder().setWorkflow(WORKFLOW).setTargetResource(DATABASE) .setTargetPartitionStates(Sets.newHashSet(MasterSlaveSMD.States.MASTER.name())) .setNumConcurrentTasksPerInstance(100).setFailureThreshold(2).setMaxAttemptsPerTask(2) .setCommand(MockTask.TASK_COMMAND) .setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "99999999")); Workflow.Builder workflowBuilder = new Workflow.Builder(WORKFLOW).addJob(JOB, jobBuilder); _driver.start(workflowBuilder.build()); Assert.assertTrue(checkTasksOnSameInstances()); System.out.println("Start new participant"); startParticipant(_initialNumNodes); ZkHelixClusterVerifier clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient) .setResources(Sets.newHashSet(DATABASE)).build(); Assert.assertTrue(clusterVerifier.verify(10 * 1000)); boolean isMasterOnTwoDifferentNodes = TestHelper.verify(() -> { Set<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"); if (stateMap0 == null || stateMap1 == null) { return false; } 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; }, TestHelper.WAIT_DURATION); Assert.assertTrue(isMasterOnTwoDifferentNodes); Assert.assertTrue(checkTasksOnDifferentInstances()); }