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

Function doServerSideInitiatedFailedStreamWithRSTStream

test/channelz_test.go:876–913  ·  view source on GitHub ↗

This func is to be used to test client side counting of failed streams.

(tc testgrpc.TestServiceClient, t *testing.T, l *listenerWrapper)

Source from the content-addressed store, hash-verified

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) {
877 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
878 defer cancel()
879 stream, err := tc.FullDuplexCall(ctx)
880 if err != nil {
881 t.Fatalf("TestService/FullDuplexCall(_) = _, %v, want <nil>", err)
882 }
883
884 const smallSize = 1
885 smallPayload, err := newPayload(testpb.PayloadType_COMPRESSABLE, smallSize)
886 if err != nil {
887 t.Fatal(err)
888 }
889
890 sreq := &testpb.StreamingOutputCallRequest{
891 ResponseType: testpb.PayloadType_COMPRESSABLE,
892 ResponseParameters: []*testpb.ResponseParameters{
893 {Size: smallSize},
894 },
895 Payload: smallPayload,
896 }
897
898 if err := stream.Send(sreq); err != nil {
899 t.Fatalf("%v.Send(%v) = %v, want <nil>", stream, sreq, err)
900 }
901 if _, err := stream.Recv(); err != nil {
902 t.Fatalf("%v.Recv() = %v, want <nil>", stream, err)
903 }
904
905 rcw := l.getLastConn()
906
907 if rcw != nil {
908 rcw.writeRSTStream(tc.(*testServiceClientWrapper).getCurrentStreamID(), http2.ErrCodeCancel)
909 }
910 if _, err := stream.Recv(); err == nil {
911 t.Fatalf("%v.Recv() = %v, want <non-nil>", stream, err)
912 }
913}
914
915// this func is to be used to test client side counting of failed streams.
916func doServerSideInitiatedFailedStreamWithGoAway(ctx context.Context, tc testgrpc.TestServiceClient, t *testing.T, l *listenerWrapper) {

Calls 9

newPayloadFunction · 0.85
getLastConnMethod · 0.80
getCurrentStreamIDMethod · 0.80
FullDuplexCallMethod · 0.65
FatalfMethod · 0.65
FatalMethod · 0.65
SendMethod · 0.65
RecvMethod · 0.65
writeRSTStreamMethod · 0.45

Tested by

no test coverage detected