This is an automated email from the ASF dual-hosted git repository.

lhotari pushed a commit to branch branch-4.2
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-4.2 by this push:
     new 7de44804eed [fix][test] Fix flaky BrokerRegistryIntegrationTest port 
binding race (#25463)
7de44804eed is described below

commit 7de44804eed4f7aa38bfa3dea61518faaff44d96
Author: Matteo Merli <[email protected]>
AuthorDate: Mon Apr 6 19:47:23 2026 -0700

    [fix][test] Fix flaky BrokerRegistryIntegrationTest port binding race 
(#25463)
    
    (cherry picked from commit aaf2defe4bad3fc06a080718b53599bd2aeb4333)
---
 .../loadbalance/extensions/BrokerRegistryIntegrationTest.java    | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/BrokerRegistryIntegrationTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/BrokerRegistryIntegrationTest.java
index e975671fa12..588b1c7730e 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/BrokerRegistryIntegrationTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/BrokerRegistryIntegrationTest.java
@@ -23,7 +23,6 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.bookkeeper.util.PortManager;
 import org.apache.pulsar.broker.PulsarService;
 import org.apache.pulsar.broker.ServiceConfiguration;
 import org.apache.pulsar.broker.loadbalance.LoadManager;
@@ -41,14 +40,14 @@ import org.testng.annotations.Test;
 public class BrokerRegistryIntegrationTest {
 
     private static final String clusterName = "test";
-    private final int zkPort = PortManager.nextFreePort();
-    private final LocalBookkeeperEnsemble bk = new LocalBookkeeperEnsemble(2, 
zkPort, PortManager::nextFreePort);
+    private LocalBookkeeperEnsemble bk;
     private PulsarService pulsar;
     private BrokerRegistry brokerRegistry;
     private String brokerMetadataPath;
 
     @BeforeClass
     protected void setup() throws Exception {
+        bk = new LocalBookkeeperEnsemble(2, 0, () -> 0);
         bk.start();
         pulsar = new PulsarService(brokerConfig());
         pulsar.start();
@@ -68,7 +67,9 @@ public class BrokerRegistryIntegrationTest {
             pulsar.close();
         }
         final var elapsedMs = System.currentTimeMillis() - startMs;
-        bk.stop();
+        if (bk != null) {
+            bk.stop();
+        }
         if (elapsedMs > 5000) {
             throw new RuntimeException("Broker took " + elapsedMs + "ms to 
close");
         }

Reply via email to