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
commit 1305f6d5f525dd9b4ca6985fef02af18b8cff10b Author: Junkai Xue <[email protected]> AuthorDate: Fri Apr 10 21:12:33 2026 -0700 Wait for handler count stabilization in TestConsecutiveZkSessionExpiry The test was checking handler count immediately after losing leadership, but handler cleanup is async. Added a 20-second wait loop to allow handler count to stabilize before asserting. Co-Authored-By: Claude Opus 4.6 <[email protected]> --- .../manager/TestConsecutiveZkSessionExpiry.java | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/helix-core/src/test/java/org/apache/helix/integration/manager/TestConsecutiveZkSessionExpiry.java b/helix-core/src/test/java/org/apache/helix/integration/manager/TestConsecutiveZkSessionExpiry.java index fd7d5caef..3d36353fd 100644 --- a/helix-core/src/test/java/org/apache/helix/integration/manager/TestConsecutiveZkSessionExpiry.java +++ b/helix-core/src/test/java/org/apache/helix/integration/manager/TestConsecutiveZkSessionExpiry.java @@ -238,15 +238,26 @@ public class TestConsecutiveZkSessionExpiry extends ZkUnitTestBase { Assert.assertNotNull(leader); Assert.assertEquals(leader.getId(), "localhost_12919"); - // check localhost_12918 has 2 handlers: message and data-accessor + // Wait for handler count to stabilize after losing leadership + // This is needed because handler cleanup is async and may take time in CI + List<CallbackHandler> handlers = null; + int expectedHandlerCount = 1; + int maxWaitTime = 20000; + int pollInterval = 200; + long startTime = System.currentTimeMillis(); + while (System.currentTimeMillis() - startTime < maxWaitTime) { + handlers = distributedControllers[0].getHandlers(); + if (handlers.size() == expectedHandlerCount) { + LOG.info("Handler count stabilized at {} after {} ms", + handlers.size(), System.currentTimeMillis() - startTime); + break; + } + Thread.sleep(pollInterval); + } LOG.debug("handlers: " + TestHelper.printHandlers(distributedControllers[0])); - List<CallbackHandler> handlers = distributedControllers[0].getHandlers(); - Assert - .assertEquals( - handlers.size(), - 1, - "Distributed controller should have 1 handler (message) after lose leadership, but was " - + handlers.size()); + Assert.assertEquals(handlers.size(), expectedHandlerCount, + "Distributed controller should have 1 handler (message) after lose leadership, but was " + + handlers.size()); // clean up distributedControllers[0].disconnect();
