Search in sources :

Example 6 with HelixClusterVerifier

use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.

the class TestPartitionMovementThrottle method testANYtypeThrottle.

@Test
public void testANYtypeThrottle() throws InterruptedException {
    // start some participants
    for (int i = 0; i < NODE_NR - 3; i++) {
        _participants[i].syncStart();
    }
    _setupTool.addResourceToCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "_ANY", 20, STATE_MODEL, RebalanceMode.FULL_AUTO.name());
    _setupTool.rebalanceStorageCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "_ANY", _replica);
    HelixClusterVerifier _clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
    Assert.assertTrue(_clusterVerifier.verify());
    // Set ANY type throttling after states are stable.
    setSingleThrottlingConfig(StateTransitionThrottleConfig.RebalanceType.ANY, StateTransitionThrottleConfig.ThrottleScope.INSTANCE, 1);
    DelayedTransition.setDelay(20);
    DelayedTransition.enableThrottleRecord();
    // start another 3 nodes
    for (int i = NODE_NR - 3; i < NODE_NR; i++) {
        _participants[i].syncStart();
    }
    Thread.sleep(2000L);
    for (int i = 0; i < NODE_NR; i++) {
        validateThrottle(DelayedTransition.getInstancePatitionTransitionTimes(), _participants[i].getInstanceName(), 1);
    }
}
Also used : HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) Test(org.testng.annotations.Test)

Example 7 with HelixClusterVerifier

use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.

the class TestZkCallbackHandlerLeak method testCbHandlerLeakOnParticipantSessionExpiry.

