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


The following commit(s) were added to refs/heads/master by this push:
     new 026a3ba8c Fix unstable test TestZeroReplicaAvoidance
026a3ba8c is described below

commit 026a3ba8cf7187c99e95acbf32b1691870d7dcfd
Author: Junkai Xue <[email protected]>
AuthorDate: Tue Feb 24 21:28:07 2026 -0800

    Fix unstable test TestZeroReplicaAvoidance
    
      1. First waits for cluster to stabilize with verify(120000L) - kept the 
longer timeout for WagedRebalance
      2. Then polls _testSuccess using TestHelper.verify() with 
DEFAULT_REBALANCE_PROCESSING_WAIT_TIME (1500ms)
    
      This properly handles the race condition where:
      - verify() returns true when cluster reaches ideal state
      - But async listener callbacks may still be processing
      - The polling ensures _testSuccess remains true (no validation failures 
from callbacks)
    
      This is better than a hardcoded sleep because it will:
      - Pass immediately if _testSuccess is already true
      - Wait up to 1500ms if callbacks are still processing
      - Fail fast if validation fails
    
    [INFO] Tests run: 20, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 
56.383 s - in TestSuite
    [INFO]
    [INFO] Results:
    [INFO]
    [INFO] Tests run: 20, Failures: 0, Errors: 0, Skipped: 0
    [INFO]
    [INFO]
---
 .../helix/integration/rebalancer/TestZeroReplicaAvoidance.java   | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git 
a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestZeroReplicaAvoidance.java
 
b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestZeroReplicaAvoidance.java
index 6f0b8478a..f574b6673 100644
--- 
a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestZeroReplicaAvoidance.java
+++ 
b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestZeroReplicaAvoidance.java
@@ -178,8 +178,13 @@ public class TestZeroReplicaAvoidance extends ZkTestBase
     for (; i < NUM_NODE; i++) {
       _participants.get(i).syncStart();
     }
-    Assert.assertTrue(_clusterVerifier.verify(70000L));
-    Assert.assertTrue(_testSuccess);
+    // Wait for cluster to stabilize and then poll until _testSuccess remains 
true
+    Assert.assertTrue(_clusterVerifier.verify(120000L));
+    // Poll to ensure _testSuccess stays true after cluster stabilizes
+    // This accounts for async callbacks that may still be processing
+    Assert.assertTrue(TestHelper.verify(() -> {
+      return _testSuccess;
+    }, TestHelper.DEFAULT_REBALANCE_PROCESSING_WAIT_TIME));
 
     if (manager.isConnected()) {
       manager.disconnect();

Reply via email to