use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestCrushAutoRebalance method testLackEnoughLiveRacks.
@Test(dependsOnMethods = { "testZoneIsolation", "testZoneIsolationWithInstanceTag" })
public void testLackEnoughLiveRacks() 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();
}
}
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 testLackEnoughInstances.
@Test(dataProvider = "rebalanceStrategies", enabled = true, dependsOnMethods = { "testLackEnoughLiveInstances" })
public void testLackEnoughInstances(String rebalanceStrategyName, String rebalanceStrategyClass) throws Exception {
System.out.println("TestLackEnoughInstances " + rebalanceStrategyName);
enablePersistBestPossibleAssignment(_gZkClient, CLUSTER_NAME, true);
// shutdown participants, keep only two left
for (int i = 2; i < _participants.size(); i++) {
MockParticipantManager p = _participants.get(i);
p.syncStop();
_setupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME, p.getInstanceName(), false);
Thread.sleep(50);
_setupTool.dropInstanceFromCluster(CLUSTER_NAME, p.getInstanceName());
}
int j = 0;
for (String stateModel : _testModels) {
String db = "Test-DB-" + rebalanceStrategyName + "-" + j++;
_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());
for (String db : _allDBs) {
IdealState is = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, db);
ExternalView ev = _setupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, db);
validateIsolation(is, ev, 2);
}
// recover test environment
ConfigAccessor configAccessor = new ConfigAccessor(_gZkClient);
for (int i = 2; i < _participants.size(); i++) {
String storageNodeName = _participants.get(i).getInstanceName();
_setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
InstanceConfig instanceConfig = configAccessor.getInstanceConfig(CLUSTER_NAME, storageNodeName);
instanceConfig.setDomain("instance=" + storageNodeName);
configAccessor.setInstanceConfig(CLUSTER_NAME, storageNodeName, instanceConfig);
MockParticipantManager participant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, storageNodeName);
participant.syncStart();
_participants.set(i, participant);
}
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestCrushAutoRebalanceNonRack method testLackEnoughLiveInstances.
@Test(dataProvider = "rebalanceStrategies", enabled = true, dependsOnMethods = { "testWithInstanceTag" })
public void testLackEnoughLiveInstances(String rebalanceStrategyName, String rebalanceStrategyClass) throws Exception {
System.out.println("TestLackEnoughLiveInstances " + rebalanceStrategyName);
enablePersistBestPossibleAssignment(_gZkClient, CLUSTER_NAME, true);
// shutdown participants, keep only two left
for (int i = 2; i < _participants.size(); i++) {
_participants.get(i).syncStop();
}
int j = 0;
for (String stateModel : _testModels) {
String db = "Test-DB-" + rebalanceStrategyName + "-" + j++;
_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, 2);
}
for (int i = 2; i < _participants.size(); i++) {
_participants.get(i).syncStart();
}
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestZkConnectionLost method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
_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();
createManagers();
// start controller
String controllerName = CONTROLLER_PREFIX + "_0";
_controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
_controller.syncStart();
HelixClusterVerifier clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
Assert.assertTrue(clusterVerifier.verify());
_zkServerRef.set(_zkServer);
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestClusterDataCacheSelectiveUpdate method testSelectiveUpdates.
@Test(dependsOnMethods = { "testUpdateOnNotification" })
public void testSelectiveUpdates() throws Exception {
MockZkHelixDataAccessor accessor = new MockZkHelixDataAccessor(CLUSTER_NAME, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
ClusterDataCache cache = new ClusterDataCache("CLUSTER_" + TestHelper.getTestClassName());
cache.refresh(accessor);
Assert.assertEquals(accessor.getReadCount(PropertyType.IDEALSTATES), 1);
Assert.assertEquals(accessor.getReadCount(PropertyType.LIVEINSTANCES), NODE_NR);
Assert.assertEquals(accessor.getReadCount(PropertyType.CURRENTSTATES), NODE_NR);
Assert.assertEquals(accessor.getReadCount(PropertyType.CONFIGS), NODE_NR + 1);
accessor.clearReadCounters();
// refresh again should read nothing
cache.refresh(accessor);
Assert.assertEquals(accessor.getReadCount(PropertyType.IDEALSTATES), 0);
Assert.assertEquals(accessor.getReadCount(PropertyType.LIVEINSTANCES), 0);
Assert.assertEquals(accessor.getReadCount(PropertyType.CURRENTSTATES), 0);
Assert.assertEquals(accessor.getReadCount(PropertyType.CONFIGS), 1);
// add a new resource
_setupTool.addResourceToCluster(CLUSTER_NAME, "TestDB_1", _PARTITIONS, STATE_MODEL);
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, "TestDB_1", _replica);
Thread.sleep(100);
HelixClusterVerifier _clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
Assert.assertTrue(_clusterVerifier.verify());
accessor.clearReadCounters();
// refresh again should read only new current states and new idealstate
cache.notifyDataChange(HelixConstants.ChangeType.IDEAL_STATE);
cache.refresh(accessor);
Assert.assertEquals(accessor.getReadCount(PropertyType.CURRENTSTATES), NODE_NR);
Assert.assertEquals(accessor.getReadCount(PropertyType.IDEALSTATES), 1);
// Add more resources
accessor.clearReadCounters();
_setupTool.addResourceToCluster(CLUSTER_NAME, "TestDB_2", _PARTITIONS, STATE_MODEL);
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, "TestDB_2", _replica);
_setupTool.addResourceToCluster(CLUSTER_NAME, "TestDB_3", _PARTITIONS, STATE_MODEL);
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, "TestDB_3", _replica);
// Totally four resources. Two of them are newly added.
cache.notifyDataChange(HelixConstants.ChangeType.IDEAL_STATE);
cache.refresh(accessor);
Assert.assertEquals(accessor.getReadCount(PropertyType.IDEALSTATES), 2);
}
Aggregations