@Test
public void testCbHandlerLeakOnParticipantSessionExpiry() throws Exception {
    // Logger.getRootLogger().setLevel(Level.INFO);
    String className = TestHelper.getTestClassName();
    String methodName = TestHelper.getTestMethodName();
    String clusterName = className + "_" + methodName;
    final int n = 2;
    final int r = 2;
    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
    // participant port
    TestHelper.setupCluster(// participant port
    clusterName, // participant port
    ZK_ADDR, // participant port
    12918, // participant name prefix
    "localhost", // resource name prefix
    "TestDB", // resources
    r, // partitions per resource
    32, // number of nodes
    n, // replicas
    2, "MasterSlave", // do rebalance
    true);
    final ClusterControllerManager controller = new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
    controller.syncStart();
    // start participants
    MockParticipantManager[] participants = new MockParticipantManager[n];
    for (int i = 0; i < n; i++) {
        String instanceName = "localhost_" + (12918 + i);
        participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
        participants[i].syncStart();
    }
    HelixClusterVerifier verifier = new BestPossibleExternalViewVerifier.Builder(clusterName).setZkAddr(ZK_ADDR).build();
    Assert.assertTrue(verifier.verify());
    final MockParticipantManager participantManagerToExpire = participants[1];
    // check controller zk-watchers
    boolean result = TestHelper.verify(new TestHelper.Verifier() {

        @Override
        public boolean verify() throws Exception {
            Map<String, Set<String>> watchers = ZkTestHelper.getListenersBySession(ZK_ADDR);
            // Set<String> watchPaths = watchers.get("0x" + controllerManager.getSessionId());
            Set<String> watchPaths = watchers.get("0x" + controller.getSessionId());
            // where n is number of nodes and r is number of resources
            return watchPaths.size() == (7 + r + (4 + r) * n);
        }
    }, 2000);
    Assert.assertTrue(result, "Controller has incorrect number of zk-watchers.");
    // check participant zk-watchers
    result = TestHelper.verify(new TestHelper.Verifier() {

        @Override
        public boolean verify() throws Exception {
            Map<String, Set<String>> watchers = ZkTestHelper.getListenersBySession(ZK_ADDR);
            Set<String> watchPaths = watchers.get("0x" + participantManagerToExpire.getSessionId());
            // participant should have 1 zk-watcher: 1 for MESSAGE
            return watchPaths.size() == 1;
        }
    }, 2000);
    Assert.assertTrue(result, "Participant should have 1 zk-watcher. MESSAGES->HelixTaskExecutor");
    // check HelixManager#_handlers
    // printHandlers(controllerManager);
    // printHandlers(participantManagerToExpire);
    int controllerHandlerNb = controller.getHandlers().size();
    int particHandlerNb = participantManagerToExpire.getHandlers().size();
    Assert.assertEquals(controllerHandlerNb, 11, "HelixController should have 10 (5+2n) callback handlers for 2 (n) participant");
    Assert.assertEquals(particHandlerNb, 1, "HelixParticipant should have 1 (msg->HelixTaskExecutor) callback handlers");
    // expire the session of participant
    System.out.println("Expiring participant session...");
    String oldSessionId = participantManagerToExpire.getSessionId();
    ZkTestHelper.expireSession(participantManagerToExpire.getZkClient());
    String newSessionId = participantManagerToExpire.getSessionId();
    System.out.println("Expried participant session. oldSessionId: " + oldSessionId + ", newSessionId: " + newSessionId);
    result = ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR, clusterName));
    Assert.assertTrue(result);
    // check controller zk-watchers
    result = TestHelper.verify(new TestHelper.Verifier() {

        @Override
        public boolean verify() throws Exception {
            Map<String, Set<String>> watchers = ZkTestHelper.getListenersBySession(ZK_ADDR);
            Set<String> watchPaths = watchers.get("0x" + controller.getSessionId());
            // where n is number of nodes and r is number of resources
            return watchPaths.size() == (7 + r + (4 + r) * n);
        }
    }, 2000);
    Assert.assertTrue(result, "Controller has incorrect number of zk-watchers after session expiry.");
    // check participant zk-watchers
    result = TestHelper.verify(new TestHelper.Verifier() {

        @Override
        public boolean verify() throws Exception {
            Map<String, Set<String>> watchers = ZkTestHelper.getListenersBySession(ZK_ADDR);
            Set<String> watchPaths = watchers.get("0x" + participantManagerToExpire.getSessionId());
            // participant should have 1 zk-watcher: 1 for MESSAGE
            return watchPaths.size() == 1;
        }
    }, 2000);
    Assert.assertTrue(result, "Participant should have 1 zk-watcher after session expiry.");
    // check handlers
    // printHandlers(controllerManager);
    // printHandlers(participantManagerToExpire);
    int handlerNb = controller.getHandlers().size();
    Assert.assertEquals(handlerNb, controllerHandlerNb, "controller callback handlers should not increase after participant session expiry");
    handlerNb = participantManagerToExpire.getHandlers().size();
    Assert.assertEquals(handlerNb, particHandlerNb, "participant callback handlers should not increase after participant session expiry");
    // clean up
    controller.syncStop();
    for (int i = 0; i < n; i++) {
        participants[i].syncStop();
    }
    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
Also used : HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) Set(java.util.Set) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) ClusterStateVerifier(org.apache.helix.tools.ClusterStateVerifier) BestPossibleExternalViewVerifier(org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier) Date(java.util.Date) ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) Map(java.util.Map) Test(org.testng.annotations.Test)

Example 8 with HelixClusterVerifier

use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.

the class TestZkCallbackHandlerLeak method testCbHandlerLeakOnControllerSessionExpiry.

