diff --git a/test/end2end_test.go b/test/end2end_test.go index 7f1b7e1b..4b3c1db6 100644 --- a/test/end2end_test.go +++ b/test/end2end_test.go @@ -304,9 +304,10 @@ func setUp(useTLS bool, maxStream uint32) (s *grpc.Server, tc testpb.TestService func TestTimeoutOnDeadServer(t *testing.T) { s, tc := setUp(false, math.MaxUint32) s.Stop() - // Set a minimal deadline to make sure the context times out in the 1st - // invoke of ClientConn.wait. - ctx, _ := context.WithTimeout(context.Background(), time.Nanosecond) + // Set -1 as the timeout to make sure if transportMonitor gets error + // notification in time the failure path of the 1st invoke of + // ClientConn.wait hits the deadline exceeded error. + ctx, _ := context.WithTimeout(context.Background(), -1) if _, err := tc.EmptyCall(ctx, &testpb.Empty{}); grpc.Code(err) != codes.DeadlineExceeded { t.Fatalf("TestService/EmptyCall(%v, _) = _, error %v, want _, error code: %d", ctx, err, codes.DeadlineExceeded) }