This is an automated email from the ASF dual-hosted git repository.

jxue pushed a commit to branch helix-stickiness-rebalancer
in repository https://gitbox.apache.org/repos/asf/helix.git


The following commit(s) were added to refs/heads/helix-stickiness-rebalancer by 
this push:
     new af64cfc8d Add test to ensure no partition movement when nodes restart 
(#2896)
af64cfc8d is described below

commit af64cfc8d1cad17e9678e4ac0906ee8454d05897
Author: frankmu <muteng...@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);

Reply via email to