[Flaky-test] Fix metadata cache flaky tests - #14373
Conversation
|
@Demogorgon314 We should use Awaitility instead of expanding the use of "retryStrategically" which exists in some older test code. Was there a specific reason to not use Awaitility in this PR? |
|
@lhotari If we use Awaitility.await().untilAsserted(() -> {
assertEquals(objCache.getIfCached(key1), Optional.of(v));
});If |
I don't see a reason why Awaitility couldn't handle this. Sometimes it's necessary to add Did you try Awaitility.await().ignoreExceptions().untilAsserted(() -> {
assertEquals(objCache.getIfCached(key1), Optional.of(v));
});I'm also wondering the logic in |
|
@Demogorgon314 I made a PR to address the issue, it's #14518 . Please review it. |
|
@lhotari |
(cherry picked from commit 8264414)
(cherry picked from commit 8264414)
Motivation
The
MetadataCache#getIfCachedmethod will returnOptional.empty()if the required path is not cached yet or the cached future is not finished yet, this is normal behavior.pulsar/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/cache/impl/MetadataCacheImpl.java
Lines 130 to 137 in 773f919
We should add a retry mechanism when asserting getIfCached.
Modifications
Add a retry mechanism to assert getIfCached.
Documentation
Check the box below or label this PR directly (if you have committer privilege).
Need to update docs?
doc-required(If you need help on updating docs, create a doc issue)
no-need-doc(Please explain why)
doc(If this PR contains doc changes)