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 769eca9ca Fix flaky test TestZkCacheAsyncOpSingleThread
769eca9ca is described below
commit 769eca9cab06154c3dd5f622f0e99367ea4733fc
Author: Junkai Xue <[email protected]>
AuthorDate: Wed Feb 25 22:12:29 2026 -0800
Fix flaky test TestZkCacheAsyncOpSingleThread
Changes made to testHappyPathExtOpZkCacheBaseDataAccessor:
- Line 154-156: Changed immediate verifyZkCache to polling with 10s
timeout
- Lines 203-209: Changed Thread.sleep(100) + immediate verify to polling
with 10s timeout
- Lines 223-229: Changed Thread.sleep(100) + immediate verify to polling
with 10s timeout
- Lines 240-246: Changed Thread.sleep(100) + immediate verify to polling
with 10s timeout
---
.../manager/zk/TestZkCacheAsyncOpSingleThread.java | 31 ++++++++--------------
1 file changed, 11 insertions(+), 20 deletions(-)
diff --git
a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheAsyncOpSingleThread.java
b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheAsyncOpSingleThread.java
index 36ac89e47..ed02da334 100644
---
a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheAsyncOpSingleThread.java
+++
b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheAsyncOpSingleThread.java
@@ -151,8 +151,8 @@ public class TestZkCacheAsyncOpSingleThread extends
ZkUnitTestBase {
new ZkCacheBaseDataAccessor<>(baseAccessor, null, null,
zkCacheInitPaths);
// TestHelper.printCache(accessor._zkCache);
- boolean ret =
- TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache,
_gZkClient, true);
+ boolean ret = TestHelper.verify(() ->
+ TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache,
_gZkClient, true), 10000);
Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
// create 10 current states using external base accessor
@@ -200,12 +200,9 @@ public class TestZkCacheAsyncOpSingleThread extends
ZkUnitTestBase {
}
}
- // wait zkEventThread update zkCache
- Thread.sleep(100);
-
- // verify cache
- // TestHelper.printCache(accessor._zkCache);
- ret = TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache,
_gZkClient, true);
+ // wait zkEventThread update zkCache using polling
+ ret = TestHelper.verify(() ->
+ TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache,
_gZkClient, true), 10000);
Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
// set 10 external views by external accessor
@@ -223,12 +220,9 @@ public class TestZkCacheAsyncOpSingleThread extends
ZkUnitTestBase {
Assert.assertTrue(success[i], "Should succeed in set: " + paths.get(i));
}
- // wait zkEventThread update zkCache
- Thread.sleep(100);
-
- // verify cache
- // TestHelper.printCache(accessor._zkCache._cache);
- ret = TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache,
_gZkClient, true);
+ // wait zkEventThread update zkCache using polling
+ ret = TestHelper.verify(() ->
+ TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache,
_gZkClient, true), 10000);
Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
// remove 10 external views by external accessor
@@ -243,12 +237,9 @@ public class TestZkCacheAsyncOpSingleThread extends
ZkUnitTestBase {
Assert.assertTrue(success[i], "Should succeed in remove: " +
paths.get(i));
}
- // wait zkEventThread update zkCache
- Thread.sleep(100);
-
- // verify cache
- // TestHelper.printCache(accessor._zkCache._cache);
- ret = TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache,
_gZkClient, true);
+ // wait zkEventThread update zkCache using polling
+ ret = TestHelper.verify(() ->
+ TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache,
_gZkClient, true), 10000);
Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
// clean up