Search in sources :

Example 21 with HelixClusterVerifier

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));
}
Also used : ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) ConfigAccessor(org.apache.helix.ConfigAccessor) ClusterSetup(org.apache.helix.tools.ClusterSetup) ClusterConfig(org.apache.helix.model.ClusterConfig) BeforeClass(org.testng.annotations.BeforeClass)

Example 22 with HelixClusterVerifier

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

Example 23 with HelixClusterVerifier

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

Example 24 with HelixClusterVerifier

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

Example 25 with HelixClusterVerifier

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