Fix data race in TestServerGoAwayPendingRPC (#1862)
This commit is contained in:
@ -940,18 +940,18 @@ func testServerGoAwayPendingRPC(t *testing.T, e env) {
|
|||||||
close(ch)
|
close(ch)
|
||||||
}()
|
}()
|
||||||
// Loop until the server side GoAway signal is propagated to the client.
|
// Loop until the server side GoAway signal is propagated to the client.
|
||||||
abort := false
|
start := time.Now()
|
||||||
time.AfterFunc(time.Second, func() { abort = true })
|
errored := false
|
||||||
for !abort {
|
for time.Since(start) < time.Second {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
|
||||||
if _, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.FailFast(false)); err != nil {
|
_, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.FailFast(false))
|
||||||
cancel()
|
cancel()
|
||||||
|
if err != nil {
|
||||||
|
errored = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
cancel()
|
|
||||||
}
|
}
|
||||||
// Don't bother stopping the timer; it will have no effect past here.
|
if !errored {
|
||||||
if abort {
|
|
||||||
t.Fatalf("GoAway never received by client")
|
t.Fatalf("GoAway never received by client")
|
||||||
}
|
}
|
||||||
respParam := []*testpb.ResponseParameters{{Size: 1}}
|
respParam := []*testpb.ResponseParameters{{Size: 1}}
|
||||||
|
Reference in New Issue
Block a user