Skip to content

Commit

Permalink
Attempt 3 times to reconnect to allow listener to set up
Browse files Browse the repository at this point in the history
  • Loading branch information
gbbr committed Feb 11, 2021
1 parent 183fd15 commit d31a680
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions statsd/pipe_windows_test.go
Expand Up @@ -106,17 +106,21 @@ func TestPipeWriterReconnect(t *testing.T) {
// ok
}

// third attempt succeeds with new connection
if err := client.Gauge("metric", 3, []string{"key:val"}, 1); err != nil {
t.Fatalf("Failed to send second gauge: %s", err)
}
timeout = time.After(100 * time.Millisecond)
select {
case got := <-out:
if exp := "metric:3|g|#key:val"; got != exp {
t.Fatalf("Expected %q, got %q", exp, got)
// subsequent attempts succeed with new connection
for n := 0; n < 3; n++ {
if err := client.Gauge("metric", 3, []string{"key:val"}, 1); err != nil {
t.Fatalf("Failed to send second gauge: %s", err)
}
timeout = time.After(500 * time.Millisecond)
select {
case got := <-out:
if exp := "metric:3|g|#key:val"; got != exp {
t.Fatalf("Expected %q, got %q", exp, got)
}
return
case <-timeout:
continue
}
case <-timeout:
t.Fatal("Third attempt should have succeeded")
}
t.Fatal("failed to reconnect")
}

0 comments on commit d31a680

Please sign in to comment.