Commit 0b07d53e authored by Matthew Sykes's avatar Matthew Sykes
Browse files

[FAB-12870] fix timing flake in grpclogging tests



Ensure the client stream is setup before the server returns an error.

Change-Id: Id5062f2947d44588b32127afc913c36ff238f834
Signed-off-by: default avatarMatthew Sykes <sykesmat@us.ibm.com>
parent 11fa186a
......@@ -560,14 +560,18 @@ var _ = Describe("Server", func() {
var expectedErr error
BeforeEach(func() {
expectedErr = &statusError{Status: status.New(codes.Aborted, "aborted")}
fakeEchoService.EchoStreamReturns(expectedErr)
errCh := make(chan error)
fakeEchoService.EchoStreamStub = func(svr testpb.EchoService_EchoStreamServer) error { return <-errCh }
streamClient, err := echoServiceClient.EchoStream(context.Background())
Expect(err).NotTo(HaveOccurred())
err = streamClient.Send(&testpb.Message{Message: "hello"})
Expect(err).NotTo(HaveOccurred())
expectedErr = &statusError{Status: status.New(codes.Aborted, "aborted")}
errCh <- expectedErr
_, err = streamClient.Recv()
Expect(err).To(HaveOccurred())
})
......
......@@ -271,8 +271,11 @@ var _ = Describe("Interceptor", func() {
})
Context("when stream recv returns an error", func() {
var errCh chan error
BeforeEach(func() {
fakeEchoService.EchoStreamReturns(errors.New("oh bother"))
errCh = make(chan error)
fakeEchoService.EchoStreamStub = func(svs testpb.EchoService_EchoStreamServer) error { return <-errCh }
})
It("does not increment the update count", func() {
......@@ -281,8 +284,11 @@ var _ = Describe("Interceptor", func() {
err = streamClient.Send(&testpb.Message{Message: "hello"})
Expect(err).NotTo(HaveOccurred())
errCh <- errors.New("oh bother")
_, err = streamClient.Recv()
Expect(err).To(MatchError(grpc.Errorf(codes.Unknown, "oh bother")))
err = streamClient.CloseSend()
Expect(err).NotTo(HaveOccurred())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment