hachikuji commented on code in PR #12508: URL: https://github.com/apache/kafka/pull/12508#discussion_r947194934
########## core/src/test/scala/integration/kafka/server/KRaftClusterTest.scala: ########## @@ -778,4 +779,52 @@ class KRaftClusterTest { cluster.close() } } + def createAdminClient(cluster: KafkaClusterTestKit, useController: Boolean): Admin = { + var props: Properties = null + props = cluster.clientProperties() + props.put(AdminClientConfig.CLIENT_ID_CONFIG, this.getClass.getName) + Admin.create(props) + } + + @Test + def testDescribeQuorumRequestToBrokers() : Unit = { + val cluster = new KafkaClusterTestKit.Builder( + new TestKitNodes.Builder(). + setNumBrokerNodes(4). + setNumControllerNodes(3).build()).build() + try { + cluster.format + cluster.startup + for (i <- 0 to 3) { + TestUtils.waitUntilTrue(() => cluster.brokers.get(i).brokerState == BrokerState.RUNNING, + "Broker Never started up") + } + val admin = createAdminClient(cluster, false) + try { + val quorumState = admin.describeMetadataQuorum(new DescribeMetadataQuorumOptions) + val quorumInfo = quorumState.quorumInfo.get() + + assertEquals(0, quorumInfo.observers.size) + assertEquals(3, quorumInfo.voters.size) Review Comment: We are checking the size and all of the individual replicaIds below. For example: ``` assertTrue(-1 < observer.replicaId && 4 > observer.replicaId, s"Observer ID ${observer.replicaId} was not within expected range.") ``` I am just offering a more concise and complete way to do that. ########## core/src/test/scala/integration/kafka/server/KRaftClusterTest.scala: ########## @@ -778,4 +779,52 @@ class KRaftClusterTest { cluster.close() } } + def createAdminClient(cluster: KafkaClusterTestKit, useController: Boolean): Admin = { + var props: Properties = null + props = cluster.clientProperties() + props.put(AdminClientConfig.CLIENT_ID_CONFIG, this.getClass.getName) + Admin.create(props) + } + + @Test + def testDescribeQuorumRequestToBrokers() : Unit = { + val cluster = new KafkaClusterTestKit.Builder( + new TestKitNodes.Builder(). + setNumBrokerNodes(4). + setNumControllerNodes(3).build()).build() + try { + cluster.format + cluster.startup + for (i <- 0 to 3) { + TestUtils.waitUntilTrue(() => cluster.brokers.get(i).brokerState == BrokerState.RUNNING, + "Broker Never started up") + } + val admin = createAdminClient(cluster, false) + try { + val quorumState = admin.describeMetadataQuorum(new DescribeMetadataQuorumOptions) + val quorumInfo = quorumState.quorumInfo.get() + + assertEquals(0, quorumInfo.observers.size) + assertEquals(3, quorumInfo.voters.size) Review Comment: We are checking the size here and all of the individual replicaIds below. For example: ``` assertTrue(-1 < observer.replicaId && 4 > observer.replicaId, s"Observer ID ${observer.replicaId} was not within expected range.") ``` I am just offering a more concise and complete way to do that. -- 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