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

Method TestServerStreaming_ClientSendsMultipleMessages

test/end2end_test.go:4064–4104  ·  view source on GitHub ↗

Tests the behavior for server-side streaming RPC when client misbehaves as Bidi-streaming and sends multiple messages.

(t *testing.T)

Source from the content-addressed store, hash-verified

4062// Tests the behavior for server-side streaming RPC when client misbehaves as Bidi-streaming
4063// and sends multiple messages.
4064func (s) TestServerStreaming_ClientSendsMultipleMessages(t *testing.T) {
4065 // The initial call to recvMsg made by the generated code, will return the error.
4066 ss := stubserver.StubServer{}
4067 if err := ss.Start(nil); err != nil {
4068 t.Fatal("Error starting server:", err)
4069 }
4070 defer ss.Stop()
4071
4072 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
4073 defer cancel()
4074 cc, err := grpc.NewClient(ss.Address, grpc.WithTransportCredentials(local.NewCredentials()))
4075 if err != nil {
4076 t.Fatalf("grpc.NewClient(%q) failed unexpectedly: %v", ss.Address, err)
4077 }
4078 defer cc.Close()
4079
4080 // Making the client bi-di to bypass the client side checks that stop a non-streaming client
4081 // from sending multiple messages.
4082 desc := &grpc.StreamDesc{
4083 StreamName: "StreamingOutputCall",
4084 ServerStreams: true,
4085 ClientStreams: true,
4086 }
4087
4088 stream, err := cc.NewStream(ctx, desc, "/grpc.testing.TestService/StreamingOutputCall")
4089 if err != nil {
4090 t.Fatalf("cc.NewStream() failed unexpectedly: %v", err)
4091 }
4092
4093 if err := stream.SendMsg(&testpb.Empty{}); err != nil {
4094 t.Errorf("stream.SendMsg() = %v, want <nil>", err)
4095 }
4096
4097 if err := stream.SendMsg(&testpb.Empty{}); err != nil {
4098 t.Errorf("stream.SendMsg() = %v, want <nil>", err)
4099 }
4100
4101 if err := stream.RecvMsg(&testpb.Empty{}); status.Code(err) != codes.Internal {
4102 t.Errorf("stream.RecvMsg() = %v, want error %v", status.Code(err), codes.Internal)
4103 }
4104}
4105
4106// Tests the behavior of server for server-side streaming RPC when client sends zero request messages.
4107func (s) TestServerStreaming_ServerRecvZeroRequests(t *testing.T) {

Callers

nothing calls this directly

Calls 13

StartMethod · 0.95
StopMethod · 0.95
SendMsgMethod · 0.95
RecvMsgMethod · 0.95
NewClientFunction · 0.92
WithTransportCredentialsFunction · 0.92
NewCredentialsFunction · 0.92
CodeMethod · 0.80
FatalMethod · 0.65
FatalfMethod · 0.65
CloseMethod · 0.65
NewStreamMethod · 0.65

Tested by

no test coverage detected