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

Function testServerMultipleGoAwayPendingRPC

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

Source from the content-addressed store, hash-verified

333}
334
335func testServerMultipleGoAwayPendingRPC(t *testing.T, e env) {
336 te := newTest(t, e)
337 te.userAgent = testAppUA
338 te.declareLogNoise(
339 "transport: http2Client.notifyError got notified that the client transport was broken EOF",
340 "grpc: addrConn.transportMonitor exits due to: grpc: the connection is closing",
341 "grpc: addrConn.resetTransport failed to create client transport: connection error",
342 )
343 te.startServer(&testServer{security: e.security})
344 defer te.tearDown()
345
346 cc := te.clientConn()
347 tc := testgrpc.NewTestServiceClient(cc)
348 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
349 stream, err := tc.FullDuplexCall(ctx, grpc.WaitForReady(true))
350 if err != nil {
351 t.Fatalf("%v.FullDuplexCall(_) = _, %v, want <nil>", tc, err)
352 }
353 // Finish an RPC to make sure the connection is good.
354 if _, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.WaitForReady(true)); err != nil {
355 t.Fatalf("%v.EmptyCall(_, _, _) = _, %v, want _, <nil>", tc, err)
356 }
357 ch1 := make(chan struct{})
358 go func() {
359 te.srv.GracefulStop()
360 close(ch1)
361 }()
362 ch2 := make(chan struct{})
363 go func() {
364 te.srv.GracefulStop()
365 close(ch2)
366 }()
367 // Loop until the server side GoAway signal is propagated to the client.
368
369 for {
370 ctx, cancel := context.WithTimeout(context.Background(), defaultTestShortTimeout)
371 if _, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.WaitForReady(true)); err != nil {
372 cancel()
373 break
374 }
375 cancel()
376 }
377 select {
378 case <-ch1:
379 t.Fatal("GracefulStop() terminated early")
380 case <-ch2:
381 t.Fatal("GracefulStop() terminated early")
382 default:
383 }
384 respParam := []*testpb.ResponseParameters{
385 {
386 Size: 1,
387 },
388 }
389 payload, err := newPayload(testpb.PayloadType_COMPRESSABLE, int32(100))
390 if err != nil {
391 t.Fatal(err)
392 }

Callers 1

Calls 15

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

Tested by

no test coverage detected