mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-14 10:10:42 -07:00
@@ -185,12 +185,14 @@ func TestAsyncClientWithRunningServer(t *testing.T) {
|
||||
defer c.close()
|
||||
|
||||
buf := make([]byte, 1000000)
|
||||
n := runtime.Stack(buf, true)
|
||||
|
||||
writeLoopTxt := fmt.Sprintf("writeLoop(%p)", c.client)
|
||||
if count := strings.Count(string(buf[:n]), writeLoopTxt); count != 1 {
|
||||
t.Fatalf("writeLoop for client started more than once: %v", count)
|
||||
}
|
||||
checkFor(t, time.Second, 15*time.Millisecond, func() error {
|
||||
n := runtime.Stack(buf, true)
|
||||
if count := strings.Count(string(buf[:n]), writeLoopTxt); count != 1 {
|
||||
return fmt.Errorf("writeLoop for client should have been started only once: %v", count)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func TestClientCreateAndInfo(t *testing.T) {
|
||||
|
||||
@@ -401,16 +401,18 @@ func TestClientAdvertiseErrorOnStartup(t *testing.T) {
|
||||
opts.ClientAdvertise = "addr:::123"
|
||||
s := New(opts)
|
||||
defer s.Shutdown()
|
||||
dl := &DummyLogger{}
|
||||
s.SetLogger(dl, false, false)
|
||||
l := &captureFatalLogger{fatalCh: make(chan string, 1)}
|
||||
s.SetLogger(l, false, false)
|
||||
|
||||
// Expect this to return due to failure
|
||||
s.Start()
|
||||
dl.Lock()
|
||||
msg := dl.msg
|
||||
dl.Unlock()
|
||||
if !strings.Contains(msg, "ClientAdvertise") {
|
||||
t.Fatalf("Unexpected error: %v", msg)
|
||||
select {
|
||||
case msg := <-l.fatalCh:
|
||||
if !strings.Contains(msg, "ClientAdvertise") {
|
||||
t.Fatalf("Unexpected error: %v", msg)
|
||||
}
|
||||
case <-time.After(time.Second):
|
||||
t.Fatalf("Should have failed to start")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user