From 46c9ce9b068a0e0191a9598e6c863bda3f428bc2 Mon Sep 17 00:00:00 2001 From: Lari Hotari Date: Wed, 13 Mar 2024 07:48:35 -0700 Subject: [PATCH] [improve][test] Reduce AdvertisedListenersMultiBrokerLeaderElectionTest flakiness (#22258) --- .../broker/loadbalance/MultiBrokerLeaderElectionTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/MultiBrokerLeaderElectionTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/MultiBrokerLeaderElectionTest.java index f2712820d6968..32f3acf42142e 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/MultiBrokerLeaderElectionTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/MultiBrokerLeaderElectionTest.java @@ -108,11 +108,12 @@ public void shouldProvideConsistentAnswerToTopicLookupsUsingAdminApi() List topicNames = IntStream.range(0, 500).mapToObj(i -> topicNameBase + i) .collect(Collectors.toList()); List allAdmins = getAllAdmins(); - @Cleanup("shutdown") + @Cleanup("shutdownNow") ExecutorService executorService = Executors.newFixedThreadPool(allAdmins.size()); List>> resultFutures = new ArrayList<>(); // use Phaser to increase the chances of a race condition by triggering all threads once // they are waiting just before each lookupTopic call + @Cleanup("forceTermination") final Phaser phaser = new Phaser(1); for (PulsarAdmin brokerAdmin : allAdmins) { phaser.register(); @@ -149,11 +150,12 @@ public void shouldProvideConsistentAnswerToTopicLookupsUsingClient() List topicNames = IntStream.range(0, 500).mapToObj(i -> topicNameBase + i) .collect(Collectors.toList()); List allClients = getAllClients(); - @Cleanup("shutdown") + @Cleanup("shutdownNow") ExecutorService executorService = Executors.newFixedThreadPool(allClients.size()); List>> resultFutures = new ArrayList<>(); // use Phaser to increase the chances of a race condition by triggering all threads once // they are waiting just before each lookupTopic call + @Cleanup("forceTermination") final Phaser phaser = new Phaser(1); for (PulsarClient brokerClient : allClients) { phaser.register();