m1a2st commented on code in PR #20068: URL: https://github.com/apache/kafka/pull/20068#discussion_r2198067365
########## core/src/test/scala/integration/kafka/api/PlaintextAdminIntegrationTest.scala: ########## @@ -2850,6 +2851,20 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest { } } + def sleepMillisToPropagateMetadata(durationMs: Long, partition: TopicPartition): Unit = { + TimeUnit.MILLISECONDS.sleep(1000) + val prior = brokers.head.metadataCache.getPartitionLeaderEndpoint(partition.topic, partition.partition(), listenerName).get.id() Review Comment: Could you add a comment explaining why we need to call sleep here? ########## core/src/test/scala/integration/kafka/api/PlaintextAdminIntegrationTest.scala: ########## @@ -2850,6 +2851,20 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest { } } + def sleepMillisToPropagateMetadata(durationMs: Long, partition: TopicPartition): Unit = { + TimeUnit.MILLISECONDS.sleep(1000) + val prior = brokers.head.metadataCache.getPartitionLeaderEndpoint(partition.topic, partition.partition(), listenerName).get.id() + TestUtils.waitUntilTrue( + () => { + val allSynced = brokers.forall { broker => + val leaderIdOpt = broker.metadataCache.getPartitionLeaderEndpoint(partition.topic, partition.partition(), listenerName).map(_.id()) + val leaderId = leaderIdOpt.toScala + leaderId.contains(prior) + } + allSynced + }, s"Waited less than $durationMs ms", durationMs) Review Comment: Could you update the error message to indicate which condition was not met? ########## core/src/test/scala/integration/kafka/api/PlaintextAdminIntegrationTest.scala: ########## @@ -2850,6 +2851,20 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest { } } + def sleepMillisToPropagateMetadata(durationMs: Long, partition: TopicPartition): Unit = { Review Comment: Since `durationMs` is always set to `10000`, we might consider removing this parameter. -- 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