You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/07/11 15:33:00 UTC

[GitHub] [kafka] ueisele commented on a change in pull request #10935: KAFKA-13003: In kraft mode also advertise configured advertised port instead of socket port

ueisele commented on a change in pull request #10935:
URL: https://github.com/apache/kafka/pull/10935#discussion_r667498348



##########
File path: core/src/test/scala/integration/kafka/server/RaftClusterTest.scala
##########
@@ -313,4 +318,94 @@ class RaftClusterTest {
       cluster.close()
     }
   }
+
+  @Test
+  def testCreateClusterWithAdvertisedPortZero(): Unit = {
+    val nodes = new TestKitNodes.Builder()
+      .setNumControllerNodes(1)
+      .setNumBrokerNodes(3)
+      .build()
+    nodes.brokerNodes().values().forEach { broker =>
+      broker.propertyOverrides().put(KafkaConfig.ListenersProp,
+        s"${nodes.externalListenerName().value()}://localhost:0")
+      broker.propertyOverrides().put(KafkaConfig.AdvertisedListenersProp,
+        s"${nodes.externalListenerName().value()}://localhost:0")
+    }
+    val cluster = new KafkaClusterTestKit.Builder(nodes).build()
+    try {
+      cluster.format()
+      cluster.startup()
+
+      val (runningBrokerServer, foundRunningBroker) = TestUtils.computeUntilTrue(anyBrokerServer(cluster)){
+        brokerServer => brokerServer.currentState() == BrokerState.RUNNING
+      }
+      assertTrue(foundRunningBroker, "No Broker never made it to RUNNING state.")
+
+      val (describeClusterResponse, metadataUpToDate) = TestUtils.computeUntilTrue(
+        sendDescribeClusterRequest(runningBrokerServer.socketServer, nodes.externalListenerName())
+      ) {
+        response => response.nodes().size() == nodes.brokerNodes().size()
+      }
+      assertTrue(metadataUpToDate, s"Broker never reached expected cluster size of ${nodes.brokerNodes().size()}")

Review comment:
       I refactored the two tests and also considered your other two remarks.




-- 
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-unsubscribe@kafka.apache.org

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