BewareMyPower commented on code in PR #25246:
URL: https://github.com/apache/pulsar/pull/25246#discussion_r2811977750
##########
pulsar-metadata/src/test/java/org/apache/pulsar/metadata/MetadataCacheTest.java:
##########
@@ -739,4 +741,18 @@ public void testNoBackoffMetadataCacheConfig() {
assertTrue(backoff.isMandatoryStopMade());
assertEquals(backoff.getFirstBackoffTimeInMillis(), 0);
}
+
+ @Test
+ public void testRefreshRace() throws Exception {
+ @Cleanup final var store = new
LocalMemoryMetadataStore("memory:local", MetadataStoreConfig.builder().build());
+ final var cache = store.getMetadataCache(String.class);
+ for (int i = 0; i < 500; i++) {
+ final var key = "/key" + i;
+ assertTrue(cache.get(key).get().isEmpty());
+
+ store.put(key, "\"value\"".getBytes(StandardCharsets.UTF_8),
Optional.empty()).get();
+
Awaitility.await().pollInterval(Duration.ofMillis(1)).atMost(Duration.ofSeconds(3)).untilAsserted(()
->
Review Comment:
I intentionally called `store.put` rather than `cache.put`. This test is
added mainly to verify the notification listener from
`AbstractMetadataStore#accept` works, so it should not rely on the semantics of
the MetadataCache `put` API, which refreshes the cache before the future is
done.
--
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]