Skip to content

Conversation

@lhotari
Copy link
Member

@lhotari lhotari commented Mar 1, 2022

Motivation

  • see comments in #14373

  • the retryStrategically method will always pass on the last retry unless
    previous retries fail with an exception. This is very confusing.

  • Awaitility should be used instead of retryStrategically

Modifications

  • remove the retryStrategically solution from MetadataCacheTest

- the retryStrategically method will always pass on the last retry unless
  previous retries fail with an exception. This is very confusing.
- Awaitility should be used instead of retryStrategically
@lhotari lhotari added type/flaky-tests doc-not-needed Your PR changes do not impact docs labels Mar 1, 2022
@lhotari lhotari self-assigned this Mar 1, 2022
@lhotari
Copy link
Member Author

lhotari commented Mar 1, 2022

Actually this change doesn't make sense after all. I think that the correct solution would be to revert #14373.

@lhotari lhotari closed this Mar 1, 2022
@lhotari
Copy link
Member Author

lhotari commented Mar 1, 2022

I don't see why this type of code would make sense:

         assertEquals(objCache.get(key1).join(), Optional.of(value2));
        Awaitility.await().untilAsserted(() -> assertEquals(objCache.getIfCached(key1), Optional.of(value2)));

This is already the case in #14373. Therefore it should be reverted.

assertEquals(objCache.readModifyUpdateOrCreate(key1, __ -> value2).join(), value2);
assertEquals(objCache.get(key1).join(), Optional.of(value2));
assertEqualsAndRetry(() -> objCache.getIfCached(key1), Optional.of(value2), Optional.empty());
Awaitility.await().untilAsserted(() -> assertEquals(objCache.getIfCached(key1), Optional.of(value2)));
Copy link
Member

@Demogorgon314 Demogorgon314 Mar 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lhotari
Need ensure objCache.getIfCached(key1) don't return a wrong value.

If we use Awaitility.await().untilAsserted(() -> assertEquals(objCache.getIfCached(key1), Optional.of(value2)));, here has an example case test can't cover.

  1. objCache.getIfCached(key1) => Optional.of(value1) (We should fail here, but it will continue to run)
  2. objCache.getIfCached(key1) => Optional.of(value2)

The getIfCached method should always return Optional.empty() or correct value, we don't want to read dirty values from the cache, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs type/flaky-tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants