Owen-CH-Leung commented on code in PR #14891:
URL: https://github.com/apache/kafka/pull/14891#discussion_r1451689247
##########
tools/src/test/java/org/apache/kafka/tools/TopicCommandIntegrationTest.java:
##########
@@ -787,16 +827,28 @@ public void
testDescribeUnderReplicatedPartitionsWhenReassignmentIsInProgress(St
// describe the topic and test if it's under-replicated
String simpleDescribeOutput =
captureDescribeTopicStandardOut(buildTopicCommandOptionsWithBootstrap("--describe",
"--topic", testTopicName));
- String[] simpleDescribeOutputRows = simpleDescribeOutput.split("\n");
-
assertTrue(simpleDescribeOutputRows[0].startsWith(String.format("Topic: %s",
testTopicName)));
- assertEquals(2, simpleDescribeOutputRows.length);
+ String[] simpleDescribeOutputRows =
simpleDescribeOutput.split(System.lineSeparator());
+
assertTrue(simpleDescribeOutputRows[0].startsWith(String.format("Topic: %s",
testTopicName)),
+ "Unexpected describe output: " + simpleDescribeOutputRows[0]);
+ assertEquals(2, simpleDescribeOutputRows.length,
+ "Unexpected describe output length: " +
simpleDescribeOutputRows.length);
String underReplicatedOutput =
captureDescribeTopicStandardOut(buildTopicCommandOptionsWithBootstrap("--describe",
"--under-replicated-partitions"));
assertEquals("", underReplicatedOutput,
String.format("--under-replicated-partitions shouldn't return
anything: '%s'", underReplicatedOutput));
// Verify reassignment is still ongoing.
- PartitionReassignment reassignments =
adminClient.listPartitionReassignments(Collections.singleton(tp)).reassignments().get().get(tp);
+ PartitionReassignment reassignments = null;
+ int retryCount = 0;
+ int maxRetries = 20;
+ while (reassignments == null && retryCount < maxRetries) {
+ reassignments =
adminClient.listPartitionReassignments(Collections.singleton(tp)).reassignments().get().get(tp);
+ if (reassignments != null) {
+ break;
+ }
+ retryCount++;
+ Thread.sleep(100L);
+ }
assertFalse(reassignments.addingReplicas().isEmpty());
Review Comment:
Thanks. I've used `waitUntilTrue` to implement the retry logic.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]