@Test
public void testCbHandlerLeakOnControllerSessionExpiry() throws Exception {
    // Logger.getRootLogger().setLevel(Level.INFO);
    String className = TestHelper.getTestClassName();
    String methodName = TestHelper.getTestMethodName();
    String clusterName = className + "_" + methodName;
    final int n = 2;
    final int r = 1;
    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
    // participant port
    TestHelper.setupCluster(// participant port
    clusterName, // participant port
    ZK_ADDR, // participant port
    12918, // participant name prefix
    "localhost", // resource name prefix
    "TestDB", // resources
    r, // partitions per resource
    32, // number of nodes
    n, // replicas
    2, "MasterSlave", // do rebalance
    true);
    final ClusterControllerManager controller = new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
    controller.syncStart();
    // start participants
    MockParticipantManager[] participants = new MockParticipantManager[n];
    for (int i = 0; i < n; i++) {
        String instanceName = "localhost_" + (12918 + i);
        participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
        participants[i].syncStart();
    }
    HelixClusterVerifier verifier = new BestPossibleExternalViewVerifier.Builder(clusterName).setZkAddr(ZK_ADDR).build();
    Assert.assertTrue(verifier.verify());
    final MockParticipantManager participantManager = participants[0];
    // wait until we get all the listeners registered
    TestHelper.verify(new TestHelper.Verifier() {

        @Override
        public boolean verify() throws Exception {
            int controllerHandlerNb = controller.getHandlers().size();
            int particHandlerNb = participantManager.getHandlers().size();
            if (controllerHandlerNb == 10 && particHandlerNb == 2)
                return true;
            else
                return false;
        }
    }, 1000);
    int controllerHandlerNb = controller.getHandlers().size();
    int particHandlerNb = participantManager.getHandlers().size();
    Assert.assertEquals(controllerHandlerNb, 11, "HelixController should have 10 (6+2n) callback handlers for 2 participant, but was " + controllerHandlerNb + ", " + printHandlers(controller));
    Assert.assertEquals(particHandlerNb, 1, "HelixParticipant should have 1 (msg->HelixTaskExecutor) callback handler, but was " + particHandlerNb + ", " + printHandlers(participantManager));
    // expire controller
    System.out.println("Expiring controller session...");
    String oldSessionId = controller.getSessionId();
    ZkTestHelper.expireSession(controller.getZkClient());
    String newSessionId = controller.getSessionId();
    System.out.println("Expired controller session. oldSessionId: " + oldSessionId + ", newSessionId: " + newSessionId);
    Assert.assertTrue(verifier.verify());
    // check controller zk-watchers
    boolean result = TestHelper.verify(new TestHelper.Verifier() {

        @Override
        public boolean verify() throws Exception {
            Map<String, Set<String>> watchers = ZkTestHelper.getListenersBySession(ZK_ADDR);
            Set<String> watchPaths = watchers.get("0x" + controller.getSessionId());
            System.err.println("controller watch paths after session expiry: " + watchPaths.size());
            // where r is number of resources and n is number of nodes
            int expected = (7 + r + (4 + r) * n);
            return watchPaths.size() == expected;
        }
    }, 2000);
    Assert.assertTrue(result, "Controller has incorrect zk-watchers after session expiry.");
    // check participant zk-watchers
    result = TestHelper.verify(new TestHelper.Verifier() {

        @Override
        public boolean verify() throws Exception {
            Map<String, Set<String>> watchers = ZkTestHelper.getListenersBySession(ZK_ADDR);
            Set<String> watchPaths = watchers.get("0x" + participantManager.getSessionId());
            // participant should have 1 zk-watcher: 1 for MESSAGE
            return watchPaths.size() == 1;
        }
    }, 2000);
    Assert.assertTrue(result, "Participant should have 1 zk-watcher after session expiry.");
    // check HelixManager#_handlers
    // printHandlers(controllerManager);
    int handlerNb = controller.getHandlers().size();
    Assert.assertEquals(handlerNb, controllerHandlerNb, "controller callback handlers should not increase after participant session expiry, but was " + printHandlers(controller));
    handlerNb = participantManager.getHandlers().size();
    Assert.assertEquals(handlerNb, particHandlerNb, "participant callback handlers should not increase after participant session expiry, but was " + printHandlers(participantManager));
    // clean up
    controller.syncStop();
    for (int i = 0; i < n; i++) {
        participants[i].syncStop();
    }
    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
Also used : HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) Set(java.util.Set) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) ClusterStateVerifier(org.apache.helix.tools.ClusterStateVerifier) BestPossibleExternalViewVerifier(org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier) Date(java.util.Date) ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) Map(java.util.Map) Test(org.testng.annotations.Test)

