diff options
author | Stan Hu <stanhu@gmail.com> | 2020-05-11 22:02:58 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2020-05-11 22:31:13 -0700 |
commit | 0372634076cdfd7cda740cd040e16e629ea662e4 (patch) | |
tree | 3b8c76cf68dcb9fa1c16d3aa370d0692a0800136 /internal/command | |
parent | 940aa912784b2e99d6f2a767f13bd013a62c94f8 (diff) | |
download | gitlab-shell-0372634076cdfd7cda740cd040e16e629ea662e4.tar.gz |
Fix race conditions with logrus testingsh-fix-logrus-race
logrus fires a Goroutine to write logs, so the tests could fail if they
checked the event queue before the logrus have fired. Since there isn't
an easy way to flush all outstanding hooks, we just retry every 100 ms
for up to a second for log to arrive in the queue.
Closes https://gitlab.com/gitlab-org/gitlab-shell/-/issues/450
Diffstat (limited to 'internal/command')
-rw-r--r-- | internal/command/receivepack/gitalycall_test.go | 1 | ||||
-rw-r--r-- | internal/command/uploadarchive/gitalycall_test.go | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/internal/command/receivepack/gitalycall_test.go b/internal/command/receivepack/gitalycall_test.go index fd062b2..0cfbf5c 100644 --- a/internal/command/receivepack/gitalycall_test.go +++ b/internal/command/receivepack/gitalycall_test.go @@ -43,6 +43,7 @@ func TestReceivePack(t *testing.T) { require.Equal(t, "ReceivePack: "+userId+" "+repo, output.String()) + require.True(t, testhelper.WaitForLogEvent(hook)) entries := hook.AllEntries() require.Equal(t, 2, len(entries)) require.Equal(t, logrus.InfoLevel, entries[1].Level) diff --git a/internal/command/uploadarchive/gitalycall_test.go b/internal/command/uploadarchive/gitalycall_test.go index 8b60e11..488c390 100644 --- a/internal/command/uploadarchive/gitalycall_test.go +++ b/internal/command/uploadarchive/gitalycall_test.go @@ -42,6 +42,8 @@ func TestUploadPack(t *testing.T) { require.NoError(t, err) require.Equal(t, "UploadArchive: "+repo, output.String()) + + require.True(t, testhelper.WaitForLogEvent(hook)) entries := hook.AllEntries() require.Equal(t, 2, len(entries)) require.Equal(t, logrus.InfoLevel, entries[1].Level) |