MCPcopy
hub / github.com/grpc/grpc-go / testCancel

Function testCancel

test/end2end_test.go:3092–3120  ·  view source on GitHub ↗
(t *testing.T, e env)

Source from the content-addressed store, hash-verified

3090}
3091
3092func testCancel(t *testing.T, e env) {
3093 te := newTest(t, e)
3094 te.declareLogNoise("grpc: the client connection is closing; please retry")
3095 te.startServer(&testServer{security: e.security, unaryCallSleepTime: time.Second})
3096 defer te.tearDown()
3097
3098 cc := te.clientConn()
3099 tc := testgrpc.NewTestServiceClient(cc)
3100
3101 const argSize = 2718
3102 const respSize = 314
3103
3104 payload, err := newPayload(testpb.PayloadType_COMPRESSABLE, argSize)
3105 if err != nil {
3106 t.Fatal(err)
3107 }
3108
3109 req := &testpb.SimpleRequest{
3110 ResponseType: testpb.PayloadType_COMPRESSABLE,
3111 ResponseSize: respSize,
3112 Payload: payload,
3113 }
3114 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
3115 time.AfterFunc(1*time.Millisecond, cancel)
3116 if r, err := tc.UnaryCall(ctx, req); status.Code(err) != codes.Canceled {
3117 t.Fatalf("TestService/UnaryCall(_, _) = %v, %v; want _, error code: %s", r, err, codes.Canceled)
3118 }
3119 awaitNewConnLogOutput()
3120}
3121
3122func (s) TestCancelNoIO(t *testing.T) {
3123 for _, e := range listTestEnv() {

Callers 1

TestCancelMethod · 0.85

Calls 11

UnaryCallMethod · 0.95
newPayloadFunction · 0.85
awaitNewConnLogOutputFunction · 0.85
declareLogNoiseMethod · 0.80
CodeMethod · 0.80
newTestFunction · 0.70
FatalMethod · 0.65
FatalfMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45
clientConnMethod · 0.45

Tested by

no test coverage detected