Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some flappers #1501

Merged
merged 1 commit into from Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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