Example 9 with HelixClusterVerifier

use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.

the class TestZkCallbackHandlerLeak method testRemoveUserCbHandlerOnPathRemoval.

@Test
public void testRemoveUserCbHandlerOnPathRemoval() throws Exception {
    String className = TestHelper.getTestClassName();
    String methodName = TestHelper.getTestMethodName();
    String clusterName = className + "_" + methodName;
    final int n = 3;
    final String zkAddr = ZK_ADDR;
    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
    // resource
    TestHelper.setupCluster(// resource
    clusterName, // resource
    zkAddr, // resource
    12918, // resource
    "localhost", // resource
    "TestDB", // resource
    1, // partitions
    32, // nodes
    n, // replicas
    2, "MasterSlave", true);
    final ClusterControllerManager controller = new ClusterControllerManager(zkAddr, clusterName, "controller_0");
    controller.syncStart();
    MockParticipantManager[] participants = new MockParticipantManager[n];
    for (int i = 0; i < n; i++) {
        String instanceName = "localhost_" + (12918 + i);
        participants[i] = new MockParticipantManager(zkAddr, clusterName, instanceName);
        participants[i].syncStart();
        // register a controller listener on participant_0
        if (i == 0) {
            // ZkHelixTestManager manager = participants[0].getManager();
            MockParticipantManager manager = participants[0];
            manager.addCurrentStateChangeListener(new CurrentStateChangeListener() {

                @Override
                public void onStateChange(String instanceName, List<CurrentState> statesInfo, NotificationContext changeContext) {
                // To change body of implemented methods use File | Settings | File Templates.
                // System.out.println(instanceName + " on current-state change, type: " +
                // changeContext.getType());
                }
            }, manager.getInstanceName(), manager.getSessionId());
        }
    }
    Boolean result = ClusterStateVerifier.verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(zkAddr, clusterName));
    Assert.assertTrue(result);
    MockParticipantManager participantToExpire = participants[0];
    String oldSessionId = participantToExpire.getSessionId();
    PropertyKey.Builder keyBuilder = new PropertyKey.Builder(clusterName);
    // check manager#hanlders
    Assert.assertEquals(participantToExpire.getHandlers().size(), 2, "Should have 2 handlers: CURRENTSTATE/{sessionId}, and MESSAGES");
    // check zkclient#listeners
    Map<String, Set<IZkDataListener>> dataListeners = ZkTestHelper.getZkDataListener(participantToExpire.getZkClient());
    Map<String, Set<IZkChildListener>> childListeners = ZkTestHelper.getZkChildListener(participantToExpire.getZkClient());
    // printZkListeners(participantToExpire.getZkClient());
    Assert.assertEquals(dataListeners.size(), 1, "Should have 1 path (CURRENTSTATE/{sessionId}/TestDB0) which has 1 data-listeners");
    String path = keyBuilder.currentState(participantToExpire.getInstanceName(), oldSessionId, "TestDB0").getPath();
    Assert.assertEquals(dataListeners.get(path).size(), 1, "Should have 1 data-listeners on path: " + path);
    Assert.assertEquals(childListeners.size(), 2, "Should have 2 paths (CURRENTSTATE/{sessionId}, and MESSAGES) each of which has 1 child-listener");
    path = keyBuilder.currentStates(participantToExpire.getInstanceName(), oldSessionId).getPath();
    Assert.assertEquals(childListeners.get(path).size(), 1, "Should have 1 child-listener on path: " + path);
    path = keyBuilder.messages(participantToExpire.getInstanceName()).getPath();
    Assert.assertEquals(childListeners.get(path).size(), 1, "Should have 1 child-listener on path: " + path);
    path = keyBuilder.controller().getPath();
    Assert.assertNull(childListeners.get(path), "Should have no child-listener on path: " + path);
    // check zookeeper#watches on client side
    Map<String, List<String>> watchPaths = ZkTestHelper.getZkWatch(participantToExpire.getZkClient());
    // System.out.println("localhost_12918 zk-client side watchPaths: " + watchPaths + "\n");
    Assert.assertEquals(watchPaths.get("dataWatches").size(), 3, "Should have 3 data-watches: CURRENTSTATE/{sessionId}, CURRENTSTATE/{sessionId}/TestDB, MESSAGES");
    Assert.assertEquals(watchPaths.get("childWatches").size(), 2, "Should have 2 child-watches: MESSAGES, and CURRENTSTATE/{sessionId}");
    // expire localhost_12918
    System.out.println("Expire participant: " + participantToExpire.getInstanceName() + ", session: " + participantToExpire.getSessionId());
    ZkTestHelper.expireSession(participantToExpire.getZkClient());
    String newSessionId = participantToExpire.getSessionId();
    System.out.println(participantToExpire.getInstanceName() + " oldSessionId: " + oldSessionId + ", newSessionId: " + newSessionId);
    HelixClusterVerifier verifier = new BestPossibleExternalViewVerifier.Builder(clusterName).setZkAddr(ZK_ADDR).build();
    Assert.assertTrue(verifier.verify());
    // check manager#hanlders
    Assert.assertEquals(participantToExpire.getHandlers().size(), 1, "Should have 1 handlers: MESSAGES. CURRENTSTATE/{sessionId} handler should be removed by CallbackHandler#handleChildChange()");
    // check zkclient#listeners
    dataListeners = ZkTestHelper.getZkDataListener(participantToExpire.getZkClient());
    childListeners = ZkTestHelper.getZkChildListener(participantToExpire.getZkClient());
    // printZkListeners(participantToExpire.getZkClient());
    Assert.assertTrue(dataListeners.isEmpty(), "Should have no data-listeners");
    Assert.assertEquals(childListeners.size(), 2, "Should have 2 paths (CURRENTSTATE/{oldSessionId}, and MESSAGES). " + "CONTROLLER and MESSAGE has 1 child-listener each. CURRENTSTATE/{oldSessionId} doesn't have listener (ZkClient doesn't remove empty childListener set. probably a ZkClient bug. see ZkClient#unsubscribeChildChange())");
    path = keyBuilder.currentStates(participantToExpire.getInstanceName(), oldSessionId).getPath();
    Assert.assertEquals(childListeners.get(path).size(), 0, "Should have no child-listener on path: " + path);
    path = keyBuilder.messages(participantToExpire.getInstanceName()).getPath();
    Assert.assertEquals(childListeners.get(path).size(), 1, "Should have 1 child-listener on path: " + path);
    path = keyBuilder.controller().getPath();
    Assert.assertNull(childListeners.get(path), "Should have no child-listener on path: " + path);
    // check zookeeper#watches on client side
    watchPaths = ZkTestHelper.getZkWatch(participantToExpire.getZkClient());
    // System.out.println("localhost_12918 zk-client side watchPaths: " + watchPaths + "\n");
    Assert.assertEquals(watchPaths.get("dataWatches").size(), 1, "Should have 1 data-watches: MESSAGES");
    Assert.assertEquals(watchPaths.get("childWatches").size(), 1, "Should have 1 child-watches: MESSAGES");
    Assert.assertEquals(watchPaths.get("existWatches").size(), 2, "Should have 2 exist-watches: CURRENTSTATE/{oldSessionId} and CURRENTSTATE/{oldSessionId}/TestDB0");
    // another session expiry on localhost_12918 should clear the two exist-watches on
    // CURRENTSTATE/{oldSessionId}
    System.out.println("Expire participant: " + participantToExpire.getInstanceName() + ", session: " + participantToExpire.getSessionId());
    ZkTestHelper.expireSession(participantToExpire.getZkClient());
    Assert.assertTrue(verifier.verify());
    // check zookeeper#watches on client side
    watchPaths = ZkTestHelper.getZkWatch(participantToExpire.getZkClient());
    // System.out.println("localhost_12918 zk-client side watchPaths: " + watchPaths + "\n");
    Assert.assertEquals(watchPaths.get("dataWatches").size(), 1, "Should have 1 data-watches: MESSAGES");
    Assert.assertEquals(watchPaths.get("childWatches").size(), 1, "Should have 1 child-watches: MESSAGES");
    Assert.assertEquals(watchPaths.get("existWatches").size(), 0, "Should have no exist-watches. exist-watches on CURRENTSTATE/{oldSessionId} and CURRENTSTATE/{oldSessionId}/TestDB0 should be cleared during handleNewSession");
    // Thread.sleep(1000);
    // clean up
    controller.syncStop();
    for (int i = 0; i < n; i++) {
        participants[i].syncStop();
    }
    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
