mjsax commented on code in PR #20509: URL: https://github.com/apache/kafka/pull/20509#discussion_r2342708180
########## streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/SmokeTestDriverIntegrationTest.java: ########## @@ -46,29 +47,43 @@ import static org.apache.kafka.streams.tests.SmokeTestDriver.generate; import static org.apache.kafka.streams.tests.SmokeTestDriver.verify; import static org.apache.kafka.streams.utils.TestUtils.safeUniqueTestName; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @Timeout(600) @Tag("integration") public class SmokeTestDriverIntegrationTest { - public static final EmbeddedKafkaCluster CLUSTER = new EmbeddedKafkaCluster(3); + private static EmbeddedKafkaCluster cluster = null; public TestInfo testInfo; + private ArrayList<SmokeTestClient> clients = new ArrayList<>(); @BeforeAll public static void startCluster() throws IOException { - CLUSTER.start(); + cluster = new EmbeddedKafkaCluster(3); + cluster.start(); } @AfterAll public static void closeCluster() { - CLUSTER.stop(); + cluster.stop(); + cluster = null; } @BeforeEach public void setUp(final TestInfo testInfo) { this.testInfo = testInfo; } + @AfterEach + public void shutDown(final TestInfo testInfo) { + // Clean up clients in case the test failed or timed out + for (final SmokeTestClient client : clients) { + if (!client.closed() && !client.error()) { + client.close(); Review Comment: Could `close()` throw an exception, and break the loop early? If yes, might be good to have try-catch around it, and just log a warning or similar, but continue the for-loop. ########## streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/SmokeTestDriverIntegrationTest.java: ########## @@ -46,29 +47,43 @@ import static org.apache.kafka.streams.tests.SmokeTestDriver.generate; import static org.apache.kafka.streams.tests.SmokeTestDriver.verify; import static org.apache.kafka.streams.utils.TestUtils.safeUniqueTestName; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @Timeout(600) @Tag("integration") public class SmokeTestDriverIntegrationTest { - public static final EmbeddedKafkaCluster CLUSTER = new EmbeddedKafkaCluster(3); + private static EmbeddedKafkaCluster cluster = null; public TestInfo testInfo; + private ArrayList<SmokeTestClient> clients = new ArrayList<>(); @BeforeAll public static void startCluster() throws IOException { - CLUSTER.start(); + cluster = new EmbeddedKafkaCluster(3); + cluster.start(); } @AfterAll public static void closeCluster() { - CLUSTER.stop(); + cluster.stop(); + cluster = null; } @BeforeEach public void setUp(final TestInfo testInfo) { this.testInfo = testInfo; } + @AfterEach + public void shutDown(final TestInfo testInfo) { + // Clean up clients in case the test failed or timed out + for (final SmokeTestClient client : clients) { + if (!client.closed() && !client.error()) { Review Comment: Why can't we make a blind call to `close()` ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org