Skip to content

Commit d02723a

Browse files
authored
MINOR: Add shutdown broker and bootstrap controller for ConfigCommand (#22134)
FYI: #22104 (comment) Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
1 parent 82d0c12 commit d02723a

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

tools/src/test/java/org/apache/kafka/tools/ConfigCommandIntegrationTest.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,49 @@ public void testDeleteNonExistentConfigIsIdempotent() throws Exception {
644644
}
645645
}
646646

647+
@ClusterTest
648+
public void testDeleteNonExistentConfigIsIdempotentWithBootstrapController() throws Exception {
649+
String topicName = "test-delete-nonexistent-topic";
650+
try (Admin bootstrapControllerClient = cluster.admin(Map.of(), true);
651+
Admin bootstrapServerClient = cluster.admin(Map.of())) {
652+
bootstrapServerClient.createTopics(List.of(new NewTopic(topicName, 1, (short) 1))).all().get();
653+
ConfigCommand.alterConfig(bootstrapControllerClient, new ConfigCommand.ConfigCommandOptions(toArray(
654+
List.of("--bootstrap-controller", cluster.bootstrapControllers(),
655+
"--entity-type", "topics", "--entity-name", topicName,
656+
"--alter", "--delete-config", "non.existent.config"))));
657+
658+
ConfigCommand.alterConfig(bootstrapControllerClient, new ConfigCommand.ConfigCommandOptions(toArray(
659+
List.of("--bootstrap-controller", cluster.bootstrapControllers(),
660+
"--entity-type", "brokers", "--entity-name", defaultBrokerId,
661+
"--alter", "--delete-config", "non.existent.config"))));
662+
663+
ConfigCommand.alterConfig(bootstrapControllerClient, new ConfigCommand.ConfigCommandOptions(toArray(
664+
List.of("--bootstrap-controller", cluster.bootstrapControllers(),
665+
"--entity-type", "brokers", "--entity-default",
666+
"--alter", "--delete-config", "non.existent.config"))));
667+
}
668+
}
669+
670+
@ClusterTest(brokers = 2)
671+
public void testAlterBrokerConfigWithOfflineBroker() throws Exception {
672+
int offlineBrokerId = cluster.brokerIds().stream()
673+
.filter(id -> !cluster.controllerIds().contains(id))
674+
.findFirst()
675+
.orElseThrow();
676+
cluster.shutdownBroker(offlineBrokerId);
677+
TestUtils.waitForCondition(
678+
() -> !cluster.aliveBrokers().containsKey(offlineBrokerId),
679+
"Broker " + offlineBrokerId + " did not shut down in time"
680+
);
681+
682+
try (Admin client = cluster.admin(Map.of(), true)) {
683+
ConfigCommand.alterConfig(client, new ConfigCommand.ConfigCommandOptions(toArray(
684+
List.of("--bootstrap-controller", cluster.bootstrapControllers(),
685+
"--entity-type", "brokers", "--entity-name", String.valueOf(offlineBrokerId),
686+
"--alter", "--delete-config", "log.retention.ms"))));
687+
}
688+
}
689+
647690
// Test case from KAFKA-13788
648691
@ClusterTest(serverProperties = {
649692
// Must be at greater than 1MB per cleaner thread, set to 2M+2 so that we can set 2 cleaner threads.

0 commit comments

Comments
 (0)