Repository: kafka Updated Branches: refs/heads/trunk b24f9c089 -> 723fa4c40
KAFKA-328 Write unit test for kafka server startup and shutdown API; reviewed by Neha Narkhede Project: http://git-wip-us.apache.org/repos/asf/kafka/repo Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/723fa4c4 Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/723fa4c4 Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/723fa4c4 Branch: refs/heads/trunk Commit: 723fa4c40d2d04a8557ef9a0ae1626e56f30a9a3 Parents: b24f9c0 Author: Balaji Seshadri <[email protected]> Authored: Tue Dec 2 15:17:20 2014 -0800 Committer: Neha Narkhede <[email protected]> Committed: Tue Dec 2 15:17:42 2014 -0800 ---------------------------------------------------------------------- .../unit/kafka/server/ServerShutdownTest.scala | 14 ++++++++++++++ .../scala/unit/kafka/server/ServerStartupTest.scala | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kafka/blob/723fa4c4/core/src/test/scala/unit/kafka/server/ServerShutdownTest.scala ---------------------------------------------------------------------- diff --git a/core/src/test/scala/unit/kafka/server/ServerShutdownTest.scala b/core/src/test/scala/unit/kafka/server/ServerShutdownTest.scala index 1bfb501..67918f2 100644 --- a/core/src/test/scala/unit/kafka/server/ServerShutdownTest.scala +++ b/core/src/test/scala/unit/kafka/server/ServerShutdownTest.scala @@ -146,4 +146,18 @@ class ServerShutdownTest extends JUnit3Suite with ZooKeeperTestHarness { .map(_.asInstanceOf[Thread]) .count(t => !t.isDaemon && t.isAlive && t.getClass.getCanonicalName.toLowerCase.startsWith("kafka"))) } + + def testConsecutiveShutdown(){ + val server = new KafkaServer(config) + try { + server.startup() + server.shutdown() + server.awaitShutdown() + server.shutdown() + assertTrue(true); + } + catch{ + case ex => fail() + } + } } http://git-wip-us.apache.org/repos/asf/kafka/blob/723fa4c4/core/src/test/scala/unit/kafka/server/ServerStartupTest.scala ---------------------------------------------------------------------- diff --git a/core/src/test/scala/unit/kafka/server/ServerStartupTest.scala b/core/src/test/scala/unit/kafka/server/ServerStartupTest.scala index a0ed485..8fe7cd4 100644 --- a/core/src/test/scala/unit/kafka/server/ServerStartupTest.scala +++ b/core/src/test/scala/unit/kafka/server/ServerStartupTest.scala @@ -18,7 +18,6 @@ package kafka.server import org.scalatest.junit.JUnit3Suite -import kafka.zk import kafka.utils.ZkUtils import kafka.utils.Utils import kafka.utils.TestUtils @@ -36,7 +35,6 @@ class ServerStartupTest extends JUnit3Suite with ZooKeeperTestHarness { val props = TestUtils.createBrokerConfig(brokerId, TestUtils.choosePort()) val zooKeeperConnect = props.get("zookeeper.connect") props.put("zookeeper.connect", zooKeeperConnect + zookeeperChroot) - server = TestUtils.createServer(new KafkaConfig(props)) } @@ -51,4 +49,18 @@ class ServerStartupTest extends JUnit3Suite with ZooKeeperTestHarness { assertTrue(pathExists) } + def testServerStartupConsecutively() { + server.shutdown() + try { + intercept[IllegalStateException]{ + server.startup() + server.startup() + } + } + finally { + server.shutdown() + } + + } + } \ No newline at end of file
