From b192d7e8eb8b593834308d0a108c21c05088302b Mon Sep 17 00:00:00 2001 From: Lari Hotari Date: Mon, 21 Oct 2024 16:10:58 +0300 Subject: [PATCH] [fix][test] Fix running ClusterMetadataSetupTest in IDE --- .../pulsar/broker/zookeeper/ClusterMetadataSetupTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/zookeeper/ClusterMetadataSetupTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/zookeeper/ClusterMetadataSetupTest.java index 0c402a83e4227..6a7d54dbf7cae 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/zookeeper/ClusterMetadataSetupTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/zookeeper/ClusterMetadataSetupTest.java @@ -506,11 +506,9 @@ static class ZookeeperServerTest implements Closeable { private ZooKeeperServer zks; private NIOServerCnxnFactory serverFactory; private final int zkPort; - private final String hostPort; public ZookeeperServerTest(int zkPort) throws IOException { this.zkPort = zkPort; - this.hostPort = "127.0.0.1:" + zkPort; this.zkTmpDir = File.createTempFile("zookeeper", "test"); log.info("**** Start GZK on {} ****", zkTmpDir); if (!zkTmpDir.delete() || !zkTmpDir.mkdir()) { @@ -520,15 +518,17 @@ public ZookeeperServerTest(int zkPort) throws IOException { public void start() throws IOException { try { + System.setProperty("zookeeper.4lw.commands.whitelist", "*"); zks = new ZooKeeperServer(zkTmpDir, zkTmpDir, ZooKeeperServer.DEFAULT_TICK_TIME); zks.setMaxSessionTimeout(20000); serverFactory = new NIOServerCnxnFactory(); - serverFactory.configure(new InetSocketAddress(zkPort), 1000); + serverFactory.configure(new InetSocketAddress("127.0.0.1", zkPort), 1000); serverFactory.startup(zks); } catch (Exception e) { log.error("Exception while instantiating ZooKeeper", e); } + String hostPort = "127.0.0.1:" + serverFactory.getLocalPort(); LocalBookkeeperEnsemble.waitForServerUp(hostPort, 30000); log.info("ZooKeeper started at {}", hostPort); }