You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by jy...@apache.org on 2026/08/23 15:11:19 UTC
(kafka) branch trunk updated: MINOR: fix ClientRebootstrapTest verification and admin cleanup (#23231)
This is an automated email from the ASF dual-hosted git repository.
m1a2st pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 9f1512a245e MINOR: fix ClientRebootstrapTest verification and admin cleanup (#23231)
9f1512a245e is described below
commit 9f1512a245ea75b773213dd36f6f0e6ee95a2176
Author: Yu-Chia Ma <79...@users.noreply.github.com>
AuthorDate: Sun Aug 23 23:11:12 2026 +0800
MINOR: fix ClientRebootstrapTest verification and admin cleanup (#23231)
Related to this
[comment](https://github.com/apache/kafka/pull/19187#pullrequestreview-4996055200),
* Verify `TOPIC` existence with assertTrue.
* Ensure the Admin client is always closed with try-finally.
Reviewers: Uros (github:uros-b), Ken Huang <s7...@gmail.com>,
Chia-Ping Tsai <ch...@gmail.com>
---
.../kafka/clients/ClientRebootstrapTest.java | 32 +++++++++++++---------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/ClientRebootstrapTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/ClientRebootstrapTest.java
index b1a7b11334d..ba2a12c7f87 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/ClientRebootstrapTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/ClientRebootstrapTest.java
@@ -41,6 +41,7 @@ import java.util.concurrent.TimeoutException;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class ClientRebootstrapTest {
private static final String TOPIC = "topic";
@@ -65,7 +66,8 @@ public class ClientRebootstrapTest {
admin.createTopics(List.of(new NewTopic(TOPIC, PARTITIONS, (short) REPLICAS)));
// Only the broker 1 is available for the admin client during the bootstrap.
- assertDoesNotThrow(() -> admin.listTopics().names().get(timeout, TimeUnit.SECONDS).contains(TOPIC));
+ var topics = assertDoesNotThrow(() -> admin.listTopics().names().get(timeout, TimeUnit.SECONDS));
+ assertTrue(topics.contains(TOPIC));
clusterInstance.shutdownBroker(broker1);
clusterInstance.startBroker(broker0);
@@ -73,7 +75,8 @@ public class ClientRebootstrapTest {
// The broker 1, originally cached during the bootstrap, is offline.
// However, the broker 0 from the bootstrap list is online.
// Should be able to list topics again.
- assertDoesNotThrow(() -> admin.listTopics().names().get(timeout, TimeUnit.SECONDS).contains(TOPIC));
+ topics = assertDoesNotThrow(() -> admin.listTopics().names().get(timeout, TimeUnit.SECONDS));
+ assertTrue(topics.contains(TOPIC));
}
}
@@ -91,19 +94,22 @@ public class ClientRebootstrapTest {
clusterInstance.shutdownBroker(broker0);
var admin = clusterInstance.admin(Map.of(CommonClientConfigs.METADATA_RECOVERY_STRATEGY_CONFIG, "none"));
- admin.createTopics(List.of(new NewTopic(TOPIC, PARTITIONS, (short) REPLICAS)));
-
- // Only the broker 1 is available for the admin client during the bootstrap.
- assertDoesNotThrow(() -> admin.listTopics().names().get(60, TimeUnit.SECONDS).contains(TOPIC));
+ try {
+ admin.createTopics(List.of(new NewTopic(TOPIC, PARTITIONS, (short) REPLICAS)));
+ // Only the broker 1 is available for the admin client during the bootstrap.
+ var topics = assertDoesNotThrow(() -> admin.listTopics().names().get(60, TimeUnit.SECONDS));
+ assertTrue(topics.contains(TOPIC));
- clusterInstance.shutdownBroker(broker1);
- clusterInstance.startBroker(broker0);
+ clusterInstance.shutdownBroker(broker1);
+ clusterInstance.startBroker(broker0);
- // The broker 1, originally cached during the bootstrap, is offline.
- // As a result, the admin client will throw a TimeoutException when trying to get list of the topics.
- assertThrows(TimeoutException.class, () -> admin.listTopics().names().get(5, TimeUnit.SECONDS));
- // Since the brokers cached during the bootstrap are offline, the admin client needs to wait the default timeout for other threads.
- admin.close(Duration.ZERO);
+ // The broker 1, originally cached during the bootstrap, is offline.
+ // As a result, the admin client will throw a TimeoutException when trying to get list of the topics.
+ assertThrows(TimeoutException.class, () -> admin.listTopics().names().get(5, TimeUnit.SECONDS));
+ } finally {
+ // Since the brokers cached during the bootstrap are offline, the admin client needs to wait the default timeout for other threads.
+ admin.close(Duration.ZERO);
+ }
}
@ClusterTest(