mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-16 19:14:41 -07:00
36 lines
786 B
Go
36 lines
786 B
Go
// Copyright 2012 Apcera Inc. All rights reserved.
|
|
|
|
package test
|
|
|
|
import (
|
|
"runtime"
|
|
"testing"
|
|
"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)
|
|
}
|
|
}
|