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

mmerli 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 c9715812a0e [improve][test] Speed up HealthCheckTest by sharing 
cluster across test methods (#25448)
c9715812a0e is described below

commit c9715812a0eab12576508456fad07c936ac8c248
Author: Matteo Merli <[email protected]>
AuthorDate: Tue Mar 31 13:29:10 2026 -0700

    [improve][test] Speed up HealthCheckTest by sharing cluster across test 
methods (#25448)
---
 .../tests/integration/cli/HealthCheckTest.java     | 46 +++++++++-------------
 1 file changed, 18 insertions(+), 28 deletions(-)

diff --git 
a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/cli/HealthCheckTest.java
 
b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/cli/HealthCheckTest.java
index 4cacad3f76a..4582f8d2c9e 100644
--- 
a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/cli/HealthCheckTest.java
+++ 
b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/cli/HealthCheckTest.java
@@ -18,10 +18,6 @@
  */
 package org.apache.pulsar.tests.integration.cli;
 
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.util.HashMap;
-import java.util.Map;
 import java.util.UUID;
 import org.apache.pulsar.tests.TestRetrySupport;
 import org.apache.pulsar.tests.integration.containers.BKContainer;
@@ -30,11 +26,9 @@ import 
org.apache.pulsar.tests.integration.docker.ContainerExecException;
 import org.apache.pulsar.tests.integration.docker.ContainerExecResult;
 import org.apache.pulsar.tests.integration.topologies.PulsarCluster;
 import org.apache.pulsar.tests.integration.topologies.PulsarClusterSpec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 /**
@@ -42,8 +36,6 @@ import org.testng.annotations.Test;
  */
 public class HealthCheckTest extends TestRetrySupport {
 
-    private static final Logger log = 
LoggerFactory.getLogger(HealthCheckTest.class);
-
     private final PulsarClusterSpec spec = PulsarClusterSpec.builder()
         .clusterName("HealthCheckTest-" + 
UUID.randomUUID().toString().substring(0, 8))
         .numProxies(0)
@@ -52,14 +44,16 @@ public class HealthCheckTest extends TestRetrySupport {
 
     private PulsarCluster pulsarCluster = null;
 
-    @BeforeMethod(alwaysRun = true)
+    @Override
+    @BeforeClass(alwaysRun = true)
     public final void setup() throws Exception {
         incrementSetupNumber();
         pulsarCluster = PulsarCluster.forSpec(spec);
         pulsarCluster.start();
     }
 
-    @AfterMethod(alwaysRun = true)
+    @Override
+    @AfterClass(alwaysRun = true)
     public final void cleanup() {
         markCurrentSetupNumberCleaned();
         if (pulsarCluster != null) {
@@ -91,28 +85,24 @@ public class HealthCheckTest extends TestRetrySupport {
     @Test
     public void testZooKeeperDown() throws Exception {
         pulsarCluster.getZooKeeper().execCmd("pkill", "-STOP", "java");
-        assertHealthcheckFailure();
+        try {
+            assertHealthcheckFailure();
+        } finally {
+            pulsarCluster.getZooKeeper().execCmd("pkill", "-CONT", "java");
+        }
     }
 
-    // Disabled until PulsarAdmin can time out (#2891)
-    // @Test
-    // public void testBrokerDown() throws Exception {
-    //     for (BrokerContainer b : pulsarCluster.getBrokers()) {
-    //         b.execCmd("pkill", "-STOP", "java");
-    //     }
-    //     assertHealthcheckFailure();
-    // }
-
     @Test
     public void testBookKeeperDown() throws Exception {
         for (BKContainer b : pulsarCluster.getBookies()) {
             b.execCmd("pkill", "-STOP", "java");
         }
-        assertHealthcheckFailure();
-    }
-
-    private static Map<String, String> parseOutput(String output) throws 
Exception {
-        ObjectMapper mapper = new ObjectMapper();
-        return mapper.readValue(output, new TypeReference<HashMap<String, 
String>>() {});
+        try {
+            assertHealthcheckFailure();
+        } finally {
+            for (BKContainer b : pulsarCluster.getBookies()) {
+                b.execCmd("pkill", "-CONT", "java");
+            }
+        }
     }
 }

Reply via email to