Skip to content

Commit

Permalink
chore: fix flaky client initialization test (#742)
Browse files Browse the repository at this point in the history
This commit retries the dialer a few times to handle the case where a
client has connected but has not yet dialed the remote instance, while
the test has already asserted the dialer should have run.

Fixes #551
  • Loading branch information
enocom authored Dec 20, 2024
1 parent 8ce3469 commit 3e44db8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions internal/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,19 @@ func TestClientLimitsMaxConnections(t *testing.T) {
// it doesn't matter which is closed
wantEOF(t, conn1, conn2)

want := 1
if got := d.dialAttempts(); got != want {
tryDialAttempts := func(t *testing.T, want int) {
var got int
for i := 0; i < 10; i++ {
got = d.dialAttempts()
if got == want {
return
}
time.Sleep(100 * time.Millisecond)
}
t.Fatalf("dial attempts did not match expected, want = %v, got = %v", want, got)
}
want := 1
tryDialAttempts(t, want)
}

func tryTCPDial(t *testing.T, addr string) net.Conn {
Expand Down

0 comments on commit 3e44db8

Please sign in to comment.