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 fea027237 Add more logs to TestInstanceOperation
fea027237 is described below

commit fea027237d50db0c0d0283bace2009f6a2a02cf4
Author: Junkai Xue <[email protected]>
AuthorDate: Fri Mar 6 20:40:38 2026 -0800

    Add more logs to TestInstanceOperation
    
      1. Increased timeout: Changed from 30000ms to 60000ms for the verifier 
(line 1556)
      2. Added cluster name parameter: Now passes CLUSTER_NAME to the verifier 
for controller availability diagnostics (line 1556)
      3. Added detailed logging to help debug failures:
        - Line 1522: Logs when evacuation verification starts with instance 
name and replica count
        - Lines 1527-1529: Logs if ExternalView is null for a resource
        - Lines 1540-1543: Logs when active replica count is below threshold, 
showing the stateMap
        - Lines 1545-1551: Logs when evacuating instance is still in 
MASTER/LEADER state
        - Line 1557: Logs when verification completes successfully
    
      These logs will help diagnose exactly what's happening when the verifier 
returns false:
      - Whether there aren't enough active replicas
      - Whether the evacuating instance is still holding MASTER/LEADER state
      - The full stateMap for any problematic partition
---
 .../rebalancer/TestInstanceOperation.java          | 27 ++++++++++++++++++----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git 
a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestInstanceOperation.java
 
b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestInstanceOperation.java
index 5f49112a6..0182f4eec 100644
--- 
a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestInstanceOperation.java
+++ 
b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestInstanceOperation.java
@@ -1518,26 +1518,43 @@ public class TestInstanceOperation extends ZkTestBase {
         InstanceConstants.InstanceOperation.EVACUATE);
 
     // EV should contain all participants, check resources one by one
+    // Increased timeout to 60000ms for flaky test stability
+    LOG.info("Starting evacuation verification for instance {} with {} 
replicas required", evacuateInstanceName, REPLICA);
     verifier(() -> {
       Map<String, ExternalView> assignment = getEVs();
       for (String resource : _allDBs) {
         ExternalView ev = assignment.get(resource);
+        if (ev == null) {
+          LOG.info("ExternalView for resource {} is null, skipping", resource);
+          continue;
+        }
         for (String partition : ev.getPartitionSet()) {
+          Map<String, String> stateMap = ev.getStateMap(partition);
           AtomicInteger activeReplicaCount = new AtomicInteger();
-          ev.getStateMap(partition).values().stream().filter(
+          stateMap.values().stream().filter(
                   v -> v.equals("MASTER") || v.equals("LEADER") || 
v.equals("SLAVE") || v.equals(
                       "FOLLOWER") || v.equals("STANDBY"))
               .forEach(v -> activeReplicaCount.getAndIncrement());
+
           // If min active replicas violated OR if instance is evacuating and 
is top state for partition
-          if (activeReplicaCount.get() < REPLICA - 1 || 
(ev.getStateMap(partition).containsKey(evacuateInstanceName) &&
-              
(ev.getStateMap(partition).get(evacuateInstanceName).equals("MASTER") ||
-                  
ev.getStateMap(partition).get(evacuateInstanceName).equals("LEADER")))) {
+          if (activeReplicaCount.get() < REPLICA - 1) {
+            LOG.info("Partition {} in resource {} has only {} active replicas 
(required {}), stateMap: {}",
+                partition, resource, activeReplicaCount.get(), REPLICA - 1, 
stateMap);
             return false;
           }
+          if (stateMap.containsKey(evacuateInstanceName)) {
+            String evacuateState = stateMap.get(evacuateInstanceName);
+            if (evacuateState.equals("MASTER") || 
evacuateState.equals("LEADER")) {
+              LOG.info("Evacuating instance {} is still in top state {} for 
partition {} in resource {}, stateMap: {}",
+                  evacuateInstanceName, evacuateState, partition, resource, 
stateMap);
+              return false;
+            }
+          }
         }
       }
       return true;
-    }, 30000);
+    }, 60000, CLUSTER_NAME);
+    LOG.info("Evacuation verification completed successfully for instance {}", 
evacuateInstanceName);
 
     removeOfflineOrInactiveInstances();
     addParticipant(PARTICIPANT_PREFIX + "_" + _nextStartPort);

Reply via email to