Skip to content

Commit

Permalink
Merge 27540ee into 774da7f
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovic committed Jul 3, 2020
2 parents 774da7f + 27540ee commit 4d55a5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
12 changes: 7 additions & 5 deletions server/client_test.go
Expand Up @@ -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) {
Expand Down
16 changes: 9 additions & 7 deletions server/server_test.go
Expand Up @@ -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")
}
}

Expand Down

0 comments on commit 4d55a5f

Please sign in to comment.