TestGoAwayStreamIDSmallerThanCreatedStreams tests the scenario where a server sends a goaway with a stream id that is smaller than some created streams on the client, while the client is simultaneously creating new streams. This should not induce a deadlock.
(t *testing.T)
| 656 | // the client, while the client is simultaneously creating new streams. This |
| 657 | // should not induce a deadlock. |
| 658 | func (s) TestGoAwayStreamIDSmallerThanCreatedStreams(t *testing.T) { |
| 659 | lis, err := net.Listen("tcp", "localhost:0") |
| 660 | if err != nil { |
| 661 | t.Fatalf("error listening: %v", err) |
| 662 | } |
| 663 | |
| 664 | ctCh := testutils.NewChannel() |
| 665 | go func() { |
| 666 | conn, err := lis.Accept() |
| 667 | if err != nil { |
| 668 | t.Errorf("error in lis.Accept(): %v", err) |
| 669 | } |
| 670 | ct := newClientTester(t, conn) |
| 671 | ctCh.Send(ct) |
| 672 | }() |
| 673 | |
| 674 | cc, err := grpc.NewClient(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials())) |
| 675 | if err != nil { |
| 676 | t.Fatalf("grpc.NewClient(%q) = %v", lis.Addr().String(), err) |
| 677 | } |
| 678 | defer cc.Close() |
| 679 | cc.Connect() |
| 680 | |
| 681 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 682 | defer cancel() |
| 683 | |
| 684 | val, err := ctCh.Receive(ctx) |
| 685 | if err != nil { |
| 686 | t.Fatalf("timeout waiting for client transport (should be given after http2 creation)") |
| 687 | } |
| 688 | ct := val.(*clientTester) |
| 689 | |
| 690 | tc := testgrpc.NewTestServiceClient(cc) |
| 691 | someStreamsCreated := grpcsync.NewEvent() |
| 692 | goAwayWritten := grpcsync.NewEvent() |
| 693 | go func() { |
| 694 | for i := 0; i < 20; i++ { |
| 695 | if i == 10 { |
| 696 | <-goAwayWritten.Done() |
| 697 | } |
| 698 | tc.FullDuplexCall(ctx) |
| 699 | if i == 4 { |
| 700 | someStreamsCreated.Fire() |
| 701 | } |
| 702 | } |
| 703 | }() |
| 704 | |
| 705 | <-someStreamsCreated.Done() |
| 706 | ct.writeGoAway(1, http2.ErrCodeNo, []byte{}) |
| 707 | goAwayWritten.Fire() |
| 708 | } |
| 709 | |
| 710 | // TestTwoGoAwayPingFrames tests the scenario where you get two go away ping |
| 711 | // frames from the client during graceful shutdown. This should not crash the |
nothing calls this directly
no test coverage detected