Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve][test] Improve the ClusterMetadataSetupTest to reduce the execution time #17627

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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