Fix data race in TestServerGoAwayPendingRPC (#1862)

This commit is contained in:
dfawley
2018-02-13 16:48:27 -08:00
committed by GitHub
parent e014063a43
commit 445b7284b1

View File

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