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 b19510e35 Refactor TestHelixTaskExecutor to stablize the test
b19510e35 is described below
commit b19510e35e4fff14e33d48a4ea4464c678180093
Author: Junkai Xue <[email protected]>
AuthorDate: Thu Apr 9 17:07:49 2026 -0700
Refactor TestHelixTaskExecutor to stablize the test
---
.../messaging/handling/TestHelixTaskExecutor.java | 31 ++++++++++++++++++----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git
a/helix-core/src/test/java/org/apache/helix/messaging/handling/TestHelixTaskExecutor.java
b/helix-core/src/test/java/org/apache/helix/messaging/handling/TestHelixTaskExecutor.java
index 48e986225..3efcb6390 100644
---
a/helix-core/src/test/java/org/apache/helix/messaging/handling/TestHelixTaskExecutor.java
+++
b/helix-core/src/test/java/org/apache/helix/messaging/handling/TestHelixTaskExecutor.java
@@ -884,11 +884,32 @@ public class TestHelixTaskExecutor {
executor.onMessage("someInstance", msgList, changeContext);
LOG.info("Submitted {} messages to executor", nMsgs2);
- // Wait for processing to complete
- // Increased wait time to ensure flaky test stability on slower CI machines
- int waitTime = 8000;
- LOG.info("Waiting {} ms for processing to complete...", waitTime);
- Thread.sleep(waitTime);
+ // Wait for processing to stabilize with exactly 2 messages timed out
+ // Poll until we see exactly 2 timed out and the count has been stable for
2 consecutive polls
+ int maxWaitTime = 15000;
+ int pollInterval = 300;
+ int expectedTimeoutCount = 2;
+ int stableCount = 0;
+ int lastTimeoutCount = -1;
+
+ LOG.info("Waiting up to {} ms for exactly {} messages to timeout...",
maxWaitTime, expectedTimeoutCount);
+ long startTime = System.currentTimeMillis();
+
+ while (System.currentTimeMillis() - startTime < maxWaitTime) {
+ int currentTimeoutCount = factory._timedOutMsgIds.size();
+ if (currentTimeoutCount == expectedTimeoutCount && currentTimeoutCount
== lastTimeoutCount) {
+ stableCount++;
+ if (stableCount >= 2) {
+ LOG.info("Timed out count stabilized at {} after {} ms",
+ currentTimeoutCount, System.currentTimeMillis() - startTime);
+ break;
+ }
+ } else {
+ stableCount = 0;
+ }
+ lastTimeoutCount = currentTimeoutCount;
+ Thread.sleep(pollInterval);
+ }
LOG.info("After wait - Handlers created: {}, Processed: {}, TimedOut: {}",
factory._handlersCreated, factory._processedMsgIds.size(),
factory._timedOutMsgIds.size());