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

Function testConcurrentServerStopAndGoAway

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

Source from the content-addressed store, hash-verified

461}
462
463func testConcurrentServerStopAndGoAway(t *testing.T, e env) {
464 te := newTest(t, e)
465 te.userAgent = testAppUA
466 te.declareLogNoise(
467 "transport: http2Client.notifyError got notified that the client transport was broken EOF",
468 "grpc: addrConn.transportMonitor exits due to: grpc: the connection is closing",
469 "grpc: addrConn.resetTransport failed to create client transport: connection error",
470 )
471 te.startServer(&testServer{security: e.security})
472 defer te.tearDown()
473
474 cc := te.clientConn()
475 tc := testgrpc.NewTestServiceClient(cc)
476 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
477 defer cancel()
478 stream, err := tc.FullDuplexCall(ctx, grpc.WaitForReady(true))
479 if err != nil {
480 t.Fatalf("%v.FullDuplexCall(_) = _, %v, want <nil>", tc, err)
481 }
482
483 // Finish an RPC to make sure the connection is good.
484 if _, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.WaitForReady(true)); err != nil {
485 t.Fatalf("%v.EmptyCall(_, _, _) = _, %v, want _, <nil>", tc, err)
486 }
487
488 ch := make(chan struct{})
489 go func() {
490 te.srv.GracefulStop()
491 close(ch)
492 }()
493 // Loop until the server side GoAway signal is propagated to the client.
494 for {
495 ctx, cancel := context.WithTimeout(context.Background(), defaultTestShortTimeout)
496 if _, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.WaitForReady(true)); err != nil {
497 cancel()
498 break
499 }
500 cancel()
501 }
502 // Stop the server and close all the connections.
503 te.srv.Stop()
504 respParam := []*testpb.ResponseParameters{
505 {
506 Size: 1,
507 },
508 }
509 payload, err := newPayload(testpb.PayloadType_COMPRESSABLE, int32(100))
510 if err != nil {
511 t.Fatal(err)
512 }
513 req := &testpb.StreamingOutputCallRequest{
514 ResponseType: testpb.PayloadType_COMPRESSABLE,
515 ResponseParameters: respParam,
516 Payload: payload,
517 }
518 sendStart := time.Now()
519 for {
520 if err := stream.Send(req); err == io.EOF {

Callers 1

Calls 15

FullDuplexCallMethod · 0.95
EmptyCallMethod · 0.95
WaitForReadyFunction · 0.92
newPayloadFunction · 0.85
awaitNewConnLogOutputFunction · 0.85
declareLogNoiseMethod · 0.80
NowMethod · 0.80
newTestFunction · 0.70
FatalfMethod · 0.65
GracefulStopMethod · 0.65
StopMethod · 0.65
FatalMethod · 0.65

Tested by

no test coverage detected