From 14105ff3015c889ebd822dec38a19841b90ad7ed Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Mon, 28 Apr 2025 12:20:07 -0500 Subject: [PATCH] test: do not run memory race test in parallel (#17582) Closes https://github.com/coder/internal/issues/597#issuecomment-2835262922 The parallelized tests share configs, which when accessed concurrently throw race errors. The configs are read only, so it is fine to run these tests with shared idp configs. --- coderd/idpsync/group_test.go | 10 ++++++---- coderd/idpsync/role_test.go | 7 +++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/coderd/idpsync/group_test.go b/coderd/idpsync/group_test.go index 4a892964a9..58024ed2f6 100644 --- a/coderd/idpsync/group_test.go +++ b/coderd/idpsync/group_test.go @@ -65,6 +65,7 @@ func TestParseGroupClaims(t *testing.T) { }) } +//nolint:paralleltest, tparallel func TestGroupSyncTable(t *testing.T) { t.Parallel() @@ -248,9 +249,11 @@ func TestGroupSyncTable(t *testing.T) { for _, tc := range testCases { tc := tc + // The final test, "AllTogether", cannot run in parallel. + // These tests are nearly instant using the memory db, so + // this is still fast without being in parallel. + //nolint:paralleltest, tparallel t.Run(tc.Name, func(t *testing.T) { - t.Parallel() - db, _ := dbtestutil.NewDB(t) manager := runtimeconfig.NewManager() s := idpsync.NewAGPLSync(slogtest.Make(t, &slogtest.Options{}), @@ -289,9 +292,8 @@ func TestGroupSyncTable(t *testing.T) { // deployment. This tests all organizations being synced together. // The reason we do them individually, is that it is much easier to // debug a single test case. + //nolint:paralleltest, tparallel // This should run after all the individual tests t.Run("AllTogether", func(t *testing.T) { - t.Parallel() - db, _ := dbtestutil.NewDB(t) manager := runtimeconfig.NewManager() s := idpsync.NewAGPLSync(slogtest.Make(t, &slogtest.Options{}), diff --git a/coderd/idpsync/role_test.go b/coderd/idpsync/role_test.go index d766ada605..f1cebc1884 100644 --- a/coderd/idpsync/role_test.go +++ b/coderd/idpsync/role_test.go @@ -23,6 +23,7 @@ import ( "github.com/coder/coder/v2/testutil" ) +//nolint:paralleltest, tparallel func TestRoleSyncTable(t *testing.T) { t.Parallel() @@ -190,9 +191,11 @@ func TestRoleSyncTable(t *testing.T) { for _, tc := range testCases { tc := tc + // The final test, "AllTogether", cannot run in parallel. + // These tests are nearly instant using the memory db, so + // this is still fast without being in parallel. + //nolint:paralleltest, tparallel t.Run(tc.Name, func(t *testing.T) { - t.Parallel() - db, _ := dbtestutil.NewDB(t) manager := runtimeconfig.NewManager() s := idpsync.NewAGPLSync(slogtest.Make(t, &slogtest.Options{