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

Function doClientSideInitiatedFailedStream

test/channelz_test.go:843–873  ·  view source on GitHub ↗
(tc testgrpc.TestServiceClient, t *testing.T)

Source from the content-addressed store, hash-verified

841}
842
843func doClientSideInitiatedFailedStream(tc testgrpc.TestServiceClient, t *testing.T) {
844 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
845 stream, err := tc.FullDuplexCall(ctx)
846 if err != nil {
847 t.Fatalf("TestService/FullDuplexCall(_) = _, %v, want <nil>", err)
848 }
849
850 const smallSize = 1
851 smallPayload, err := newPayload(testpb.PayloadType_COMPRESSABLE, smallSize)
852 if err != nil {
853 t.Fatal(err)
854 }
855
856 sreq := &testpb.StreamingOutputCallRequest{
857 ResponseType: testpb.PayloadType_COMPRESSABLE,
858 ResponseParameters: []*testpb.ResponseParameters{
859 {Size: smallSize},
860 },
861 Payload: smallPayload,
862 }
863
864 if err := stream.Send(sreq); err != nil {
865 t.Fatalf("%v.Send(%v) = %v, want <nil>", stream, sreq, err)
866 }
867 if _, err := stream.Recv(); err != nil {
868 t.Fatalf("%v.Recv() = %v, want <nil>", stream, err)
869 }
870 // By canceling the call, the client will send rst_stream to end the call, and
871 // the stream will failed as a result.
872 cancel()
873}
874
875// This func is to be used to test client side counting of failed streams.
876func doServerSideInitiatedFailedStreamWithRSTStream(tc testgrpc.TestServiceClient, t *testing.T, l *listenerWrapper) {

Calls 6

newPayloadFunction · 0.85
FullDuplexCallMethod · 0.65
FatalfMethod · 0.65
FatalMethod · 0.65
SendMethod · 0.65
RecvMethod · 0.65

Tested by

no test coverage detected