dengziming commented on code in PR #12108: URL: https://github.com/apache/kafka/pull/12108#discussion_r867294432
########## core/src/test/scala/unit/kafka/utils/TestUtils.scala: ########## @@ -1127,6 +1127,23 @@ object TestUtils extends Logging { throw new IllegalStateException(s"Cannot get topic: $topic, partition: $partition in server metadata cache")) } + /** + * Wait until the kraft broker metadata have caught up to the controller + */ + def waitForKRaftBrokerMetadataCatchupController( + brokers: Seq[KafkaBroker], + controllerServer: ControllerServer, + msg: String = "Timeout waiting for controller metadata propagating to brokers" + ): Unit = { + TestUtils.waitUntilTrue( + () => { + brokers.forall { broker => + val metadataOffset = broker.metadataCache.asInstanceOf[KRaftMetadataCache].currentImage().highestOffsetAndEpoch().offset + metadataOffset >= controllerServer.raftManager.replicatedLog.endOffset().offset - 1 Review Comment: Yeah, that makes sense, I also added a comment to this method that we should make sure the related metadata message has already been committed to the controller metadata log. -- 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