kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsiva...@apache.org
Subject kafka git commit: MINOR: Add test brokers to list as they are created to ensure cleanup
Date Tue, 04 Jul 2017 09:36:58 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk cbafc08a5 -> afb91a02a


MINOR: Add test brokers to list as they are created to ensure cleanup

Author: Rajini Sivaram <rajinisivaram@googlemail.com>

Reviewers: Apurva Mehta <apurva@confluent.io>, Ismael Juma <ismael@juma.me.uk>

Closes #3471 from rajinisivaram/MINOR-shutdown-brokers


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/afb91a02
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/afb91a02
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/afb91a02

Branch: refs/heads/trunk
Commit: afb91a02ae1ef8aab6a33335eec0a07490b36390
Parents: cbafc08
Author: Rajini Sivaram <rajinisivaram@googlemail.com>
Authored: Tue Jul 4 10:36:42 2017 +0100
Committer: Rajini Sivaram <rajinisivaram@googlemail.com>
Committed: Tue Jul 4 10:36:42 2017 +0100

----------------------------------------------------------------------
 .../unit/kafka/integration/KafkaServerTestHarness.scala     | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/afb91a02/core/src/test/scala/unit/kafka/integration/KafkaServerTestHarness.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/integration/KafkaServerTestHarness.scala b/core/src/test/scala/unit/kafka/integration/KafkaServerTestHarness.scala
index da25d5c..ceeaffc 100755
--- a/core/src/test/scala/unit/kafka/integration/KafkaServerTestHarness.scala
+++ b/core/src/test/scala/unit/kafka/integration/KafkaServerTestHarness.scala
@@ -28,7 +28,7 @@ import org.apache.kafka.common.protocol.SecurityProtocol
 import org.apache.kafka.common.security.auth.KafkaPrincipal
 import org.junit.{After, Before}
 
-import scala.collection.mutable.Buffer
+import scala.collection.mutable.{ArrayBuffer, Buffer}
 import java.util.Properties
 
 import org.apache.kafka.common.network.ListenerName
@@ -38,7 +38,7 @@ import org.apache.kafka.common.network.ListenerName
  */
 abstract class KafkaServerTestHarness extends ZooKeeperTestHarness {
   var instanceConfigs: Seq[KafkaConfig] = null
-  var servers: Buffer[KafkaServer] = null
+  var servers: Buffer[KafkaServer] = new ArrayBuffer
   var brokerList: String = null
   var alive: Array[Boolean] = null
   val kafkaPrincipalType = KafkaPrincipal.USER_TYPE
@@ -88,7 +88,10 @@ abstract class KafkaServerTestHarness extends ZooKeeperTestHarness {
     // default implementation is a no-op, it is overridden by subclasses if required
     configureSecurityBeforeServersStart()
 
-    servers = configs.map(TestUtils.createServer(_)).toBuffer
+    // Add each broker to `servers` buffer as soon as it is created to ensure that brokers
+    // are shutdown cleanly in tearDown even if a subsequent broker fails to start
+    for (config <- configs)
+      servers += TestUtils.createServer(config)
     brokerList = TestUtils.bootstrapServers(servers, listenerName)
     alive = new Array[Boolean](servers.length)
     Arrays.fill(alive, true)


Mime
View raw message