use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestJobTimeoutTaskNotStarted method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
_numDbs = 1;
_numNodes = 1;
_numParitions = 50;
_numReplicas = 1;
_participants = new MockParticipantManager[_numNodes];
String namespace = "/" + CLUSTER_NAME;
if (_gZkClient.exists(namespace)) {
_gZkClient.deleteRecursively(namespace);
}
_setupTool = new ClusterSetup(ZK_ADDR);
_setupTool.addCluster(CLUSTER_NAME, true);
setupParticipants();
setupDBs();
startParticipantsWithStuckTaskStateModelFactory();
createManagers();
_controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, CONTROLLER_PREFIX);
_controller.syncStart();
// Enable cancellation
ConfigAccessor _configAccessor = new ConfigAccessor(_gZkClient);
ClusterConfig clusterConfig = _configAccessor.getClusterConfig(CLUSTER_NAME);
clusterConfig.stateTransitionCancelEnabled(true);
clusterConfig.setMaxConcurrentTaskPerInstance(_numParitions);
_configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);
HelixClusterVerifier clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient).build();
Assert.assertTrue(clusterVerifier.verify(10000));
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestRebalanceRunningTask method testFixedTargetTaskAndEnabledRebalanceAndNodeAdded.
/**
* Task type: fixed target
* Rebalance raunning task: enabled
* Story: new node added
*/
@Test
public void testFixedTargetTaskAndEnabledRebalanceAndNodeAdded() throws InterruptedException {
WORKFLOW = TestHelper.getTestMethodName();
JobConfig.Builder jobBuilder = new JobConfig.Builder().setWorkflow(WORKFLOW).setTargetResource(DATABASE).setTargetPartitionStates(Sets.newHashSet(MasterSlaveSMD.States.MASTER.name())).setNumConcurrentTasksPerInstance(100).setRebalanceRunningTask(true).setCommand(MockTask.TASK_COMMAND).setJobCommandConfigMap(// task stuck
ImmutableMap.of(MockTask.TIMEOUT_CONFIG, "99999999"));
Workflow.Builder workflowBuilder = new Workflow.Builder(WORKFLOW).addJob(JOB, jobBuilder);
_driver.start(workflowBuilder.build());
// All tasks stuck on the same instance
Assert.assertTrue(checkTasksOnSameInstances());
// Add a new instance, partition is rebalanced
startParticipant(_initialNumNodes);
HelixClusterVerifier clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient).setResources(Sets.newHashSet(DATABASE)).build();
Assert.assertTrue(clusterVerifier.verify(10 * 1000));
// Running tasks are also rebalanced
Assert.assertTrue(checkTasksOnDifferentInstances());
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestTargetExternalView method testTargetExternalViewEnable.
@Test
public void testTargetExternalViewEnable() throws InterruptedException {
// Before enable target external view
Assert.assertFalse(_gZkClient.exists(_accessor.keyBuilder().targetExternalViews().getPath()));
ClusterConfig clusterConfig = _configAccessor.getClusterConfig(CLUSTER_NAME);
clusterConfig.enableTargetExternalView(true);
clusterConfig.setPersistIntermediateAssignment(true);
_configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);
_gSetupTool.getClusterManagementTool().rebalance(CLUSTER_NAME, _testDbs.get(0), 3);
HelixClusterVerifier verifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
Assert.assertTrue(verifier.verify());
Assert.assertEquals(_accessor.getChildNames(_accessor.keyBuilder().targetExternalViews()).size(), 3);
List<ExternalView> targetExternalViews = _accessor.getChildValues(_accessor.keyBuilder().externalViews());
List<IdealState> idealStates = _accessor.getChildValues(_accessor.keyBuilder().idealStates());
for (int i = 0; i < idealStates.size(); i++) {
Assert.assertEquals(targetExternalViews.get(i).getRecord().getMapFields(), idealStates.get(i).getRecord().getMapFields());
Assert.assertEquals(targetExternalViews.get(i).getRecord().getListFields(), idealStates.get(i).getRecord().getListFields());
}
// Disable one instance to see whether the target external views changes.
_gSetupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME, _participants[0].getInstanceName(), false);
Assert.assertTrue(verifier.verify());
targetExternalViews = _accessor.getChildValues(_accessor.keyBuilder().externalViews());
idealStates = _accessor.getChildValues(_accessor.keyBuilder().idealStates());
for (int i = 0; i < idealStates.size(); i++) {
Assert.assertEquals(targetExternalViews.get(i).getRecord().getMapFields(), idealStates.get(i).getRecord().getMapFields());
Assert.assertEquals(targetExternalViews.get(i).getRecord().getListFields(), idealStates.get(i).getRecord().getListFields());
}
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestCrushAutoRebalance method testLackEnoughRacks.
@Test(dependsOnMethods = { "testLackEnoughLiveRacks" })
public void testLackEnoughRacks() throws Exception {
System.out.println("TestLackEnoughInstances ");
enablePersistBestPossibleAssignment(_gZkClient, CLUSTER_NAME, true);
// shutdown participants within one zone
String zone = _nodeToZoneMap.values().iterator().next();
for (int i = 0; i < _participants.size(); i++) {
MockParticipantManager p = _participants.get(i);
if (_nodeToZoneMap.get(p.getInstanceName()).equals(zone)) {
p.syncStop();
_setupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME, p.getInstanceName(), false);
Thread.sleep(50);
_setupTool.dropInstanceFromCluster(CLUSTER_NAME, p.getInstanceName());
}
}
int i = 0;
for (String stateModel : _testModels) {
String db = "Test-DB-CrushRebalanceStrategy-" + i++;
_setupTool.addResourceToCluster(CLUSTER_NAME, db, _PARTITIONS, stateModel, RebalanceMode.FULL_AUTO + "", CrushRebalanceStrategy.class.getName());
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, db, _replica);
_allDBs.add(db);
}
Thread.sleep(300);
HelixClusterVerifier _clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).setResources(_allDBs).build();
Assert.assertTrue(_clusterVerifier.verify());
for (String db : _allDBs) {
IdealState is = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, db);
ExternalView ev = _setupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, db);
validateZoneAndTagIsolation(is, ev, 2);
}
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestCrushAutoRebalanceNonRack method testWithInstanceTag.
@Test(dataProvider = "rebalanceStrategies", enabled = true, dependsOnMethods = "test")
public void testWithInstanceTag(String rebalanceStrategyName, String rebalanceStrategyClass) throws Exception {
Set<String> tags = new HashSet<String>(_nodeToTagMap.values());
int i = 3;
for (String tag : tags) {
String db = "Test-DB-" + rebalanceStrategyName + "-" + i++;
_setupTool.addResourceToCluster(CLUSTER_NAME, db, _PARTITIONS, BuiltInStateModelDefinitions.MasterSlave.name(), RebalanceMode.FULL_AUTO + "", rebalanceStrategyClass);
IdealState is = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, db);
is.setInstanceGroupTag(tag);
_setupTool.getClusterManagementTool().setResourceIdealState(CLUSTER_NAME, db, is);
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, db, _replica);
_allDBs.add(db);
}
Thread.sleep(300);
HelixClusterVerifier _clusterVerifier = new StrictMatchExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).setResources(_allDBs).build();
Assert.assertTrue(_clusterVerifier.verify(5000));
for (String db : _allDBs) {
IdealState is = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, db);
ExternalView ev = _setupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, db);
validateIsolation(is, ev, _replica);
}
}
Aggregations