@@ -3590,9 +3590,6 @@ func testClientStreamingError(t *testing.T, e env) {
35903590// Tests that a client receives a cardinality violation error for client-streaming
35913591// RPCs if the server doesn't send a message before returning status OK.
35923592func (s ) TestClientStreamingCardinalityViolation_ServerHandlerMissingSendAndClose (t * testing.T ) {
3593- // TODO : https://github.com/grpc/grpc-go/issues/8119 - remove `t.Skip()`
3594- // after this is fixed.
3595- t .Skip ()
35963593 ss := & stubserver.StubServer {
35973594 StreamingInputCallF : func (_ testgrpc.TestService_StreamingInputCallServer ) error {
35983595 // Returning status OK without sending a response message.This is a
@@ -3741,6 +3738,111 @@ func (s) TestClientStreaming_ReturnErrorAfterSendAndClose(t *testing.T) {
37413738 }
37423739}
37433740
3741+ // Tests that a client receives a cardinality violation error for unary
3742+ // RPCs if the server doesn't send a message before returning status OK.
3743+ func (s ) TestUnaryRPC_ServerSendsOnlyTrailersWithOK (t * testing.T ) {
3744+ lis , err := testutils .LocalTCPListener ()
3745+ if err != nil {
3746+ t .Fatal (err )
3747+ }
3748+ defer lis .Close ()
3749+
3750+ ss := grpc .UnknownServiceHandler (func (any , grpc.ServerStream ) error {
3751+ return nil
3752+ })
3753+
3754+ s := grpc .NewServer (ss )
3755+ go s .Serve (lis )
3756+ defer s .Stop ()
3757+
3758+ ctx , cancel := context .WithTimeout (context .Background (), defaultTestTimeout )
3759+ defer cancel ()
3760+ cc , err := grpc .NewClient (lis .Addr ().String (), grpc .WithTransportCredentials (insecure .NewCredentials ()))
3761+ if err != nil {
3762+ t .Fatalf ("grpc.NewClient(%q) failed unexpectedly: %v" , lis .Addr (), err )
3763+ }
3764+ defer cc .Close ()
3765+
3766+ client := testgrpc .NewTestServiceClient (cc )
3767+ if _ , err = client .EmptyCall (ctx , & testpb.Empty {}); status .Code (err ) != codes .Internal {
3768+ t .Errorf ("stream.RecvMsg() = %v, want error %v" , status .Code (err ), codes .Internal )
3769+ }
3770+ }
3771+
3772+ // Tests that client will receive cardinality violations when calling
3773+ // RecvMsg() multiple times for non-streaming response streams.
3774+ func (s ) TestUnaryRPC_ClientCallRecvMsgTwice (t * testing.T ) {
3775+ e := tcpTLSEnv
3776+ te := newTest (t , e )
3777+ defer te .tearDown ()
3778+
3779+ te .startServer (& testServer {security : e .security })
3780+
3781+ cc := te .clientConn ()
3782+ ctx , cancel := context .WithTimeout (context .Background (), defaultTestTimeout )
3783+ defer cancel ()
3784+
3785+ desc := & grpc.StreamDesc {
3786+ StreamName : "UnaryCall" ,
3787+ ServerStreams : false ,
3788+ ClientStreams : false ,
3789+ }
3790+ stream , err := cc .NewStream (ctx , desc , "/grpc.testing.TestService/UnaryCall" )
3791+ if err != nil {
3792+ t .Fatalf ("cc.NewStream() failed unexpectedly: %v" , err )
3793+ }
3794+
3795+ if err := stream .SendMsg (& testpb.SimpleRequest {}); err != nil {
3796+ t .Fatalf ("stream.SendMsg(_) = %v, want <nil>" , err )
3797+ }
3798+
3799+ resp := & testpb.SimpleResponse {}
3800+ if err := stream .RecvMsg (resp ); err != nil {
3801+ t .Fatalf ("stream.RecvMsg() = %v , want <nil>" , err )
3802+ }
3803+
3804+ if err = stream .RecvMsg (resp ); status .Code (err ) != codes .Internal {
3805+ t .Errorf ("stream.RecvMsg() = %v, want error %v" , status .Code (err ), codes .Internal )
3806+ }
3807+ }
3808+
3809+ // Tests that client will receive cardinality violations when calling
3810+ // RecvMsg() multiple times for non-streaming response streams.
3811+ func (s ) TestClientStreaming_ClientCallRecvMsgTwice (t * testing.T ) {
3812+ ss := stubserver.StubServer {
3813+ StreamingInputCallF : func (stream testgrpc.TestService_StreamingInputCallServer ) error {
3814+ if err := stream .SendAndClose (& testpb.StreamingInputCallResponse {}); err != nil {
3815+ t .Errorf ("stream.SendAndClose(_) = %v, want <nil>" , err )
3816+ }
3817+ return nil
3818+ },
3819+ }
3820+ if err := ss .Start (nil ); err != nil {
3821+ t .Fatal ("Error starting server:" , err )
3822+ }
3823+ defer ss .Stop ()
3824+
3825+ ctx , cancel := context .WithTimeout (context .Background (), defaultTestTimeout )
3826+ defer cancel ()
3827+ stream , err := ss .Client .StreamingInputCall (ctx )
3828+ if err != nil {
3829+ t .Fatalf (".StreamingInputCall(_) = _, %v, want <nil>" , err )
3830+ }
3831+ if err := stream .Send (& testpb.StreamingInputCallRequest {}); err != nil {
3832+ t .Fatalf ("stream.Send(_) = %v, want <nil>" , err )
3833+ }
3834+ if err := stream .CloseSend (); err != nil {
3835+ t .Fatalf ("stream.CloseSend() = %v, want <nil>" , err )
3836+ }
3837+ resp := new (testpb.StreamingInputCallResponse )
3838+ if err := stream .RecvMsg (resp ); err != nil {
3839+ t .Fatalf ("stream.RecvMsg() = %v , want <nil>" , err )
3840+ }
3841+ if err = stream .RecvMsg (resp ); status .Code (err ) != codes .Internal {
3842+ t .Errorf ("stream.RecvMsg() = %v, want error %v" , status .Code (err ), codes .Internal )
3843+ }
3844+ }
3845+
37443846// Tests the behavior for server-side streaming when client calls SendMsg twice.
37453847// Second call to SendMsg should fail with Internal error and result in closing
37463848// the connection with a RST_STREAM.
@@ -3981,7 +4083,7 @@ func (s) TestServerStreaming_ClientSendsZeroRequests(t *testing.T) {
39814083}
39824084
39834085// Tests that a client receives a cardinality violation error for client-streaming
3984- // RPCs if the server call SendMsg multiple times.
4086+ // RPCs if the server call SendMsg() multiple times.
39854087func (s ) TestClientStreaming_ServerHandlerSendMsgAfterSendMsg (t * testing.T ) {
39864088 ss := stubserver.StubServer {
39874089 StreamingInputCallF : func (stream testgrpc.TestService_StreamingInputCallServer ) error {
0 commit comments