Files
nats-server/test/gosrv_test.go
Derek Collison 5189dba7b6 Cluster startup
2013-07-27 16:29:25 -07:00

37 lines
789 B
Go

// Copyright 2012 Apcera Inc. All rights reserved.
package test
import (
"testing"
"runtime"
"time"
)
func TestSimpleGoServerShutdown(t *testing.T) {
base := runtime.NumGoroutine()
s := runDefaultServer()
s.Shutdown()
time.Sleep(10 * time.Millisecond)
delta := (runtime.NumGoroutine() - base)
if delta > 1 {
t.Fatalf("%d Go routines still exist post Shutdown()", delta)
}
}
func TestGoServerShutdownWithClients(t *testing.T) {
base := runtime.NumGoroutine()
s := runDefaultServer()
for i := 0 ; i < 10 ; i++ {
createClientConn(t, "localhost", 4222)
}
s.Shutdown()
// Wait longer for client connections
time.Sleep(50 * time.Millisecond)
delta := (runtime.NumGoroutine() - base)
if delta > 1 {
t.Fatalf("%d Go routines still exist post Shutdown()", delta)
}
}