use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestClusterVerifier method testDisablePartitionAndStopInstance.
@Test
public void testDisablePartitionAndStopInstance() throws InterruptedException {
// Just ensure that the entire cluster passes
// ensure that the external view coalesces
HelixClusterVerifier bestPossibleVerifier = new BestPossibleExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).build();
Assert.assertTrue(bestPossibleVerifier.verify(10000));
HelixClusterVerifier strictMatchVerifier = new StrictMatchExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).build();
Assert.assertTrue(strictMatchVerifier.verify(10000));
// Disable partition for 1 instance, then Full-Auto ExternalView should not match IdealState.
_admin.enablePartition(false, _clusterName, _participants[0].getInstanceName(), FULL_AUTO_RESOURCES[0], Lists.newArrayList(FULL_AUTO_RESOURCES[0] + "_0"));
Thread.sleep(1000);
Assert.assertFalse(strictMatchVerifier.verify(3000));
// Enable the partition back
_admin.enablePartition(true, _clusterName, _participants[0].getInstanceName(), FULL_AUTO_RESOURCES[0], Lists.newArrayList(FULL_AUTO_RESOURCES[0] + "_0"));
Thread.sleep(1000);
Assert.assertTrue(strictMatchVerifier.verify(10000));
// Make 1 instance non-live
_participants[0].syncStop();
Thread.sleep(1000);
// Semi-Auto ExternalView should not match IdealState
for (String resource : SEMI_AUTO_RESOURCES) {
System.out.println("Un-verify resource: " + resource);
strictMatchVerifier = new StrictMatchExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).setResources(Sets.newHashSet(resource)).build();
Assert.assertFalse(strictMatchVerifier.verify(3000));
}
// Full-Auto still match, because preference list wouldn't contain non-live instances
strictMatchVerifier = new StrictMatchExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).setResources(Sets.newHashSet(FULL_AUTO_RESOURCES)).build();
Assert.assertTrue(strictMatchVerifier.verify(10000));
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestClusterVerifier method testSleepTransition.
@Test
public void testSleepTransition() throws InterruptedException {
HelixClusterVerifier bestPossibleVerifier = new BestPossibleExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).build();
Assert.assertTrue(bestPossibleVerifier.verify(10000));
HelixClusterVerifier strictMatchVerifier = new StrictMatchExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).build();
Assert.assertTrue(strictMatchVerifier.verify(10000));
// Re-start a new participant with sleeping transition(all state model transition cannot finish)
_participants[0].syncStop();
Thread.sleep(1000);
_participants[0] = new MockParticipantManager(ZK_ADDR, _clusterName, _participants[0].getInstanceName());
_participants[0].setTransition(new SleepTransition(99999999));
_participants[0].syncStart();
// The new participant causes rebalance, but the state transitions are all stuck
Thread.sleep(1000);
Assert.assertFalse(strictMatchVerifier.verify(3000));
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestDriver method verifyCluster.
public static void verifyCluster(String uniqClusterName, long beginTime, long timeout) throws Exception {
Thread.sleep(beginTime);
if (!_testInfoMap.containsKey(uniqClusterName)) {
String errMsg = "test cluster hasn't been setup:" + uniqClusterName;
throw new IllegalArgumentException(errMsg);
}
TestInfo testInfo = _testInfoMap.get(uniqClusterName);
String clusterName = testInfo._clusterName;
HelixClusterVerifier verifier = new BestPossibleExternalViewVerifier.Builder(clusterName).setZkAddr(ZK_ADDR).build();
Assert.assertTrue(verifier.verify());
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestPartitionMovementThrottle method testResourceThrottle.
@Test()
public void testResourceThrottle() throws Exception {
// start a few participants
for (int i = 0; i < NODE_NR - 2; i++) {
_participants[i].syncStart();
}
for (int i = 0; i < 5; i++) {
String dbName = "TestDB-" + i;
_setupTool.addResourceToCluster(CLUSTER_NAME, dbName, 10, STATE_MODEL, RebalanceMode.FULL_AUTO + "");
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, dbName, _replica);
_dbs.add(dbName);
}
HelixClusterVerifier _clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
Assert.assertTrue(_clusterVerifier.verify());
DelayedTransition.setDelay(20);
DelayedTransition.enableThrottleRecord();
// add 2 nodes
for (int i = NODE_NR - 2; i < NODE_NR; i++) {
_participants[i].syncStart();
}
Thread.sleep(2000);
for (String db : _dbs) {
validateThrottle(DelayedTransition.getResourcePatitionTransitionTimes(), db, 2);
}
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestPartitionMovementThrottle method testPartitionRecoveryRebalanceThrottle.
@Test
public void testPartitionRecoveryRebalanceThrottle() throws InterruptedException {
// start some participants
for (int i = 0; i < NODE_NR - 2; i++) {
_participants[i].syncStart();
}
_setupTool.addResourceToCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB, 10, STATE_MODEL, RebalanceMode.FULL_AUTO.name());
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB, _replica);
HelixClusterVerifier _clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
Assert.assertTrue(_clusterVerifier.verify());
// Set throttling after states are stable. Otherwise it takes too long to reach stable state
setSingleThrottlingConfig(StateTransitionThrottleConfig.RebalanceType.RECOVERY_BALANCE, StateTransitionThrottleConfig.ThrottleScope.INSTANCE, 2);
DelayedTransition.setDelay(20);
DelayedTransition.enableThrottleRecord();
// start another 2 nodes
for (int i = NODE_NR - 2; i < NODE_NR; i++) {
_participants[i].syncStart();
}
Thread.sleep(2000);
for (int i = 0; i < NODE_NR; i++) {
validateThrottle(DelayedTransition.getInstancePatitionTransitionTimes(), _participants[i].getInstanceName(), 2);
}
}
Aggregations