Skip to content
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

[fix][test] Fix flaky test BrokerRegistryTest.testRegisterAndLookup #19402

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,10 @@ void cleanUp() {
brokerRegistries.clear();
log.info("Cleaning up the pulsar services...");
pulsarServices.forEach(pulsarService -> {
if (pulsarService.isRunning()) {
pulsarService.shutdownNow();
try {
pulsarService.close();
} catch (PulsarServerException e) {
throw new RuntimeException(e);
}
});
pulsarServices.clear();
Expand Down Expand Up @@ -274,8 +276,12 @@ public void testRegisterAndLookup() throws Exception {

// Unregister and see the available brokers.
brokerRegistry1.unregister();
assertEquals(brokerRegistry2.getAvailableBrokersAsync().get().size(), 2);

// After unregistering, the other broker registry lock manager's metadata cache might not be updated yet,
// so we need to wait for it to synchronize.
Awaitility.await().untilAsserted(() -> {
assertEquals(brokerRegistry2.getAvailableBrokersAsync().get().size(), 2);
});
}

@Test
Expand Down