diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2021-02-15 19:01:39 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2021-02-17 11:37:11 +0300 |
commit | d18194f408c412e8041c8fb3b687ac0de66b62d3 (patch) | |
tree | 9a8a7650185a1bb7ecad0cc950d43d51113e3b74 /client | |
parent | 29dec5fdae0846da19f803058441581b43fda91d (diff) |
fix flaky test TestDial_Tracing/stream
This commit fixes TestDial_Tracing/stream which is flaking and failing
the pipeline every now and then.
The ordering of the items is indeterministic due to a race in finishing
two spans. The main test goroutine does not wait for the stream to close
but only receives a single message. Once that message is received, both
the main test goroutine and the stream handler race to finish their spans.
This commit fixes the situation by making the main test goroutine wait for
the stream to close and only then finishing its span.
Diffstat (limited to 'client')
-rw-r--r-- | client/dial_test.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/client/dial_test.go b/client/dial_test.go index b1ca61c93..b5f3fc6c8 100644 --- a/client/dial_test.go +++ b/client/dial_test.go @@ -4,6 +4,7 @@ import ( "context" "crypto/tls" "fmt" + "io" "net" "os" "path/filepath" @@ -269,9 +270,7 @@ func TestDial_Tracing(t *testing.T) { span, _ := opentracing.StartSpanFromContext(stream.Context(), "nested-span") defer span.Finish() span.LogKV("was", "called") - _, err := stream.Recv() - require.NoError(t, err) - return stream.Send(&proxytestdata.PingResponse{}) + return nil }, } proxytestdata.RegisterTestServiceServer(grpcServer, svc) @@ -363,10 +362,10 @@ func TestDial_Tracing(t *testing.T) { // This should create a span that's nested into the "stream-check" span. stream, err := proxytestdata.NewTestServiceClient(cc).PingStream(ctx) require.NoError(t, err) - require.NoError(t, stream.Send(&proxytestdata.PingRequest{})) require.NoError(t, stream.CloseSend()) - _, err = stream.Recv() - require.NoError(t, err) + resp, err := stream.Recv() + require.Equal(t, err, io.EOF) + require.Nil(t, resp) span.Finish() tracerCloser.Close() |