cmccabe commented on a change in pull request #11410: URL: https://github.com/apache/kafka/pull/11410#discussion_r732089124
########## File path: core/src/test/scala/unit/kafka/utils/TestUtils.scala ########## @@ -1640,6 +1800,37 @@ object TestUtils extends Logging { }, s"Timed out waiting for brokerId $brokerId to come online") } + def getReplicaAssignmentForTopics[B <: KafkaBroker]( + topicNames: Seq[String], + brokers: Seq[B], + adminConfig: Properties = new Properties): Map[TopicPartition, Seq[Int]] = { + val adminClient = createAdminClient(brokers, adminConfig) + val results = new mutable.HashMap[TopicPartition, Seq[Int]] + try { + adminClient.describeTopics(topicNames.toList.asJava).topicNameValues().forEach { + case (topicName, future) => + try { + val description = future.get() + description.partitions().forEach { + case partition => + val topicPartition = new TopicPartition(topicName, partition.partition()) + results.put(topicPartition, partition.replicas().asScala.map(_.id)) + } + } catch { + case e: ExecutionException => if (e.getCause != null && + e.getCause.isInstanceOf[UnknownTopicOrPartitionException]) { + // ignore Review comment: I believe this is consistent with the behavior we have in the ZK case (which is not in TestUtils, but in KafkaZkClient or somewhere, as I recall)... I will add a JavaDoc comment. -- 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