Skip to content

Commit

Permalink
[fix][test] Fix flaky test PersistentTopicTest.testGetReplicationClus…
Browse files Browse the repository at this point in the history
…ters (apache#19421)

(cherry picked from commit 91c7ef7)
  • Loading branch information
lhotari authored and nodece committed May 14, 2024
1 parent b466a66 commit 0efbb89
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public void testProducerOverwrite() throws Exception {

private void testMaxProducers() throws Exception {
PersistentTopic topic = new PersistentTopic(successTopicName, ledgerMock, brokerService);
topic.initialize();
topic.initialize().join();
String role = "appid1";
// 1. add producer1
Producer producer = new Producer(topic, serverCnx, 1 /* producer id */, "prod-name1", role,
Expand Down Expand Up @@ -2320,7 +2320,7 @@ private ByteBuf getMessageWithMetadata(byte[] data) {
@Test
public void testGetReplicationClusters() throws Exception {
PersistentTopic topic = new PersistentTopic(successTopicName, ledgerMock, brokerService);
topic.initialize();
topic.initialize().join();
assertEquals(topic.getHierarchyTopicPolicies().getReplicationClusters().get(), Collections.emptyList());

PulsarResources pulsarResources = spyWithClassAndConstructorArgs(PulsarResources.class, store, store);
Expand All @@ -2339,7 +2339,7 @@ public void testGetReplicationClusters() throws Exception {
doReturn(policiesFuture).when(nsr).getPoliciesAsync(any());

topic = new PersistentTopic(successTopicName, ledgerMock, brokerService);
topic.initialize();
topic.initialize().join();
assertEquals(topic.getHierarchyTopicPolicies().getReplicationClusters().get(), namespaceClusters);

TopicPoliciesService topicPoliciesService = mock(TopicPoliciesService.class);
Expand All @@ -2354,7 +2354,7 @@ public void testGetReplicationClusters() throws Exception {
when(topicPoliciesService.getTopicPoliciesIfExists(any())).thenReturn(topicPolicies);

topic = new PersistentTopic(successTopicName, ledgerMock, brokerService);
topic.initialize();
topic.initialize().join();
assertEquals(topic.getHierarchyTopicPolicies().getReplicationClusters().get(), namespaceClusters);
}
}

0 comments on commit 0efbb89

Please sign in to comment.