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
commit 14c4c6327461183b9036e074ad04bdbda06c373c Author: Lari Hotari <[email protected]> AuthorDate: Wed Jul 1 03:51:27 2026 +0300 [fix][test] Fix flaky AuditorBookieTest.testBookieClusterRestart (#26122) (cherry picked from commit 116212f5424d05da7affb078308d003d5e180423) --- .../apache/bookkeeper/replication/AuditorBookieTest.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/AuditorBookieTest.java b/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/AuditorBookieTest.java index 14cdf3e1fc2..db54196321b 100644 --- a/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/AuditorBookieTest.java +++ b/pulsar-metadata/src/test/java/org/apache/bookkeeper/replication/AuditorBookieTest.java @@ -138,13 +138,12 @@ public class AuditorBookieTest extends BookKeeperClusterTestCase { assertTrue("Auditor elector is not running!", auditorElector .isRunning()); } - stopBKCluster(); stopAuditorElectors(); - - startBKCluster(zkUtil.getMetadataServiceUri()); - //startBKCluster(zkUtil.getMetadataServiceUri()) override the base conf metadataServiceUri - baseConf.setMetadataServiceUri( - zkUtil.getMetadataServiceUri().replaceAll("zk://", "metadata-store:").replaceAll("/ledgers", "")); + // Restart the bookies while preserving their identities (host:port and data dirs). + // Tearing the cluster down and recreating bookies with fresh data dirs on recycled + // ports fails bookie cookie validation against the cookies that are still registered + // in the metadata store, which made this test flaky. + restartBookies(); startAuditorElectors(); BookieServer newAuditor = waitForNewAuditor(auditor); assertNotSame( @@ -230,6 +229,10 @@ public class AuditorBookieTest extends BookKeeperClusterTestCase { LOG.debug("Stopping Auditor Elector!"); } } + // The same test instance is reused across test methods, so drop references to the + // shut-down electors. Otherwise a later method that iterates over auditorElectors + // (e.g. testBookieClusterRestart) would observe stale, already-stopped electors. + auditorElectors.clear(); } private BookieServer verifyAuditor() throws Exception {
