From a56a91e709a49f7d85d523ee7aaf54fae96c02bb Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 8 Oct 2025 15:13:38 -0700 Subject: [PATCH 1/3] MINOR: changed the condition to only check the test topic to reduce the flakiness of the test. --- .../src/test/java/org/apache/kafka/tools/TopicCommandTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java b/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java index c6f1073edb56c..af2a7606ac551 100644 --- a/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java +++ b/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java @@ -1198,7 +1198,7 @@ public void testDescribeUnderReplicatedPartitionsWhenReassignmentIsInProgress(Cl "Unexpected describe output length: " + simpleDescribeOutputRows.length); String underReplicatedOutput = captureDescribeTopicStandardOut(clusterInstance, buildTopicCommandOptionsWithBootstrap(clusterInstance, "--describe", "--under-replicated-partitions")); - assertEquals("", underReplicatedOutput, + assertFalse(underReplicatedOutput.contains(String.format("Topic: %s", testTopicName)), String.format("--under-replicated-partitions shouldn't return anything: '%s'", underReplicatedOutput)); int maxRetries = 20; From 80c484e19c53127bdb4d625fc0cf948017609fb9 Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 8 Oct 2025 18:05:47 -0700 Subject: [PATCH 2/3] Updated the error message. --- .../src/test/java/org/apache/kafka/tools/TopicCommandTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java b/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java index af2a7606ac551..d161b08a73121 100644 --- a/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java +++ b/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java @@ -1199,7 +1199,7 @@ public void testDescribeUnderReplicatedPartitionsWhenReassignmentIsInProgress(Cl String underReplicatedOutput = captureDescribeTopicStandardOut(clusterInstance, buildTopicCommandOptionsWithBootstrap(clusterInstance, "--describe", "--under-replicated-partitions")); assertFalse(underReplicatedOutput.contains(String.format("Topic: %s", testTopicName)), - String.format("--under-replicated-partitions shouldn't return anything: '%s'", underReplicatedOutput)); + String.format("--under-replicated-partitions shouldn't contain '%s': '%s'", String.format("Topic: %s", testTopicName), underReplicatedOutput)); int maxRetries = 20; long pause = 100L; From 1e211ef9a5ecab21c3fe568b86b2c3112fbc9809 Mon Sep 17 00:00:00 2001 From: Nikita Date: Thu, 9 Oct 2025 08:56:58 -0700 Subject: [PATCH 3/3] Small refactoring. --- .../test/java/org/apache/kafka/tools/TopicCommandTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java b/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java index d161b08a73121..57a8269f089bb 100644 --- a/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java +++ b/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java @@ -1192,14 +1192,15 @@ public void testDescribeUnderReplicatedPartitionsWhenReassignmentIsInProgress(Cl // describe the topic and test if it's under-replicated String simpleDescribeOutput = captureDescribeTopicStandardOut(clusterInstance, buildTopicCommandOptionsWithBootstrap(clusterInstance, "--describe", "--topic", testTopicName)); String[] simpleDescribeOutputRows = simpleDescribeOutput.split(System.lineSeparator()); - assertTrue(simpleDescribeOutputRows[0].startsWith(String.format("Topic: %s", testTopicName)), + String testTopicNameLogLine = String.format("Topic: %s", testTopicName); + assertTrue(simpleDescribeOutputRows[0].startsWith(testTopicNameLogLine), "Unexpected describe output: " + simpleDescribeOutputRows[0]); assertEquals(2, simpleDescribeOutputRows.length, "Unexpected describe output length: " + simpleDescribeOutputRows.length); String underReplicatedOutput = captureDescribeTopicStandardOut(clusterInstance, buildTopicCommandOptionsWithBootstrap(clusterInstance, "--describe", "--under-replicated-partitions")); - assertFalse(underReplicatedOutput.contains(String.format("Topic: %s", testTopicName)), - String.format("--under-replicated-partitions shouldn't contain '%s': '%s'", String.format("Topic: %s", testTopicName), underReplicatedOutput)); + assertFalse(underReplicatedOutput.contains(testTopicNameLogLine), + String.format("--under-replicated-partitions shouldn't contain '%s': '%s'", testTopicNameLogLine, underReplicatedOutput)); int maxRetries = 20; long pause = 100L;