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

Function testTimeoutOnDeadServer

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

Source from the content-addressed store, hash-verified

966}
967
968func testTimeoutOnDeadServer(t *testing.T, e env) {
969 te := newTest(t, e)
970 te.userAgent = testAppUA
971 te.startServer(&testServer{security: e.security})
972 defer te.tearDown()
973
974 cc := te.clientConn()
975 tc := testgrpc.NewTestServiceClient(cc)
976 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
977 defer cancel()
978 if _, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.WaitForReady(true)); err != nil {
979 t.Fatalf("TestService/EmptyCall(_, _) = _, %v, want _, <nil>", err)
980 }
981 // Wait for the client to report READY, stop the server, then wait for the
982 // client to notice the connection is gone.
983 testutils.AwaitState(ctx, t, cc, connectivity.Ready)
984 te.srv.Stop()
985 testutils.AwaitNotState(ctx, t, cc, connectivity.Ready)
986 ctx, cancel = context.WithTimeout(ctx, defaultTestShortTimeout)
987 defer cancel()
988 if _, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.WaitForReady(true)); status.Code(err) != codes.DeadlineExceeded {
989 t.Fatalf("TestService/EmptyCall(%v, _) = _, %v, want _, error code: %s", ctx, err, codes.DeadlineExceeded)
990 }
991 awaitNewConnLogOutput()
992}
993
994func (s) TestServerGracefulStopIdempotent(t *testing.T) {
995 for _, e := range listTestEnv() {

Callers 1

Calls 12

EmptyCallMethod · 0.95
WaitForReadyFunction · 0.92
AwaitStateFunction · 0.92
AwaitNotStateFunction · 0.92
awaitNewConnLogOutputFunction · 0.85
CodeMethod · 0.80
newTestFunction · 0.70
FatalfMethod · 0.65
StopMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45
clientConnMethod · 0.45

Tested by

no test coverage detected