You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2022/09/15 00:29:00 UTC

[pulsar] branch master updated: [improve][test] Improve the ClusterMetadataSetupTest to reduce the execution time (#17627)

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

penghui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 25cb1fb75be [improve][test] Improve the ClusterMetadataSetupTest to reduce the execution time (#17627)
25cb1fb75be is described below

commit 25cb1fb75bef7d11242c9c4400b95975b606207a
Author: Cong Zhao <zh...@apache.org>
AuthorDate: Thu Sep 15 08:28:43 2022 +0800

    [improve][test] Improve the ClusterMetadataSetupTest to reduce the execution time (#17627)
---
 .../broker/zookeeper/ClusterMetadataSetupTest.java    | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 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 4f7c2f27545..84a42aace85 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
@@ -48,14 +48,14 @@ import org.apache.pulsar.functions.worker.WorkerUtils;
 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;
 
@@ -405,17 +405,22 @@ public class ClusterMetadataSetupTest {
 
     }
 
-    @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;
@@ -448,10 +453,8 @@ public class ClusterMetadataSetupTest {
             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