hachikuji commented on a change in pull request #9777:
URL: https://github.com/apache/kafka/pull/9777#discussion_r567113645



##########
File path: core/src/test/scala/unit/kafka/utils/TestUtils.scala
##########
@@ -885,6 +891,24 @@ object TestUtils extends Logging {
     ), "Timed out waiting for broker metadata to propagate to all servers", 
timeout)
   }
 
+  /**
+   * Wait until the expected number of partitions is in the metadata cache in 
each broker.
+   *
+   * @param servers The list of servers that the metadata should reach to
+   * @param topic The topic name
+   * @param expectedNumPartitions The expected number of partitions
+   */
+  def waitUntilMetadataIsPropagatedWithExpectedSize(servers: Seq[KafkaServer], 
topic: String, expectedNumPartitions: Int): Unit = {

Review comment:
       What do you think about more concise names?
   `waitUntilMetadataIsPropagatedWithExpectedSize` -> 
`waitForAllPartitionMetadata`
   `waitUntilMetadataIsPropagated` -> `waitForPartitionMetadata`
   
   I wonder if this would be more useful if we return the partition metadata: 
`Map[TopicPartition, UpdateMetadataPartitionState`. Then we could probably skip 
the calls to `waitUntilMetadataIsPropagated` and 
`waitUntilLeaderIsElectedOrChanged` above.

##########
File path: core/src/test/scala/unit/kafka/utils/TestUtils.scala
##########
@@ -885,6 +891,24 @@ object TestUtils extends Logging {
     ), "Timed out waiting for broker metadata to propagate to all servers", 
timeout)
   }
 
+  /**
+   * Wait until the expected number of partitions is in the metadata cache in 
each broker.
+   *
+   * @param servers The list of servers that the metadata should reach to
+   * @param topic The topic name
+   * @param expectedNumPartitions The expected number of partitions
+   */
+  def waitUntilMetadataIsPropagatedWithExpectedSize(servers: Seq[KafkaServer], 
topic: String, expectedNumPartitions: Int): Unit = {
+    waitUntilTrue(
+      () => servers.forall { server =>
+        server.dataPlaneRequestProcessor.metadataCache.numPartitions(topic) 
match {

Review comment:
       Can we use `server.metadataCache`?




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to