Demogorgon314 commented on a change in pull request #14518:
URL: https://github.com/apache/pulsar/pull/14518#discussion_r816845187



##########
File path: 
pulsar-metadata/src/test/java/org/apache/pulsar/metadata/MetadataCacheTest.java
##########
@@ -265,12 +263,11 @@ public void insertionDeletion(String provider, 
Supplier<String> urlSupplier) thr
             assertEquals(e.getCause().getClass(), 
AlreadyExistsException.class);
         }
 
-        assertEqualsAndRetry(() -> objCache.getIfCached(key1), 
Optional.of(value1), Optional.empty());
         assertEquals(objCache.get(key1).join(), Optional.of(value1));
 
         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)));

Review comment:
       @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?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to