Owen-CH-Leung commented on code in PR #14891:
URL: https://github.com/apache/kafka/pull/14891#discussion_r1451666065


##########
tools/src/test/java/org/apache/kafka/tools/TopicCommandIntegrationTest.java:
##########
@@ -159,100 +166,117 @@ public void close() throws Exception {
     @ParameterizedTest(name = 
ToolsTestUtils.TEST_WITH_PARAMETERIZED_QUORUM_NAME)
     @ValueSource(strings = {"zk", "kraft"})
     public void testCreate(String quorum) throws Exception {
-        createAndWaitTopic(buildTopicCommandOptionsWithBootstrap(
-            "--create", "--partitions", "2", "--replication-factor", "1", 
"--topic", testTopicName));
-
-        
assertTrue(adminClient.listTopics().names().get().contains(testTopicName));
+        TestUtils.createTopicWithAdmin(adminClient, testTopicName, 
scalaBrokers, scalaControllers, 2, 1,
+                scala.collection.immutable.Map$.MODULE$.empty(), new 
Properties()

Review Comment:
   `createAndWaitTopic` creates the topic and wait for a valid leader to be 
propagated to metadatacache (it calls the `TestUtils` API 
`waitForPartitionMetadata`. Meanwhile, `createTopicWithAdmin` calls the 
`TestUtils` API `waitForAllPartitionsMetadata` and wait until the expected 
number of partitions is in the metadata cache in each broker (And it also calls 
`ensureConsistentKRaftMetadata` which wait until the kraft broker metadata have 
caught up to the controller) 
   
   I believe the use of `createTopicWithAdmin` will lead to more stable test 
result...What do you think ? Happy to hear your thoughts 



-- 
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

Reply via email to