Skip to content

Commit

Permalink
[improve][test] Improve the ClusterMetadataSetupTest to reduce the ex…
Browse files Browse the repository at this point in the history
…ecution time (#17627)
  • Loading branch information
coderzc authored Sep 15, 2022
1 parent 4ef8dc5 commit 25cb1fb
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@
import org.apache.pulsar.metadata.api.MetadataStoreConfig;
import org.apache.pulsar.metadata.api.extended.MetadataStoreExtended;
import org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble;
import org.apache.pulsar.zookeeper.ZookeeperServerTest;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.server.NIOServerCnxnFactory;
import org.apache.zookeeper.server.ZooKeeperServer;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

Expand Down Expand Up @@ -405,17 +405,22 @@ public void testInitialNamespaceSetupZKDefaultsFallbackWithChroot() throws Excep

}

@BeforeMethod
@BeforeClass
void setup() throws Exception {
localZkS = new ZookeeperServerTest(0);
localZkS.start();
}

@AfterMethod(alwaysRun = true)
@AfterClass
void teardown() throws Exception {
localZkS.close();
}

@AfterMethod(alwaysRun = true)
void cleanup() {
localZkS.clear();
}

static class ZookeeperServerTest implements Closeable {
private final File zkTmpDir;
private ZooKeeperServer zks;
Expand Down Expand Up @@ -448,10 +453,8 @@ public void start() throws IOException {
log.info("ZooKeeper started at {}", hostPort);
}

public void stop() throws IOException {
zks.shutdown();
serverFactory.shutdown();
log.info("Stoppend ZK server at {}", hostPort);
private void clear() {
zks.getZKDatabase().clear();
}

@Override
Expand Down

0 comments on commit 25cb1fb

Please sign in to comment.