use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestCrushAutoRebalanceNonRack method test.
@Test(dataProvider = "rebalanceStrategies", enabled = true)
public void test(String rebalanceStrategyName, String rebalanceStrategyClass) throws Exception {
System.out.println("Test " + rebalanceStrategyName);
int i = 0;
for (String stateModel : _testModels) {
String db = "Test-DB-" + rebalanceStrategyName + "-" + i++;
_setupTool.addResourceToCluster(CLUSTER_NAME, db, _PARTITIONS, stateModel, RebalanceMode.FULL_AUTO + "", rebalanceStrategyClass);
_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);
}
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestRoutingTableProviderFromCurrentStates method testRoutingTableWithCurrentStates.
@Test
public void testRoutingTableWithCurrentStates() throws InterruptedException {
RoutingTableProvider routingTableEV = new RoutingTableProvider(_manager, PropertyType.EXTERNALVIEW);
RoutingTableProvider routingTableCurrentStates = new RoutingTableProvider(_manager, PropertyType.CURRENTSTATES);
String db1 = "TestDB-1";
_setupTool.addResourceToCluster(CLUSTER_NAME, db1, NUM_PARTITIONS, "MasterSlave", IdealState.RebalanceMode.FULL_AUTO.name());
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, db1, NUM_REPLICAS);
Thread.sleep(200);
HelixClusterVerifier clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
Assert.assertTrue(clusterVerifier.verify());
IdealState idealState1 = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, db1);
validate(idealState1, routingTableEV, routingTableCurrentStates);
// add new DB
String db2 = "TestDB-2";
_setupTool.addResourceToCluster(CLUSTER_NAME, db2, NUM_PARTITIONS, "MasterSlave", IdealState.RebalanceMode.FULL_AUTO.name());
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, db2, NUM_REPLICAS);
Thread.sleep(200);
Assert.assertTrue(clusterVerifier.verify());
IdealState idealState2 = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, db2);
validate(idealState2, routingTableEV, routingTableCurrentStates);
// shutdown an instance
_participants[0].syncStop();
Thread.sleep(200);
Assert.assertTrue(clusterVerifier.verify());
validate(idealState1, routingTableEV, routingTableCurrentStates);
validate(idealState2, routingTableEV, routingTableCurrentStates);
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestRoutingTableSnapshot method testRoutingTableSnapshot.
@Test
public void testRoutingTableSnapshot() throws InterruptedException {
RoutingTableProvider routingTableProvider = new RoutingTableProvider(_manager, PropertyType.EXTERNALVIEW);
String db1 = "TestDB-1";
_setupTool.addResourceToCluster(CLUSTER_NAME, db1, NUM_PARTITIONS, "MasterSlave", IdealState.RebalanceMode.FULL_AUTO.name());
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, db1, NUM_REPLICAS);
Thread.sleep(200);
HelixClusterVerifier clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
Assert.assertTrue(clusterVerifier.verify());
IdealState idealState1 = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, db1);
RoutingTableSnapshot routingTableSnapshot = routingTableProvider.getRoutingTableSnapshot();
validateMapping(idealState1, routingTableSnapshot);
Assert.assertEquals(routingTableSnapshot.getInstanceConfigs().size(), NUM_NODES);
Assert.assertEquals(routingTableSnapshot.getResources().size(), 1);
Assert.assertEquals(routingTableSnapshot.getLiveInstances().size(), NUM_NODES);
// add new DB and shutdown an instance
String db2 = "TestDB-2";
_setupTool.addResourceToCluster(CLUSTER_NAME, db2, NUM_PARTITIONS, "MasterSlave", IdealState.RebalanceMode.FULL_AUTO.name());
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, db2, NUM_REPLICAS);
// shutdown an instance
_participants[0].syncStop();
Thread.sleep(200);
Assert.assertTrue(clusterVerifier.verify());
// the original snapshot should not change
Assert.assertEquals(routingTableSnapshot.getInstanceConfigs().size(), NUM_NODES);
Assert.assertEquals(routingTableSnapshot.getResources().size(), 1);
Assert.assertEquals(routingTableSnapshot.getLiveInstances().size(), NUM_NODES);
RoutingTableSnapshot newRoutingTableSnapshot = routingTableProvider.getRoutingTableSnapshot();
Assert.assertEquals(newRoutingTableSnapshot.getInstanceConfigs().size(), NUM_NODES);
Assert.assertEquals(newRoutingTableSnapshot.getResources().size(), 2);
Assert.assertEquals(newRoutingTableSnapshot.getLiveInstances().size(), NUM_NODES - 1);
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestJobFailureHighThreshold method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
_participants = new MockParticipantManager[_numNodes];
_numDbs = 1;
_numNodes = 1;
_numParitions = 5;
_numReplicas = 1;
String namespace = "/" + CLUSTER_NAME;
if (_gZkClient.exists(namespace)) {
_gZkClient.deleteRecursively(namespace);
}
_setupTool = new ClusterSetup(ZK_ADDR);
_setupTool.addCluster(CLUSTER_NAME, true);
setupParticipants();
setupDBs();
startParticipants();
createManagers();
_controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, CONTROLLER_PREFIX);
_controller.syncStart();
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 TestJobFailureTaskNotStarted method setupUnbalancedDB.
private void setupUnbalancedDB() throws InterruptedException {
// Start with Full-Auto mode to create the partitions, Semi-Auto won't create partitions.
_setupTool.addResourceToCluster(CLUSTER_NAME, UNBALANCED_DB_NAME, 50, MASTER_SLAVE_STATE_MODEL, IdealState.RebalanceMode.FULL_AUTO.toString());
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, UNBALANCED_DB_NAME, 1);
// Set preference list to put all partitions to one instance.
IdealState idealState = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, UNBALANCED_DB_NAME);
Set<String> partitions = idealState.getPartitionSet();
for (String partition : partitions) {
idealState.setPreferenceList(partition, Lists.newArrayList(_blockedParticipant.getInstanceName()));
}
idealState.setRebalanceMode(IdealState.RebalanceMode.SEMI_AUTO);
_setupTool.getClusterManagementTool().setResourceIdealState(CLUSTER_NAME, UNBALANCED_DB_NAME, idealState);
HelixClusterVerifier clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient).build();
Assert.assertTrue(clusterVerifier.verify(10000));
}
Aggregations