You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by jx...@apache.org on 2025/12/09 20:49:41 UTC
(helix) 23/37: Add test to ensure no partition movement when nodes restart (#2896)
This is an automated email from the ASF dual-hosted git repository.
jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
commit 5d67824818ff55aa904d07149f38db3fbd1cdf12
Author: frankmu <mu...@gmail.com>
AuthorDate: Fri Aug 30 13:48:15 2024 -0700
Add test to ensure no partition movement when nodes restart (#2896)
Add test to ensure no partition movement when nodes restart
---
.../rebalancer/TestStickyRebalanceStrategy.java | 45 ++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestStickyRebalanceStrategy.java b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestStickyRebalanceStrategy.java
index 4e4717f39..97a27017e 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestStickyRebalanceStrategy.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestStickyRebalanceStrategy.java
@@ -218,6 +218,51 @@ public class TestStickyRebalanceStrategy extends ZkTestBase {
validateNoPartitionMoveWithDiffCount(idealStates, externalViewsBefore, externalViewsAfter, 2);
}
+ @Test
+ public void testNoPartitionMovementWithInstanceRestart() throws Exception {
+ setGlobalMaxPartitionAllowedPerInstanceInCluster(_gZkClient, CLUSTER_NAME, 1);
+ // Create resource
+ Map<String, ExternalView> externalViewsBefore = createTestDBs();
+ // Shut down half of the nodes
+ for (int i = 0; i < _participants.size(); i++) {
+ if (i % 2 == 0) {
+ _participants.get(i).syncStop();
+ }
+ }
+ Assert.assertTrue(_clusterVerifier.verifyByPolling());
+
+ Map<String, ExternalView> externalViewsAfter = new HashMap<>();
+ Map<String, IdealState> idealStates = new HashMap<>();
+ for (String db : _testDBs) {
+ ExternalView ev =
+ _gSetupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, db);
+ IdealState is =
+ _gSetupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, db);
+ externalViewsAfter.put(db, ev);
+ idealStates.put(db, is);
+ }
+ validateNoPartitionMoveWithDiffCount(idealStates, externalViewsBefore, externalViewsAfter,
+ NUM_NODE / 2);
+
+ // Start all the nodes
+ for (int i = 0; i < _participants.size(); i++) {
+ if (!_participants.get(i).isConnected()) {
+ _participants.set(i, new MockParticipantManager(ZK_ADDR, CLUSTER_NAME,
+ _participants.get(i).getInstanceName()));
+ _participants.get(i).syncStart();
+ }
+ }
+ Assert.assertTrue(_clusterVerifier.verifyByPolling());
+
+ for (String db : _testDBs) {
+ ExternalView ev =
+ _gSetupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, db);
+ IdealState is =
+ _gSetupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, db);
+ validateNoPartitionMove(is, externalViewsBefore.get(db), ev);
+ }
+ }
+
@Test
public void testFirstTimeAssignmentWithStackingPlacement() throws Exception {
setGlobalMaxPartitionAllowedPerInstanceInCluster(_gZkClient, CLUSTER_NAME, 2);