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 c33d833a3 Fix the race condition for test TestClusterMaintenanceMode
c33d833a3 is described below

commit c33d833a31fe82fafeb42d48ee83e4387964cdf2
Author: Junkai Xue <[email protected]>
AuthorDate: Mon Apr 6 15:12:48 2026 -0700

    Fix the race condition for test TestClusterMaintenanceMode
    
    The test at 
helix-core/src/test/java/org/apache/helix/integration/controller/TestClusterMaintenanceMode.java:388
 has a race condition on lines 390-392
---
 .../controller/TestClusterMaintenanceMode.java         | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git 
a/helix-core/src/test/java/org/apache/helix/integration/controller/TestClusterMaintenanceMode.java
 
b/helix-core/src/test/java/org/apache/helix/integration/controller/TestClusterMaintenanceMode.java
index 6654098f8..492d46453 100644
--- 
a/helix-core/src/test/java/org/apache/helix/integration/controller/TestClusterMaintenanceMode.java
+++ 
b/helix-core/src/test/java/org/apache/helix/integration/controller/TestClusterMaintenanceMode.java
@@ -387,6 +387,12 @@ public class TestClusterMaintenanceMode extends 
TaskTestBase {
   @Test(dependsOnMethods = "testMaxPartitionLimit")
   public void testMaintenanceHistory() throws Exception {
     // In maintenance mode, by controller, for 
MAX_PARTITION_PER_INSTANCE_EXCEEDED
+    // Wait for the maintenance history entry to be written
+    TestHelper.verify(() -> {
+      ControllerHistory hist = 
_dataAccessor.getProperty(_keyBuilder.controllerLeaderHistory());
+      return hist != null && !hist.getMaintenanceHistoryList().isEmpty();
+    }, 2000L);
+
     ControllerHistory history = 
_dataAccessor.getProperty(_keyBuilder.controllerLeaderHistory());
     Map<String, String> lastHistoryEntry = convertStringToMap(
         
history.getMaintenanceHistoryList().get(history.getMaintenanceHistoryList().size()
 - 1));
@@ -405,7 +411,13 @@ public class TestClusterMaintenanceMode extends 
TaskTestBase {
     TestHelper.verify(() -> 
_dataAccessor.getProperty(_keyBuilder.maintenance()) == null, 2000L);
 
     // Now check that the cluster exited maintenance
+    // Wait for the EXIT history entry to be written
     // EXIT, CONTROLLER, for MAX_PARTITION_PER_INSTANCE_EXCEEDED
+    TestHelper.verify(() -> {
+      ControllerHistory hist = 
_dataAccessor.getProperty(_keyBuilder.controllerLeaderHistory());
+      return hist != null && !hist.getMaintenanceHistoryList().isEmpty();
+    }, 2000L);
+
     history = _dataAccessor.getProperty(_keyBuilder.controllerLeaderHistory());
     lastHistoryEntry = convertStringToMap(
         
history.getMaintenanceHistoryList().get(history.getMaintenanceHistoryList().size()
 - 1));
@@ -420,7 +432,13 @@ public class TestClusterMaintenanceMode extends 
TaskTestBase {
         .manuallyEnableMaintenanceMode(CLUSTER_NAME, true, 
TestHelper.getTestMethodName(), customFieldMap);
     TestHelper.verify(() -> 
_dataAccessor.getProperty(_keyBuilder.maintenance()) != null, 2000L);
 
+    // Wait for the USER triggered ENTER history entry to be written
     // ENTER, USER, for reason TEST, no internalReason
+    TestHelper.verify(() -> {
+      ControllerHistory hist = 
_dataAccessor.getProperty(_keyBuilder.controllerLeaderHistory());
+      return hist != null && !hist.getMaintenanceHistoryList().isEmpty();
+    }, 2000L);
+
     history = _dataAccessor.getProperty(_keyBuilder.controllerLeaderHistory());
     lastHistoryEntry =
         
convertStringToMap(history.getMaintenanceHistoryList().get(history.getMaintenanceHistoryList().size()
 - 1));

Reply via email to