-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Flaky-test] Fix metadata cache flaky tests #14373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Flaky-test] Fix metadata cache flaky tests #14373
Conversation
pulsar-metadata/src/test/java/org/apache/pulsar/metadata/MetadataCacheTest.java
Show resolved
Hide resolved
Jason918
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
pulsar-metadata/src/test/java/org/apache/pulsar/metadata/MetadataCacheTest.java
Show resolved
Hide resolved
|
@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 pulsar/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/MetadataCacheTest.java Lines 611 to 620 in 8264414
|
|
@Demogorgon314 I made a PR to address the issue, it's #14518 . Please review it. |
|
I closed #14518 since I came to the conclusion that this PR #14373 should be reverted instead. pulsar/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/MetadataCacheTest.java Lines 272 to 273 in 8264414
|
|
@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)