Search in sources :

Example 1 with HelixClusterVerifier

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));
}
Also used : HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) Test(org.testng.annotations.Test)

Example 2 with HelixClusterVerifier

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));
}
Also used : HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) SleepTransition(org.apache.helix.mock.participant.SleepTransition) Test(org.testng.annotations.Test)

Example 3 with HelixClusterVerifier

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());
}
Also used : HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) PropertyPathBuilder(org.apache.helix.PropertyPathBuilder)

Example 4 with HelixClusterVerifier

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);
    }
}
Also used : HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) Test(org.testng.annotations.Test)

Example 5 with HelixClusterVerifier

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);
    }
}
Also used : HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) Test(org.testng.annotations.Test)

Aggregations

HelixClusterVerifier (org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier)43 Test (org.testng.annotations.Test)38 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)19 ClusterControllerManager (org.apache.helix.integration.manager.ClusterControllerManager)17 Date (java.util.Date)15 BestPossibleExternalViewVerifier (org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier)14 IdealState (org.apache.helix.model.IdealState)13 Set (java.util.Set)7 ZNRecord (org.apache.helix.ZNRecord)7 ZKHelixDataAccessor (org.apache.helix.manager.zk.ZKHelixDataAccessor)7 ExternalView (org.apache.helix.model.ExternalView)7 Map (java.util.Map)6 PropertyKey (org.apache.helix.PropertyKey)6 StrictMatchExternalViewVerifier (org.apache.helix.tools.ClusterVerifiers.StrictMatchExternalViewVerifier)5 HashMap (java.util.HashMap)4 ConfigAccessor (org.apache.helix.ConfigAccessor)4 HashSet (java.util.HashSet)3 ErrTransition (org.apache.helix.mock.participant.ErrTransition)3 ClusterConfig (org.apache.helix.model.ClusterConfig)3 CurrentState (org.apache.helix.model.CurrentState)3