From d08e0fe0028a6b52d597e854bd467331d442cad9 Mon Sep 17 00:00:00 2001 From: Will Chandler Date: Fri, 23 Sep 2022 16:12:19 -0400 Subject: praefect: run track-repositories tests serially The `praefect` command has a global logger that is passed to any subcommands executed. When executing normally this is fine as each process will only run a single subcommand. However, in testing this creates a risk of race conditions when tests are run in parallel, as each test goroutine will share this logger. To resolve race detector failures on `TestAddRepositories_Exec()` and `TestAddRepositories_Exec()`, we will now run these tests serially. This has minimal impact on test execution time, increasing from 4.663s to 5.129s. In the medium-term we should replace the global logger with a local that allows parallel testing. Issue #4500[0] has been opened for this. [0] https://gitlab.com/gitlab-org/gitaly/-/issues/4500 --- cmd/praefect/subcmd_track_repositories_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/praefect/subcmd_track_repositories_test.go b/cmd/praefect/subcmd_track_repositories_test.go index c644f88d2..ed9737864 100644 --- a/cmd/praefect/subcmd_track_repositories_test.go +++ b/cmd/praefect/subcmd_track_repositories_test.go @@ -37,8 +37,9 @@ func TestAddRepositories_FlagSet(t *testing.T) { require.Equal(t, true, cmd.replicateImmediately) } +// Cannot be run with t.Parallel() due to races on global logger +// Cleanup tracked under https://gitlab.com/gitlab-org/gitaly/-/issues/4500 func TestAddRepositories_Exec_invalidInput(t *testing.T) { - t.Parallel() g1Cfg := testcfg.Build(t, testcfg.WithStorages("gitaly-1")) g2Cfg := testcfg.Build(t, testcfg.WithStorages("gitaly-2")) @@ -194,8 +195,9 @@ func TestAddRepositories_Exec_invalidInput(t *testing.T) { } } +// Cannot be run with t.Parallel() due to races on global logger +// Cleanup tracked under https://gitlab.com/gitlab-org/gitaly/-/issues/4500 func TestAddRepositories_Exec(t *testing.T) { - t.Parallel() g1Cfg := testcfg.Build(t, testcfg.WithStorages("gitaly-1")) g2Cfg := testcfg.Build(t, testcfg.WithStorages("gitaly-2")) testcfg.BuildGitalyHooks(t, g2Cfg) -- cgit v1.2.3