Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tear down ZK server after test is finished #23

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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