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 2026/05/17 02:20:14 UTC
(helix) branch master updated: Fix unstable test adding checking logic more clearly
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits 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 9f7c92bcb Fix unstable test adding checking logic more clearly
9f7c92bcb is described below
commit 9f7c92bcb2316411552db3dc71455cb5905486d7
Author: Junkai Xue <jx...@apache.org>
AuthorDate: Sat May 16 19:19:54 2026 -0700
Fix unstable test adding checking logic more clearly
---
.../controller/TestTopologyMigration.java | 56 ++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/helix-core/src/test/java/org/apache/helix/integration/controller/TestTopologyMigration.java b/helix-core/src/test/java/org/apache/helix/integration/controller/TestTopologyMigration.java
index 6c173d97a..bc54564de 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/controller/TestTopologyMigration.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/controller/TestTopologyMigration.java
@@ -243,6 +243,11 @@ public class TestTopologyMigration extends ZkTestBase {
System.out.println("Setting MM to false");
setAndVerifyMaintenanceMode(false);
+ // Wait for EV to stabilize after exiting maintenance mode
+ // During maintenance mode, EV updates are deferred. After exiting, the controller
+ // needs time to compute and propagate the new ideal state assignment.
+ waitForEVStabilization(originalEVs, 30000);
+
// Verify cluster did not have shuffling anywhere after
// the migration to the new topology
validateNoShufflingOccurred(originalEVs, null);
@@ -255,6 +260,9 @@ public class TestTopologyMigration extends ZkTestBase {
migrateDomainForInstanceTag(updatingDb);
setAndVerifyMaintenanceMode(false);
+ // Wait for EV to stabilize after exiting maintenance mode
+ waitForEVStabilization(preMigrationEVs, 30000);
+
// Verify cluster only had shuffling in the resource group that was updated
validateNoShufflingOccurred(preMigrationEVs, updatingDb);
}
@@ -356,6 +364,54 @@ public class TestTopologyMigration extends ZkTestBase {
}
}
+ /**
+ * Waits for ExternalView state assignments to stabilize after exiting maintenance mode.
+ * During maintenance mode, EV updates are deferred. After exiting, the controller needs
+ * time to compute and propagate the new ideal state assignment.
+ *
+ * @param originalEVs The reference ExternalViews to compare against
+ * @param maxWaitTimeMs Maximum time to wait in milliseconds
+ */
+ private void waitForEVStabilization(Map<String, ExternalView> originalEVs, int maxWaitTimeMs) {
+ int pollInterval = 500;
+ long startTime = System.currentTimeMillis();
+ boolean stable = false;
+
+ while (System.currentTimeMillis() - startTime < maxWaitTimeMs) {
+ Map<String, ExternalView> currentEVs = getEVs();
+ boolean allMatch = true;
+ for (String db : _allDBs) {
+ ExternalView current = currentEVs.get(db);
+ ExternalView original = originalEVs.get(db);
+ if (current == null || original == null) {
+ allMatch = false;
+ break;
+ }
+ for (String partition : original.getPartitionSet()) {
+ if (!current.getStateMap(partition).equals(original.getStateMap(partition))) {
+ allMatch = false;
+ break;
+ }
+ }
+ if (!allMatch) break;
+ }
+ if (allMatch) {
+ stable = true;
+ LOG.info("EV stabilized after {} ms", System.currentTimeMillis() - startTime);
+ break;
+ }
+ try {
+ Thread.sleep(pollInterval);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ break;
+ }
+ }
+ if (!stable) {
+ LOG.warn("EV did not stabilize within {} ms", maxWaitTimeMs);
+ }
+ }
+
private void migrateInstanceConfigTopology(List<InstanceConfig> instanceConfigs)
throws Exception {
LOG.info("Starting migrateInstanceConfigTopology for {} instances", instanceConfigs.size());