Skip to content

Commit

Permalink
Fix grpc tests sleep between connections
Browse files Browse the repository at this point in the history
Previously there was no sleep when `testc.EmptyCall` returned an error,
so it was easy to blow throw 3000 attempts with no sleep whatsoever.

Signed-off-by: Ivan Babrou <[email protected]>
  • Loading branch information
bobrik committed Jul 26, 2024
1 parent 0e9c96a commit 9e6acc4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/discovery/grpcresolver/grpc_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ func makeSureConnectionsUp(t *testing.T, count int, testc grpc_testing.TestServi
for si := 0; si < count; si++ {
connected := false
for i := 0; i < 3000; i++ { // 3000 * 10ms = 30s
if i != 0 {
time.Sleep(time.Millisecond * 10)
}
_, err := testc.EmptyCall(context.Background(), &grpc_testing.Empty{}, grpc.Peer(&p))
if err != nil {
continue
Expand All @@ -98,7 +101,6 @@ func makeSureConnectionsUp(t *testing.T, count int, testc grpc_testing.TestServi
t.Logf("connected to peer #%d (%v) on iteration %d", si, p.Addr, i)
break
}
time.Sleep(time.Millisecond * 10)
}
assert.True(t, connected, "Connection #%d was still not up. Connections so far: %+v", si, addrs)
}
Expand Down

0 comments on commit 9e6acc4

Please sign in to comment.