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

Function testConcurrentClientConnCloseAndServerGoAway

test/goaway_test.go:424–452  ·  view source on GitHub ↗
(t *testing.T, e env)

Source from the content-addressed store, hash-verified

422}
423
424func testConcurrentClientConnCloseAndServerGoAway(t *testing.T, e env) {
425 te := newTest(t, e)
426 te.userAgent = testAppUA
427 te.declareLogNoise(
428 "transport: http2Client.notifyError got notified that the client transport was broken EOF",
429 "grpc: addrConn.transportMonitor exits due to: grpc: the connection is closing",
430 "grpc: addrConn.resetTransport failed to create client transport: connection error",
431 )
432 te.startServer(&testServer{security: e.security})
433 defer te.tearDown()
434
435 cc := te.clientConn()
436 tc := testgrpc.NewTestServiceClient(cc)
437 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
438 defer cancel()
439 if _, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.WaitForReady(true)); err != nil {
440 t.Fatalf("%v.EmptyCall(_, _, _) = _, %v, want _, <nil>", tc, err)
441 }
442 ch := make(chan struct{})
443 // Close ClientConn and Server concurrently.
444 go func() {
445 te.srv.GracefulStop()
446 close(ch)
447 }()
448 go func() {
449 cc.Close()
450 }()
451 <-ch
452}
453
454func (s) TestConcurrentServerStopAndGoAway(t *testing.T) {
455 for _, e := range listTestEnv() {

Calls 10

EmptyCallMethod · 0.95
WaitForReadyFunction · 0.92
declareLogNoiseMethod · 0.80
newTestFunction · 0.70
FatalfMethod · 0.65
GracefulStopMethod · 0.65
CloseMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45
clientConnMethod · 0.45

Tested by

no test coverage detected