Skip to content

Commit

Permalink
Tear down ZK server after test is finished
Browse files Browse the repository at this point in the history
Author: franklinhu
Pull Request: #23
URL: #23
  • Loading branch information
Franklin Hu committed Jun 13, 2012
1 parent 8edcc1b commit a4fbcf7
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class ZipkinSpec extends Specification with JMocker with ClassMocker {
var collectorTransport: Service[ThriftClientRequest, Array[Byte]] = null
var query: ZipkinQuery = null
var queryTransport: Service[ThriftClientRequest, Array[Byte]] = null
var zooKeeperServer: ZooKeeperServer = null
var connectionFactory: NIOServerCnxn.Factory = null

"ZipkinCollector and ZipkinQuery" should {
doBefore {
Expand All @@ -56,9 +58,9 @@ class ZipkinSpec extends Specification with JMocker with ClassMocker {
// start a temporary zookeeper server
val zkPort = 2181 // TODO pick another port?
val tmpDir = FileUtils.createTempDir()
val zooKeeperServer =
zooKeeperServer =
new ZooKeeperServer(new FileTxnSnapLog(tmpDir, tmpDir), new BasicDataTreeBuilder())
val connectionFactory = new NIOServerCnxn.Factory(new InetSocketAddress(zkPort))
connectionFactory = new NIOServerCnxn.Factory(new InetSocketAddress(zkPort))
connectionFactory.startup(zooKeeperServer)

// no need to register in serversets
Expand Down Expand Up @@ -106,6 +108,9 @@ class ZipkinSpec extends Specification with JMocker with ClassMocker {
queryTransport.release()
query.shutdown()

zooKeeperServer.shutdown()
connectionFactory.shutdown()

FakeServer.stop()
}

Expand Down

0 comments on commit a4fbcf7

Please sign in to comment.