Also used : HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) Set(java.util.Set) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) ClusterStateVerifier(org.apache.helix.tools.ClusterStateVerifier) Date(java.util.Date) ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) CurrentState(org.apache.helix.model.CurrentState) List(java.util.List) Test(org.testng.annotations.Test)

Example 10 with HelixClusterVerifier

use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.

the class TestAlertingRebalancerFailure method testWithDomainId.

@Test(enabled = false)
public void testWithDomainId() throws InterruptedException {
    int replicas = 2;
    ConfigAccessor configAccessor = new ConfigAccessor(_gZkClient);
    // 1. disable all participants except one node, then set domain Id
    for (int i = NODE_NR - 1; i >= 0; i--) {
        if (i < replicas) {
            setDomainId(_participants[i].getInstanceName(), configAccessor);
        } else {
            setInstanceEnable(_participants[i].getInstanceName(), false, configAccessor);
        }
    }
    // enable topology aware
    ClusterConfig clusterConfig = configAccessor.getClusterConfig(CLUSTER_NAME);
    clusterConfig.setTopologyAwareEnabled(true);
    clusterConfig.setTopology("/Rack/Instance");
    clusterConfig.setFaultZoneType("Rack");
    configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);
    // Ensure error caused by node config changes has been removed.
    // Error may be recorded unexpectedly when a resource from other tests is not cleaned up.
    accessor.removeProperty(errorNodeKey);
    _setupTool.addResourceToCluster(CLUSTER_NAME, testDb, 5, BuiltInStateModelDefinitions.MasterSlave.name(), RebalanceMode.FULL_AUTO.name(), CrushRebalanceStrategy.class.getName());
    _setupTool.rebalanceStorageCluster(CLUSTER_NAME, testDb, replicas);
    HelixClusterVerifier verifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).setResources(new HashSet<>(Collections.singleton(testDb))).build();
    Assert.assertTrue(verifier.verify());
    // Verify there is no rebalance error logged
    Assert.assertNull(accessor.getProperty(errorNodeKey));
    checkRebalanceFailureGauge(false);
    // 2. enable the rest nodes with no domain Id
    for (int i = replicas; i < NODE_NR; i++) {
        setInstanceEnable(_participants[i].getInstanceName(), true, configAccessor);
    }
    // Verify there is rebalance error logged
    Assert.assertNotNull(pollForError(accessor, errorNodeKey));
    checkRebalanceFailureGauge(true);
    // 3. reset all nodes domain Id to be correct setting
    for (int i = replicas; i < NODE_NR; i++) {
        setDomainId(_participants[i].getInstanceName(), configAccessor);
    }
    _setupTool.rebalanceStorageCluster(CLUSTER_NAME, testDb, replicas);
    Thread.sleep(1000);
    // Verify that rebalance error state is removed
    checkRebalanceFailureGauge(false);
    // clean up
    _setupTool.getClusterManagementTool().dropResource(CLUSTER_NAME, testDb);
    clusterConfig.setTopologyAwareEnabled(false);
}
Also used : HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) BestPossibleExternalViewVerifier(org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier) CrushRebalanceStrategy(org.apache.helix.controller.rebalancer.strategy.CrushRebalanceStrategy) ConfigAccessor(org.apache.helix.ConfigAccessor) ClusterConfig(org.apache.helix.model.ClusterConfig) HashSet(java.util.HashSet) 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