Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2483#discussion_r17950810
  
    --- Diff: 
external/kafka/src/test/scala/org/apache/spark/streaming/kafka/KafkaStreamSuite.scala
 ---
    @@ -59,16 +58,35 @@ class KafkaStreamSuite extends TestSuiteBase {
     
       override def beforeFunction() {
         // Zookeeper server startup
    -    zookeeper = new EmbeddedZookeeper(zkConnect)
    +    zookeeper = new EmbeddedZookeeper(s"$zkHost:$zkPort")
    +    // Get the actual zookeeper binding port
    +    zkPort = zookeeper.actualPort
         logInfo("==================== 0 ====================")
    -    zkClient = new ZkClient(zkConnect, zkSessionTimeout, 
zkConnectionTimeout, ZKStringSerializer)
    +
    +    zkClient = new ZkClient(s"$zkHost:$zkPort", zkSessionTimeout, 
zkConnectionTimeout,
    +      ZKStringSerializer)
         logInfo("==================== 1 ====================")
     
         // Kafka broker startup
    -    server = new KafkaServer(brokerConf)
    -    logInfo("==================== 2 ====================")
    -    server.startup()
    -    logInfo("==================== 3 ====================")
    +    var bindSuccess: Boolean = false
    +    while(!bindSuccess) {
    +      try {
    +        val brokerProps = getBrokerConfig(brokerPort, s"$zkHost:$zkPort")
    +        brokerConf = new KafkaConfig(brokerProps)
    +        server = new KafkaServer(brokerConf)
    --- End diff --
    
    Hi TD, thanks for reviewing. Actually there's no way for KafkaServer to 
read back the port it bound to, so I wrote like this to try different ports.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to