Skip to content

Commit 1b1800d

Browse files
committed
resolving comments
1 parent 749a52c commit 1b1800d

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

test/end2end_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3745,16 +3745,20 @@ func (s) TestClientStreaming_ReturnErrorAfterSendAndClose(t *testing.T) {
37453745
// Second call to SendMsg should fail with Internal error and result in closing
37463746
// the connection with a RST_STREAM.
37473747
func (s) TestServerStreaming_ClientCallSendMsgTwice(t *testing.T) {
3748-
// To ensure server.recvMsg() is successfully completed.
3748+
// To ensure initial call to server.recvMsg() made by the generated code is successfully
3749+
// completed. Otherwise, if the client attempts to send a second request message, that
3750+
// will trigger a RST_STREAM from the client due to the application violating the RPC's
3751+
// protocol. The RST_STREAM could cause the server’s first RecvMsg to fail and will prevent
3752+
// the method handler from being called.
37493753
recvDoneOnServer := make(chan struct{})
37503754
// To ensure goroutine for test does not end before RPC handler performs error
37513755
// checking.
37523756
handlerDone := make(chan struct{})
37533757
ss := stubserver.StubServer{
37543758
StreamingOutputCallF: func(_ *testpb.StreamingOutputCallRequest, stream testgrpc.TestService_StreamingOutputCallServer) error {
3755-
// The initial call to recvMsg is made by the generated code. Signal test when done.
37563759
close(recvDoneOnServer)
3757-
// Block until the stream’s context is done (cancelled by client).
3760+
// Block until the stream’s context is done. Second call to client.SendMsg
3761+
// triggers a RST_STREAM which cancels the stream context on the server.
37583762
<-stream.Context().Done()
37593763
if err := stream.SendMsg(&testpb.StreamingOutputCallRequest{}); status.Code(err) != codes.Canceled {
37603764
t.Errorf("stream.SendMsg() = %v, want error %v", err, codes.Canceled)
@@ -3787,12 +3791,10 @@ func (s) TestServerStreaming_ClientCallSendMsgTwice(t *testing.T) {
37873791
t.Fatalf("cc.NewStream() failed unexpectedly: %v", err)
37883792
}
37893793

3790-
// First SendMsg sends EOF along with the message.
37913794
if err := stream.SendMsg(&testpb.Empty{}); err != nil {
37923795
t.Errorf("stream.SendMsg() = %v, want <nil>", err)
37933796
}
37943797

3795-
// To ensure that the server has read the first message before client triggers RST_STREAM.
37963798
<-recvDoneOnServer
37973799
if err := stream.SendMsg(&testpb.Empty{}); status.Code(err) != codes.Internal {
37983800
t.Errorf("stream.SendMsg() = %v, want error %v", err, codes.Internal)

0 commit comments

Comments
 (0)