Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorSami Hiltunen <shiltunen@gitlab.com>2021-02-18 18:06:23 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2021-02-18 18:16:44 +0300
commitb1278dca25ed18f897e088e8860eeff18ba5ee04 (patch)
tree0a9c5a723de4e211714966173754ea56ddb6e65b /client
parent205a8f5e815d194188f32e150ecde56ffc0ac7a4 (diff)
fix TestDial_Tracing/stream flaking
There was a previous attempt at synchronizing the test by waiting for the server to close the stream. There is another race in the test as well though. The client first sends the stream close to the server and then goes off to finish the client span. If the server receives the client stream closing before the client managed to finish its span, the server will race finishing its 'nested span' with the client's '/mwitkow.testproto/TestService/PingStream' span. This commit fixes the race by synchronizing the server's stream handler to only proceed after the client has returned from the CloseSend method.
Diffstat (limited to 'client')
-rw-r--r--client/dial_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/client/dial_test.go b/client/dial_test.go
index b5f3fc6c8..b9a1dabe2 100644
--- a/client/dial_test.go
+++ b/client/dial_test.go
@@ -252,6 +252,8 @@ func TestDial_Tracing(t *testing.T) {
listener, err := net.Listen("unix", serverSocketPath)
require.NoError(t, err)
+ clientSendClosed := make(chan struct{})
+
// This is our test service. All it does is to create additional spans
// which should in the end be visible when collecting all registered
// spans.
@@ -267,6 +269,14 @@ func TestDial_Tracing(t *testing.T) {
return &proxytestdata.PingResponse{}, nil
},
PingStreamMethod: func(stream proxytestdata.TestService_PingStreamServer) error {
+ // synchronize the client has returned from CloseSend as the client span finishing
+ // races with sending the stream close to the server
+ select {
+ case <-clientSendClosed:
+ case <-stream.Context().Done():
+ return stream.Context().Err()
+ }
+
span, _ := opentracing.StartSpanFromContext(stream.Context(), "nested-span")
defer span.Finish()
span.LogKV("was", "called")
@@ -363,6 +373,9 @@ func TestDial_Tracing(t *testing.T) {
stream, err := proxytestdata.NewTestServiceClient(cc).PingStream(ctx)
require.NoError(t, err)
require.NoError(t, stream.CloseSend())
+ close(clientSendClosed)
+
+ // wait for the server to finish its spans and close the stream
resp, err := stream.Recv()
require.Equal(t, err, io.EOF)
require.Nil(t, resp)