Skip to content

Commit 0b8658e

Browse files
committed
fixing flaky test
1 parent ccc8d7b commit 0b8658e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

test/end2end_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3960,7 +3960,22 @@ func (s) TestServerStreaming_ClientCallSendMsgTwice(t *testing.T) {
39603960
// Block until the stream’s context is done. Second call to client.SendMsg
39613961
// triggers a RST_STREAM which cancels the stream context on the server.
39623962
<-stream.Context().Done()
3963-
if err := stream.SendMsg(&testpb.StreamingOutputCallRequest{}); status.Code(err) != codes.Canceled {
3963+
var err error
3964+
waitCtx, cancel := context.WithTimeout(context.Background(), defaultTestShortTimeout)
3965+
defer cancel()
3966+
for {
3967+
err = stream.SendMsg(&testpb.StreamingOutputCallRequest{})
3968+
if err != nil {
3969+
break
3970+
}
3971+
select {
3972+
case <-waitCtx.Done():
3973+
t.Fatalf("timeout while waiting for stream.SendMsg() to return an error ")
3974+
default:
3975+
time.Sleep(10 * time.Millisecond)
3976+
}
3977+
}
3978+
if status.Code(err) != codes.Canceled {
39643979
t.Errorf("stream.SendMsg() = %v, want error %v", err, codes.Canceled)
39653980
}
39663981
close(handlerDone)

0 commit comments

Comments
 (0)