Skip to content

Commit cfc815b

Browse files
committed
change all context usage to context.WithTimeout in gracefulstop_test
1 parent 59a3855 commit cfc815b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/gracefulstop_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ func (s) TestGracefulStopBlocksUntilGRPCConnectionsTerminate(t *testing.T) {
241241
grpcClientCallReturned := make(chan struct{})
242242
go func() {
243243
clt := ss.Client
244-
_, err := clt.UnaryCall(context.Background(), &testpb.SimpleRequest{})
244+
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
245+
defer cancel()
246+
_, err := clt.UnaryCall(ctx, &testpb.SimpleRequest{})
245247
if err != nil {
246248
t.Errorf("rpc failed with error: %s", err)
247249
}
@@ -290,7 +292,9 @@ func (s) TestStopAbortsBlockingGRPCCall(t *testing.T) {
290292
grpcClientCallReturned := make(chan struct{})
291293
go func() {
292294
clt := ss.Client
293-
_, err := clt.UnaryCall(context.Background(), &testpb.SimpleRequest{})
295+
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
296+
defer cancel()
297+
_, err := clt.UnaryCall(ctx, &testpb.SimpleRequest{})
294298
if err == nil || !isConnClosedErr(err) {
295299
t.Errorf("expected rpc to fail with connection closed error, got: %v", err)
296300
}

0 commit comments

Comments
 (0)