mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
37 lines
789 B
Go
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)
|
|
}
|
|
}
|
|
|