diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-10-10 13:01:02 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-10-14 13:44:54 +0300 |
commit | 1881ab188e2789715ad1307fb1748d6c14e72474 (patch) | |
tree | 5b89a52a44d9e7390208d2f233433dec8629fac4 | |
parent | 7d88809fa9bac82129b76e472f80e917eb0e3806 (diff) |
global: Reorder `testing.TB` before `context.Context` arguments
A few weeks ago we have decided that `testing.TB` arguments should be
first, `context.Context` second. This is rather a matter of perssnal
taste instead of correctness, but we should strive for consistency.
Reorder all arguments to match the agreed-upon style.
213 files changed, 973 insertions, 973 deletions
diff --git a/cmd/gitaly-backup/create_test.go b/cmd/gitaly-backup/create_test.go index 324afdaad..370291bb6 100644 --- a/cmd/gitaly-backup/create_test.go +++ b/cmd/gitaly-backup/create_test.go @@ -30,7 +30,7 @@ func TestCreateSubcommand(t *testing.T) { var repos []*gitalypb.Repository for i := 0; i < 5; i++ { - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, RelativePath: fmt.Sprintf("repo-%d", i), }) diff --git a/cmd/gitaly-backup/restore_test.go b/cmd/gitaly-backup/restore_test.go index 5e3b0ae0d..c828ad3c3 100644 --- a/cmd/gitaly-backup/restore_test.go +++ b/cmd/gitaly-backup/restore_test.go @@ -29,7 +29,7 @@ func TestRestoreSubcommand(t *testing.T) { cfg.SocketPath = testserver.RunGitalyServer(t, cfg, nil, setup.RegisterAll) - existingRepo, existRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + existingRepo, existRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, RelativePath: "existing_repo", }) @@ -76,7 +76,7 @@ func TestRestoreSubcommand(t *testing.T) { "restore: pipeline: 1 failures encountered:\n - invalid: manager: remove repository: could not dial source: invalid connection string: \"invalid\"\n") for _, repo := range repos { - repoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(ctx, t, cfg, repo)) + repoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(t, ctx, cfg, repo)) bundlePath := filepath.Join(path, repo.RelativePath+".bundle") output := gittest.Exec(t, cfg, "-C", repoPath, "bundle", "verify", bundlePath) diff --git a/cmd/gitaly-git2go/merge_test.go b/cmd/gitaly-git2go/merge_test.go index 123b8cca6..00cc5549f 100644 --- a/cmd/gitaly-git2go/merge_test.go +++ b/cmd/gitaly-git2go/merge_test.go @@ -418,7 +418,7 @@ func TestMerge_recursive(t *testing.T) { testcfg.BuildGitalyGit2Go(t, cfg) executor := buildExecutor(t, cfg) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) diff --git a/cmd/gitaly-hooks/hooks_test.go b/cmd/gitaly-hooks/hooks_test.go index b5479123c..f2549e6aa 100644 --- a/cmd/gitaly-hooks/hooks_test.go +++ b/cmd/gitaly-hooks/hooks_test.go @@ -273,7 +273,7 @@ func TestHooksUpdate(t *testing.T) { } func testHooksUpdate(t *testing.T, ctx context.Context, cfg config.Cfg, glValues glHookValues) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) diff --git a/cmd/praefect/subcmd_list_untracked_repositories_test.go b/cmd/praefect/subcmd_list_untracked_repositories_test.go index 71180d856..690df12d6 100644 --- a/cmd/praefect/subcmd_list_untracked_repositories_test.go +++ b/cmd/praefect/subcmd_list_untracked_repositories_test.go @@ -95,13 +95,13 @@ func TestListUntrackedRepositories_Exec(t *testing.T) { require.NoError(t, fs.Parse([]string{"-older-than", "4h"})) // Repositories not managed by praefect. - repo1, repo1Path := gittest.CreateRepository(ctx, t, g1Cfg, gittest.CreateRepositoryConfig{ + repo1, repo1Path := gittest.CreateRepository(t, ctx, g1Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) - repo2, repo2Path := gittest.CreateRepository(ctx, t, g1Cfg, gittest.CreateRepositoryConfig{ + repo2, repo2Path := gittest.CreateRepository(t, ctx, g1Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) - _, _ = gittest.CreateRepository(ctx, t, g2Cfg, gittest.CreateRepositoryConfig{ + _, _ = gittest.CreateRepository(t, ctx, g2Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) diff --git a/cmd/praefect/subcmd_remove_repository_test.go b/cmd/praefect/subcmd_remove_repository_test.go index e42bde82e..57c6d1bed 100644 --- a/cmd/praefect/subcmd_remove_repository_test.go +++ b/cmd/praefect/subcmd_remove_repository_test.go @@ -120,7 +120,7 @@ func TestRemoveRepository_Exec(t *testing.T) { t.Run("dry run", func(t *testing.T) { var out bytes.Buffer repo := createRepo(t, ctx, repoClient, praefectStorage, t.Name()) - replicaPath := gittest.GetReplicaPath(ctx, t, gitalycfg.Cfg{SocketPath: praefectServer.Address()}, repo) + replicaPath := gittest.GetReplicaPath(t, ctx, gitalycfg.Cfg{SocketPath: praefectServer.Address()}, repo) cmd := &removeRepository{ logger: testhelper.NewDiscardingLogger(t), @@ -143,7 +143,7 @@ func TestRemoveRepository_Exec(t *testing.T) { t.Run("ok", func(t *testing.T) { var out bytes.Buffer repo := createRepo(t, ctx, repoClient, praefectStorage, t.Name()) - replicaPath := gittest.GetReplicaPath(ctx, t, gitalycfg.Cfg{SocketPath: praefectServer.Address()}, repo) + replicaPath := gittest.GetReplicaPath(t, ctx, gitalycfg.Cfg{SocketPath: praefectServer.Address()}, repo) require.DirExists(t, filepath.Join(g1Cfg.Storages[0].Path, replicaPath)) require.DirExists(t, filepath.Join(g2Cfg.Storages[0].Path, replicaPath)) @@ -169,7 +169,7 @@ func TestRemoveRepository_Exec(t *testing.T) { t.Run("db only", func(t *testing.T) { var out bytes.Buffer repo := createRepo(t, ctx, repoClient, praefectStorage, t.Name()) - replicaPath := gittest.GetReplicaPath(ctx, t, gitalycfg.Cfg{SocketPath: praefectServer.Address()}, repo) + replicaPath := gittest.GetReplicaPath(t, ctx, gitalycfg.Cfg{SocketPath: praefectServer.Address()}, repo) cmd := &removeRepository{ logger: testhelper.NewDiscardingLogger(t), @@ -197,7 +197,7 @@ func TestRemoveRepository_Exec(t *testing.T) { t.Run("repository doesnt exist on one gitaly", func(t *testing.T) { var out bytes.Buffer repo := createRepo(t, ctx, repoClient, praefectStorage, t.Name()) - replicaPath := gittest.GetReplicaPath(ctx, t, gitalycfg.Cfg{SocketPath: praefectServer.Address()}, repo) + replicaPath := gittest.GetReplicaPath(t, ctx, gitalycfg.Cfg{SocketPath: praefectServer.Address()}, repo) require.DirExists(t, filepath.Join(g2Cfg.Storages[0].Path, replicaPath)) require.DirExists(t, filepath.Join(g1Cfg.Storages[0].Path, replicaPath)) @@ -225,7 +225,7 @@ func TestRemoveRepository_Exec(t *testing.T) { t.Run("no info about repository on praefect", func(t *testing.T) { var out bytes.Buffer repo := createRepo(t, ctx, repoClient, praefectStorage, t.Name()) - replicaPath := gittest.GetReplicaPath(ctx, t, gitalycfg.Cfg{SocketPath: praefectServer.Address()}, repo) + replicaPath := gittest.GetReplicaPath(t, ctx, gitalycfg.Cfg{SocketPath: praefectServer.Address()}, repo) repoStore := datastore.NewPostgresRepositoryStore(db.DB, nil) _, _, err = repoStore.DeleteRepository(ctx, repo.StorageName, repo.RelativePath) @@ -251,7 +251,7 @@ func TestRemoveRepository_Exec(t *testing.T) { repo := createRepo(t, ctx, repoClient, praefectStorage, t.Name()) g2Srv.Shutdown() - replicaPath := gittest.GetReplicaPath(ctx, t, gitalycfg.Cfg{SocketPath: praefectServer.Address()}, repo) + replicaPath := gittest.GetReplicaPath(t, ctx, gitalycfg.Cfg{SocketPath: praefectServer.Address()}, repo) require.DirExists(t, filepath.Join(g1Cfg.Storages[0].Path, replicaPath)) require.DirExists(t, filepath.Join(g2Cfg.Storages[0].Path, replicaPath)) diff --git a/internal/backup/backup_test.go b/internal/backup/backup_test.go index d66fa6902..05a57eb26 100644 --- a/internal/backup/backup_test.go +++ b/internal/backup/backup_test.go @@ -44,7 +44,7 @@ func TestManager_Create(t *testing.T) { { desc: "no hooks", setup: func(tb testing.TB) (*gitalypb.Repository, string) { - noHooksRepo, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + noHooksRepo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ RelativePath: "no-hooks", Seed: gittest.SeedGitLabTest, }) @@ -56,7 +56,7 @@ func TestManager_Create(t *testing.T) { { desc: "hooks", setup: func(tb testing.TB) (*gitalypb.Repository, string) { - hooksRepo, hooksRepoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + hooksRepo, hooksRepoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ RelativePath: "hooks", Seed: gittest.SeedGitLabTest, }) @@ -70,7 +70,7 @@ func TestManager_Create(t *testing.T) { { desc: "empty repo", setup: func(tb testing.TB) (*gitalypb.Repository, string) { - emptyRepo, repoPath := gittest.CreateRepository(ctx, tb, cfg) + emptyRepo, repoPath := gittest.CreateRepository(tb, ctx, cfg) return emptyRepo, repoPath }, createsBundle: false, @@ -80,7 +80,7 @@ func TestManager_Create(t *testing.T) { { desc: "nonexistent repo", setup: func(tb testing.TB) (*gitalypb.Repository, string) { - emptyRepo, repoPath := gittest.CreateRepository(ctx, tb, cfg) + emptyRepo, repoPath := gittest.CreateRepository(tb, ctx, cfg) nonexistentRepo := proto.Clone(emptyRepo).(*gitalypb.Repository) nonexistentRepo.RelativePath = "nonexistent" return nonexistentRepo, repoPath @@ -165,7 +165,7 @@ func TestManager_Create_incremental(t *testing.T) { { desc: "no previous backup", setup: func(tb testing.TB, backupRoot string) (*gitalypb.Repository, string) { - repo, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ RelativePath: "repo", Seed: gittest.SeedGitLabTest, }) @@ -176,7 +176,7 @@ func TestManager_Create_incremental(t *testing.T) { { desc: "previous backup, no updates", setup: func(tb testing.TB, backupRoot string) (*gitalypb.Repository, string) { - repo, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ RelativePath: "repo", Seed: gittest.SeedGitLabTest, }) @@ -202,7 +202,7 @@ func TestManager_Create_incremental(t *testing.T) { { desc: "previous backup, updates", setup: func(tb testing.TB, backupRoot string) (*gitalypb.Repository, string) { - repo, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ RelativePath: "repo", Seed: gittest.SeedGitLabTest, }) @@ -298,12 +298,12 @@ func testManagerRestore(t *testing.T, ctx context.Context) { // The repository might be created through Praefect and the tests reach into the repository directly // on the filesystem. To ensure the test accesses correct directory, we need to rewrite the relative // path if the repository creation went through Praefect. - repo.RelativePath = gittest.GetReplicaPath(ctx, tb, cfg, repo) + repo.RelativePath = gittest.GetReplicaPath(tb, ctx, cfg, repo) return repo } - _, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) repoChecksum := gittest.ChecksumRepo(t, cfg, repoPath) @@ -509,7 +509,7 @@ func testManagerRestore(t *testing.T, ctx context.Context) { // Restore has to use the rewritten path as the relative path due to the test creating // the repository through Praefect. In order to get to the correct disk paths, we need // to get the replica path of the rewritten repository. - repoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(ctx, t, cfg, repo)) + repoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(t, ctx, cfg, repo)) for _, p := range tc.expectedPaths { require.FileExists(t, filepath.Join(repoPath, p)) } diff --git a/internal/cache/diskcache_test.go b/internal/cache/diskcache_test.go index b33ad8648..d4687fe25 100644 --- a/internal/cache/diskcache_test.go +++ b/internal/cache/diskcache_test.go @@ -50,11 +50,11 @@ func TestStreamDBNaiveKeyer(t *testing.T) { ctx := testhelper.Context(t) ctx = testhelper.SetCtxGrpcMethod(ctx, "InfoRefsUploadPack") - repo1, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo1, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, }) - repo2, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo2, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, }) diff --git a/internal/git/catfile/cache_test.go b/internal/git/catfile/cache_test.go index 89bbec75a..b6c4f544d 100644 --- a/internal/git/catfile/cache_test.go +++ b/internal/git/catfile/cache_test.go @@ -26,7 +26,7 @@ func TestProcesses_add(t *testing.T) { p := &processes{maxLen: maxLen} cfg := testcfg.Build(t) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -63,7 +63,7 @@ func TestProcesses_addTwice(t *testing.T) { p := &processes{maxLen: 10} cfg := testcfg.Build(t) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -95,7 +95,7 @@ func TestProcesses_Checkout(t *testing.T) { p := &processes{maxLen: 10} cfg := testcfg.Build(t) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -127,7 +127,7 @@ func TestProcesses_EnforceTTL(t *testing.T) { p := &processes{maxLen: 10} cfg := testcfg.Build(t) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -177,7 +177,7 @@ func TestCache_autoExpiry(t *testing.T) { defer c.Stop() cfg := testcfg.Build(t) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -206,7 +206,7 @@ func TestCache_ObjectReader(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) @@ -306,7 +306,7 @@ func TestCache_ObjectInfoReader(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) diff --git a/internal/git/catfile/object_info_reader_test.go b/internal/git/catfile/object_info_reader_test.go index 25d784bb7..761b8a81e 100644 --- a/internal/git/catfile/object_info_reader_test.go +++ b/internal/git/catfile/object_info_reader_test.go @@ -108,7 +108,7 @@ func TestObjectInfoReader(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -212,7 +212,7 @@ func TestObjectInfoReader_queue(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) diff --git a/internal/git/catfile/object_reader_test.go b/internal/git/catfile/object_reader_test.go index 83b3a46d0..32326f07f 100644 --- a/internal/git/catfile/object_reader_test.go +++ b/internal/git/catfile/object_reader_test.go @@ -21,7 +21,7 @@ func TestObjectReader_reader(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -133,7 +133,7 @@ func TestObjectReader_queue(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -433,7 +433,7 @@ func TestObjectReader_replaceRefs(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) diff --git a/internal/git/catfile/request_queue_test.go b/internal/git/catfile/request_queue_test.go index 59f71e154..8780e1065 100644 --- a/internal/git/catfile/request_queue_test.go +++ b/internal/git/catfile/request_queue_test.go @@ -23,7 +23,7 @@ func TestRequestQueue_ReadObject(t *testing.T) { oid := git.ObjectID(strings.Repeat("1", gittest.DefaultObjectHash.EncodedLen())) t.Run("ReadInfo on ReadObject queue", func(t *testing.T) { - _, queue := newInterceptedQueue(ctx, t, "#!/bin/sh\nread\n") + _, queue := newInterceptedQueue(t, ctx, "#!/bin/sh\nread\n") require.PanicsWithValue(t, "object queue used to read object info", func() { _, _ = queue.ReadInfo() @@ -31,13 +31,13 @@ func TestRequestQueue_ReadObject(t *testing.T) { }) t.Run("read without request", func(t *testing.T) { - _, queue := newInterceptedQueue(ctx, t, "#!/bin/sh\nread\n") + _, queue := newInterceptedQueue(t, ctx, "#!/bin/sh\nread\n") _, err := queue.ReadObject() require.Equal(t, fmt.Errorf("no outstanding request"), err) }) t.Run("read on closed reader", func(t *testing.T) { - reader, queue := newInterceptedQueue(ctx, t, "#!/bin/sh\nread\n") + reader, queue := newInterceptedQueue(t, ctx, "#!/bin/sh\nread\n") require.NoError(t, queue.RequestRevision("foo")) require.True(t, queue.isDirty()) @@ -50,7 +50,7 @@ func TestRequestQueue_ReadObject(t *testing.T) { }) t.Run("read with unconsumed object", func(t *testing.T) { - _, queue := newInterceptedQueue(ctx, t, fmt.Sprintf(`#!/bin/sh + _, queue := newInterceptedQueue(t, ctx, fmt.Sprintf(`#!/bin/sh echo "%s commit 464" `, oid)) @@ -70,7 +70,7 @@ func TestRequestQueue_ReadObject(t *testing.T) { }) t.Run("read with invalid object header", func(t *testing.T) { - _, queue := newInterceptedQueue(ctx, t, `#!/bin/sh + _, queue := newInterceptedQueue(t, ctx, `#!/bin/sh echo "something something" `) @@ -84,7 +84,7 @@ func TestRequestQueue_ReadObject(t *testing.T) { }) t.Run("read with unexpected exit", func(t *testing.T) { - _, queue := newInterceptedQueue(ctx, t, `#!/bin/sh + _, queue := newInterceptedQueue(t, ctx, `#!/bin/sh exit 1 `) @@ -98,7 +98,7 @@ func TestRequestQueue_ReadObject(t *testing.T) { }) t.Run("read with missing object", func(t *testing.T) { - _, queue := newInterceptedQueue(ctx, t, fmt.Sprintf(`#!/bin/sh + _, queue := newInterceptedQueue(t, ctx, fmt.Sprintf(`#!/bin/sh echo "%s missing" `, oid)) @@ -113,7 +113,7 @@ func TestRequestQueue_ReadObject(t *testing.T) { }) t.Run("read single object", func(t *testing.T) { - _, queue := newInterceptedQueue(ctx, t, fmt.Sprintf(`#!/bin/sh + _, queue := newInterceptedQueue(t, ctx, fmt.Sprintf(`#!/bin/sh echo "%s blob 10" echo "1234567890" `, oid)) @@ -139,7 +139,7 @@ func TestRequestQueue_ReadObject(t *testing.T) { t.Run("read multiple objects", func(t *testing.T) { secondOID := git.ObjectID(strings.Repeat("2", gittest.DefaultObjectHash.EncodedLen())) - _, queue := newInterceptedQueue(ctx, t, fmt.Sprintf(`#!/bin/sh + _, queue := newInterceptedQueue(t, ctx, fmt.Sprintf(`#!/bin/sh echo "%s blob 10" echo "1234567890" echo "%s commit 10" @@ -186,7 +186,7 @@ func TestRequestQueue_ReadObject(t *testing.T) { }) t.Run("truncated object", func(t *testing.T) { - _, queue := newInterceptedQueue(ctx, t, fmt.Sprintf(`#!/bin/sh + _, queue := newInterceptedQueue(t, ctx, fmt.Sprintf(`#!/bin/sh echo "%s blob 10" printf "123" `, oid)) @@ -236,14 +236,14 @@ func TestRequestQueue_RequestRevision(t *testing.T) { } t.Run("requesting revision on closed queue", func(t *testing.T) { - _, queue := newInterceptedQueue(ctx, t, "#!/bin/sh") + _, queue := newInterceptedQueue(t, ctx, "#!/bin/sh") queue.close() require.Equal(t, fmt.Errorf("cannot request revision: %w", os.ErrClosed), queue.RequestRevision("foo")) }) t.Run("requesting revision on closed process", func(t *testing.T) { - process, queue := newInterceptedQueue(ctx, t, "#!/bin/sh") + process, queue := newInterceptedQueue(t, ctx, "#!/bin/sh") process.close() @@ -251,7 +251,7 @@ func TestRequestQueue_RequestRevision(t *testing.T) { }) t.Run("single request", func(t *testing.T) { - _, queue := newInterceptedQueue(ctx, t, fmt.Sprintf(`#!/bin/sh + _, queue := newInterceptedQueue(t, ctx, fmt.Sprintf(`#!/bin/sh read revision echo "%s blob ${#revision}" echo "${revision}" @@ -264,7 +264,7 @@ func TestRequestQueue_RequestRevision(t *testing.T) { }) t.Run("multiple request", func(t *testing.T) { - _, queue := newInterceptedQueue(ctx, t, fmt.Sprintf(`#!/bin/sh + _, queue := newInterceptedQueue(t, ctx, fmt.Sprintf(`#!/bin/sh while read revision do echo "%s blob ${#revision}" @@ -285,7 +285,7 @@ func TestRequestQueue_RequestRevision(t *testing.T) { }) t.Run("multiple request with intermediate flushing", func(t *testing.T) { - _, queue := newInterceptedQueue(ctx, t, fmt.Sprintf(`#!/bin/sh + _, queue := newInterceptedQueue(t, ctx, fmt.Sprintf(`#!/bin/sh while read revision do read flush @@ -313,13 +313,13 @@ func TestRequestQueue_RequestRevision(t *testing.T) { }) } -func newInterceptedQueue(ctx context.Context, t *testing.T, script string) (ObjectReader, *requestQueue) { +func newInterceptedQueue(t *testing.T, ctx context.Context, script string) (ObjectReader, *requestQueue) { cfg := testcfg.Build(t) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) - commandFactory := gittest.NewInterceptingCommandFactory(ctx, t, cfg, func(execEnv git.ExecutionEnvironment) string { + commandFactory := gittest.NewInterceptingCommandFactory(t, ctx, cfg, func(execEnv git.ExecutionEnvironment) string { return script }) repoExecutor := repoExecutor{ diff --git a/internal/git/catfile/testhelper_test.go b/internal/git/catfile/testhelper_test.go index 8d7e036a0..430d24088 100644 --- a/internal/git/catfile/testhelper_test.go +++ b/internal/git/catfile/testhelper_test.go @@ -59,7 +59,7 @@ func setupObjectReader(t *testing.T, ctx context.Context) (config.Cfg, ObjectRea t.Helper() cfg := testcfg.Build(t) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repoExecutor := newRepoExecutor(t, cfg, repo) diff --git a/internal/git/command_factory_test.go b/internal/git/command_factory_test.go index c0af1134b..8fe81d876 100644 --- a/internal/git/command_factory_test.go +++ b/internal/git/command_factory_test.go @@ -409,7 +409,7 @@ func TestExecCommandFactory_GitVersion(t *testing.T) { } { t.Run(tc.desc, func(t *testing.T) { gitCmdFactory := gittest.NewInterceptingCommandFactory( - ctx, t, testcfg.Build(t), generateVersionScript(tc.versionString), + t, ctx, testcfg.Build(t), generateVersionScript(tc.versionString), gittest.WithRealCommandFactoryOptions(git.WithSkipHooks()), gittest.WithInterceptedVersion(), ) @@ -426,7 +426,7 @@ func TestExecCommandFactory_GitVersion(t *testing.T) { t.Run("caching", func(t *testing.T) { gitCmdFactory := gittest.NewInterceptingCommandFactory( - ctx, t, testcfg.Build(t), generateVersionScript("git version 1.2.3"), + t, ctx, testcfg.Build(t), generateVersionScript("git version 1.2.3"), gittest.WithRealCommandFactoryOptions(git.WithSkipHooks()), gittest.WithInterceptedVersion(), ) @@ -476,7 +476,7 @@ func TestExecCommandFactory_config(t *testing.T) { // Create a repository and remove its gitconfig to bring us into a known state where there // is no repo-level configuration that interferes with our test. - repo, repoDir := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoDir := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) require.NoError(t, os.Remove(filepath.Join(repoDir, "config"))) @@ -505,7 +505,7 @@ func TestExecCommandFactory_config(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - factory := gittest.NewInterceptingCommandFactory(ctx, t, cfg, func(execEnv git.ExecutionEnvironment) string { + factory := gittest.NewInterceptingCommandFactory(t, ctx, cfg, func(execEnv git.ExecutionEnvironment) string { return fmt.Sprintf( `#!/usr/bin/env bash if test "$1" = "version" @@ -575,7 +575,7 @@ func TestExecCommandFactory_SidecarGitConfiguration(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - factory := gittest.NewInterceptingCommandFactory(ctx, t, cfg, func(git.ExecutionEnvironment) string { + factory := gittest.NewInterceptingCommandFactory(t, ctx, cfg, func(git.ExecutionEnvironment) string { return fmt.Sprintf( `#!/usr/bin/env bash echo "git version %s" @@ -632,7 +632,7 @@ func TestFsckConfiguration(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{SkipCreationViaService: true}, ) diff --git a/internal/git/decoder_test.go b/internal/git/decoder_test.go index 34073658e..6b5acfd79 100644 --- a/internal/git/decoder_test.go +++ b/internal/git/decoder_test.go @@ -19,7 +19,7 @@ func TestShowRefDecoder(t *testing.T) { cfg := testcfg.Build(t) ctx := testhelper.Context(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: "repo.git", diff --git a/internal/git/gitpipe/catfile_info_test.go b/internal/git/gitpipe/catfile_info_test.go index 317c93ba3..146f25be2 100644 --- a/internal/git/gitpipe/catfile_info_test.go +++ b/internal/git/gitpipe/catfile_info_test.go @@ -22,7 +22,7 @@ func TestCatfileInfo(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -286,7 +286,7 @@ func TestCatfileInfoAllObjects(t *testing.T) { cfg := testcfg.Build(t) ctx := testhelper.Context(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -342,7 +342,7 @@ func TestCatfileInfo_WithDiskUsageSize(t *testing.T) { cfg := testcfg.Build(t) ctx := testhelper.Context(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) diff --git a/internal/git/gitpipe/catfile_object_test.go b/internal/git/gitpipe/catfile_object_test.go index fe4f5d319..6a7c21d67 100644 --- a/internal/git/gitpipe/catfile_object_test.go +++ b/internal/git/gitpipe/catfile_object_test.go @@ -23,7 +23,7 @@ func TestCatfileObject(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) diff --git a/internal/git/gitpipe/diff_tree_test.go b/internal/git/gitpipe/diff_tree_test.go index ca29d509a..616fb8291 100644 --- a/internal/git/gitpipe/diff_tree_test.go +++ b/internal/git/gitpipe/diff_tree_test.go @@ -206,7 +206,7 @@ func TestDiffTree(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) diff --git a/internal/git/gitpipe/ls_tree_test.go b/internal/git/gitpipe/ls_tree_test.go index 82e6314d1..52984a4d1 100644 --- a/internal/git/gitpipe/ls_tree_test.go +++ b/internal/git/gitpipe/ls_tree_test.go @@ -185,7 +185,7 @@ func TestLsTree(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) diff --git a/internal/git/gitpipe/pipeline_test.go b/internal/git/gitpipe/pipeline_test.go index 2af0f0496..cf9fcde9e 100644 --- a/internal/git/gitpipe/pipeline_test.go +++ b/internal/git/gitpipe/pipeline_test.go @@ -22,7 +22,7 @@ func TestPipeline_revlist(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -391,7 +391,7 @@ func TestPipeline_forEachRef(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) diff --git a/internal/git/gitpipe/revision_test.go b/internal/git/gitpipe/revision_test.go index 723f1316b..c38f8606e 100644 --- a/internal/git/gitpipe/revision_test.go +++ b/internal/git/gitpipe/revision_test.go @@ -22,7 +22,7 @@ func TestRevlist(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -543,7 +543,7 @@ func TestForEachRef(t *testing.T) { } cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -716,7 +716,7 @@ func TestForEachRef_options(t *testing.T) { } { cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) diff --git a/internal/git/gittest/http_server.go b/internal/git/gittest/http_server.go index a0ac490f3..eb78dcade 100644 --- a/internal/git/gittest/http_server.go +++ b/internal/git/gittest/http_server.go @@ -17,7 +17,7 @@ import ( // HTTPServer starts an HTTP server with git-http-backend(1) as CGI handler. The repository is // prepared such that git-http-backend(1) will serve it by creating the "git-daemon-export-ok" magic // file. -func HTTPServer(ctx context.Context, tb testing.TB, gitCmdFactory git.CommandFactory, repoPath string, middleware func(http.ResponseWriter, *http.Request, http.Handler)) (int, func() error) { +func HTTPServer(tb testing.TB, ctx context.Context, gitCmdFactory git.CommandFactory, repoPath string, middleware func(http.ResponseWriter, *http.Request, http.Handler)) (int, func() error) { require.NoError(tb, os.WriteFile(filepath.Join(repoPath, "git-daemon-export-ok"), nil, 0o644)) listener, err := net.Listen("tcp", "127.0.0.1:0") diff --git a/internal/git/gittest/intercepting_command_factory.go b/internal/git/gittest/intercepting_command_factory.go index 6c1894fa4..dd9cc5e46 100644 --- a/internal/git/gittest/intercepting_command_factory.go +++ b/internal/git/gittest/intercepting_command_factory.go @@ -54,8 +54,8 @@ func WithInterceptedVersion() InterceptingCommandFactoryOption { // generate the script and receives as input the Git execution environment pointing to the real Git // binary. func NewInterceptingCommandFactory( - ctx context.Context, tb testing.TB, + ctx context.Context, cfg config.Cfg, generateScript func(git.ExecutionEnvironment) string, opts ...InterceptingCommandFactoryOption, diff --git a/internal/git/gittest/intercepting_command_factory_test.go b/internal/git/gittest/intercepting_command_factory_test.go index d93f68afc..b6f332dbc 100644 --- a/internal/git/gittest/intercepting_command_factory_test.go +++ b/internal/git/gittest/intercepting_command_factory_test.go @@ -14,7 +14,7 @@ func TestInterceptingCommandFactory(t *testing.T) { cfg, repoProto, repoPath := setup(t) ctx := testhelper.Context(t) - factory := NewInterceptingCommandFactory(ctx, t, cfg, func(execEnv git.ExecutionEnvironment) string { + factory := NewInterceptingCommandFactory(t, ctx, cfg, func(execEnv git.ExecutionEnvironment) string { return fmt.Sprintf( `#!/usr/bin/env bash %q rev-parse --sq-quote 'Hello, world!' @@ -79,7 +79,7 @@ func TestInterceptingCommandFactory_GitVersion(t *testing.T) { // Furthermore, we need to obtain the intercepted version here because we cannot construct // `git.Version` structs ourselves. - fakeVersion, err := NewInterceptingCommandFactory(ctx, t, cfg, generateVersionScript, WithInterceptedVersion()).GitVersion(ctx) + fakeVersion, err := NewInterceptingCommandFactory(t, ctx, cfg, generateVersionScript, WithInterceptedVersion()).GitVersion(ctx) require.NoError(t, err) require.Equal(t, "1.2.3", fakeVersion.String()) @@ -101,7 +101,7 @@ func TestInterceptingCommandFactory_GitVersion(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - factory := NewInterceptingCommandFactory(ctx, t, cfg, generateVersionScript, tc.opts...) + factory := NewInterceptingCommandFactory(t, ctx, cfg, generateVersionScript, tc.opts...) version, err := factory.GitVersion(ctx) require.NoError(t, err) diff --git a/internal/git/gittest/protocol.go b/internal/git/gittest/protocol.go index a47f33ec1..cfee5ded0 100644 --- a/internal/git/gittest/protocol.go +++ b/internal/git/gittest/protocol.go @@ -21,10 +21,10 @@ type ProtocolDetectingCommandFactory struct { } // NewProtocolDetectingCommandFactory returns a new ProtocolDetectingCommandFactory. -func NewProtocolDetectingCommandFactory(ctx context.Context, tb testing.TB, cfg config.Cfg) ProtocolDetectingCommandFactory { +func NewProtocolDetectingCommandFactory(tb testing.TB, ctx context.Context, cfg config.Cfg) ProtocolDetectingCommandFactory { envPath := filepath.Join(testhelper.TempDir(tb), "git-env") - gitCmdFactory := NewInterceptingCommandFactory(ctx, tb, cfg, func(execEnv git.ExecutionEnvironment) string { + gitCmdFactory := NewInterceptingCommandFactory(tb, ctx, cfg, func(execEnv git.ExecutionEnvironment) string { return fmt.Sprintf( `#!/usr/bin/env bash env | grep ^GIT_PROTOCOL= >>%q diff --git a/internal/git/gittest/repo.go b/internal/git/gittest/repo.go index 6022f1e6b..c5d517ffa 100644 --- a/internal/git/gittest/repo.go +++ b/internal/git/gittest/repo.go @@ -104,7 +104,7 @@ type CreateRepositoryConfig struct { ObjectFormat string } -func dialService(ctx context.Context, tb testing.TB, cfg config.Cfg) *grpc.ClientConn { +func dialService(tb testing.TB, ctx context.Context, cfg config.Cfg) *grpc.ClientConn { dialOptions := []grpc.DialOption{internalclient.UnaryInterceptor(), internalclient.StreamInterceptor()} if cfg.Auth.Token != "" { dialOptions = append(dialOptions, grpc.WithPerRPCCredentials(gitalyauth.RPCCredentialsV2(cfg.Auth.Token))) @@ -116,7 +116,7 @@ func dialService(ctx context.Context, tb testing.TB, cfg config.Cfg) *grpc.Clien } // CreateRepository creates a new repository and returns it and its absolute path. -func CreateRepository(ctx context.Context, tb testing.TB, cfg config.Cfg, configs ...CreateRepositoryConfig) (*gitalypb.Repository, string) { +func CreateRepository(tb testing.TB, ctx context.Context, cfg config.Cfg, configs ...CreateRepositoryConfig) (*gitalypb.Repository, string) { tb.Helper() require.Less(tb, len(configs), 2, "you must either pass no or exactly one option") @@ -152,7 +152,7 @@ func CreateRepository(ctx context.Context, tb testing.TB, cfg config.Cfg, config if !opts.SkipCreationViaService { conn := opts.ClientConn if conn == nil { - conn = dialService(ctx, tb, cfg) + conn = dialService(tb, ctx, cfg) tb.Cleanup(func() { testhelper.MustClose(tb, conn) }) } client := gitalypb.NewRepositoryServiceClient(conn) @@ -185,7 +185,7 @@ func CreateRepository(ctx context.Context, tb testing.TB, cfg config.Cfg, config require.NoError(tb, err) }) - repoPath = filepath.Join(storage.Path, getReplicaPath(ctx, tb, conn, repository)) + repoPath = filepath.Join(storage.Path, getReplicaPath(tb, ctx, conn, repository)) } else { repoPath = filepath.Join(storage.Path, repository.RelativePath) @@ -224,7 +224,7 @@ type GetReplicaPathConfig struct { // run with Praefect in front of it. This is necessary if the test creates a repository // through Praefect and peeks into the filesystem afterwards. Conn should be pointing to // Praefect. -func GetReplicaPath(ctx context.Context, tb testing.TB, cfg config.Cfg, repo repository.GitRepo, opts ...GetReplicaPathConfig) string { +func GetReplicaPath(tb testing.TB, ctx context.Context, cfg config.Cfg, repo repository.GitRepo, opts ...GetReplicaPathConfig) string { require.Less(tb, len(opts), 2, "you must either pass no or exactly one option") var opt GetReplicaPathConfig @@ -234,14 +234,14 @@ func GetReplicaPath(ctx context.Context, tb testing.TB, cfg config.Cfg, repo rep conn := opt.ClientConn if conn == nil { - conn = dialService(ctx, tb, cfg) + conn = dialService(tb, ctx, cfg) defer conn.Close() } - return getReplicaPath(ctx, tb, conn, repo) + return getReplicaPath(tb, ctx, conn, repo) } -func getReplicaPath(ctx context.Context, tb testing.TB, conn *grpc.ClientConn, repo repository.GitRepo) string { +func getReplicaPath(tb testing.TB, ctx context.Context, conn *grpc.ClientConn, repo repository.GitRepo) string { metadata, err := gitalypb.NewPraefectInfoServiceClient(conn).GetRepositoryMetadata( ctx, &gitalypb.GetRepositoryMetadataRequest{ Query: &gitalypb.GetRepositoryMetadataRequest_Path_{ @@ -263,10 +263,10 @@ func getReplicaPath(ctx context.Context, tb testing.TB, conn *grpc.ClientConn, r // RewrittenRepository returns the repository as it would be received by a Gitaly after being rewritten by Praefect. // This should be used when the repository is being accessed through the filesystem to ensure the access path is // correct. If the test is not running with Praefect in front, it returns the an unaltered copy of repository. -func RewrittenRepository(ctx context.Context, tb testing.TB, cfg config.Cfg, repository *gitalypb.Repository) *gitalypb.Repository { +func RewrittenRepository(tb testing.TB, ctx context.Context, cfg config.Cfg, repository *gitalypb.Repository) *gitalypb.Repository { // Don'tb modify the original repository. rewritten := proto.Clone(repository).(*gitalypb.Repository) - rewritten.RelativePath = GetReplicaPath(ctx, tb, cfg, repository) + rewritten.RelativePath = GetReplicaPath(tb, ctx, cfg, repository) return rewritten } diff --git a/internal/git/gittest/repository_suite.go b/internal/git/gittest/repository_suite.go index 505279598..885af8b40 100644 --- a/internal/git/gittest/repository_suite.go +++ b/internal/git/gittest/repository_suite.go @@ -13,7 +13,7 @@ import ( // GetRepositoryFunc is used to get a clean test repository for the different implementations of the // Repository interface in the common test suite TestRepository. -type GetRepositoryFunc func(ctx context.Context, t testing.TB) (git.Repository, string) +type GetRepositoryFunc func(t testing.TB, ctx context.Context) (git.Repository, string) // TestRepository tests an implementation of Repository. func TestRepository(t *testing.T, cfg config.Cfg, getRepository GetRepositoryFunc) { @@ -43,7 +43,7 @@ func TestRepository(t *testing.T, cfg config.Cfg, getRepository GetRepositoryFun func testRepositoryResolveRevision(t *testing.T, cfg config.Cfg, getRepository GetRepositoryFunc) { ctx := testhelper.Context(t) - repo, repoPath := getRepository(ctx, t) + repo, repoPath := getRepository(t, ctx) firstParentCommitID := WriteCommit(t, cfg, repoPath, WithMessage("first parent")) secondParentCommitID := WriteCommit(t, cfg, repoPath, WithMessage("second parent")) @@ -99,7 +99,7 @@ func testRepositoryResolveRevision(t *testing.T, cfg config.Cfg, getRepository G func testRepositoryHasBranches(t *testing.T, cfg config.Cfg, getRepository GetRepositoryFunc) { ctx := testhelper.Context(t) - repo, repoPath := getRepository(ctx, t) + repo, repoPath := getRepository(t, ctx) emptyCommit := text.ChompBytes(Exec(t, cfg, "-C", repoPath, "commit-tree", DefaultObjectHash.EmptyTreeOID.String())) @@ -127,7 +127,7 @@ func testRepositoryGetDefaultBranch(t *testing.T, cfg config.Cfg, getRepository { desc: "default ref", repo: func(t *testing.T) git.Repository { - repo, repoPath := getRepository(ctx, t) + repo, repoPath := getRepository(t, ctx) oid := WriteCommit(t, cfg, repoPath, WithBranch("apple")) WriteCommit(t, cfg, repoPath, WithParents(oid), WithBranch("main")) return repo @@ -137,7 +137,7 @@ func testRepositoryGetDefaultBranch(t *testing.T, cfg config.Cfg, getRepository { desc: "legacy default ref", repo: func(t *testing.T) git.Repository { - repo, repoPath := getRepository(ctx, t) + repo, repoPath := getRepository(t, ctx) oid := WriteCommit(t, cfg, repoPath, WithBranch("apple")) WriteCommit(t, cfg, repoPath, WithParents(oid), WithBranch("master")) return repo @@ -147,14 +147,14 @@ func testRepositoryGetDefaultBranch(t *testing.T, cfg config.Cfg, getRepository { desc: "no branches", repo: func(t *testing.T) git.Repository { - repo, _ := getRepository(ctx, t) + repo, _ := getRepository(t, ctx) return repo }, }, { desc: "one branch", repo: func(t *testing.T) git.Repository { - repo, repoPath := getRepository(ctx, t) + repo, repoPath := getRepository(t, ctx) WriteCommit(t, cfg, repoPath, WithBranch("apple")) return repo }, @@ -163,7 +163,7 @@ func testRepositoryGetDefaultBranch(t *testing.T, cfg config.Cfg, getRepository { desc: "no default branches", repo: func(t *testing.T) git.Repository { - repo, repoPath := getRepository(ctx, t) + repo, repoPath := getRepository(t, ctx) oid := WriteCommit(t, cfg, repoPath, WithBranch("apple")) WriteCommit(t, cfg, repoPath, WithParents(oid), WithBranch("banana")) return repo @@ -173,7 +173,7 @@ func testRepositoryGetDefaultBranch(t *testing.T, cfg config.Cfg, getRepository { desc: "test repo HEAD set", repo: func(t *testing.T) git.Repository { - repo, repoPath := getRepository(ctx, t) + repo, repoPath := getRepository(t, ctx) WriteCommit(t, cfg, repoPath, WithBranch("feature")) Exec(t, cfg, "-C", repoPath, "symbolic-ref", "HEAD", "refs/heads/feature") diff --git a/internal/git/gittest/testhelper_test.go b/internal/git/gittest/testhelper_test.go index a477adc66..98b6a6cdd 100644 --- a/internal/git/gittest/testhelper_test.go +++ b/internal/git/gittest/testhelper_test.go @@ -53,7 +53,7 @@ func setup(tb testing.TB) (config.Cfg, *gitalypb.Repository, string) { require.NoError(tb, cfg.Validate()) - repo, repoPath := CreateRepository(ctx, tb, cfg, CreateRepositoryConfig{ + repo, repoPath := CreateRepository(tb, ctx, cfg, CreateRepositoryConfig{ SkipCreationViaService: true, }) diff --git a/internal/git/housekeeping/clean_stale_data_test.go b/internal/git/housekeeping/clean_stale_data_test.go index 5a8e5f218..dce0f12aa 100644 --- a/internal/git/housekeeping/clean_stale_data_test.go +++ b/internal/git/housekeeping/clean_stale_data_test.go @@ -868,7 +868,7 @@ func TestRepositoryManager_CleanStaleData_unsetConfiguration(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -925,7 +925,7 @@ func TestRepositoryManager_CleanStaleData_unsetConfigurationTransactional(t *tes ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -959,7 +959,7 @@ func TestRepositoryManager_CleanStaleData_pruneEmptyConfigSections(t *testing.T) ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -1009,7 +1009,7 @@ func TestPruneEmptyConfigSections(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) diff --git a/internal/git/housekeeping/objects_test.go b/internal/git/housekeeping/objects_test.go index 33bc89e41..e5194f1fa 100644 --- a/internal/git/housekeeping/objects_test.go +++ b/internal/git/housekeeping/objects_test.go @@ -37,7 +37,7 @@ func TestRepackObjects(t *testing.T) { cfg := testcfg.Build(t) t.Run("no server info is written", func(t *testing.T) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -57,7 +57,7 @@ func TestRepackObjects(t *testing.T) { }) testRepoAndPool(t, "delta islands", func(t *testing.T, relativePath string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: relativePath, }) diff --git a/internal/git/housekeeping/optimize_repository_ext_test.go b/internal/git/housekeeping/optimize_repository_ext_test.go index fa51834ae..fd1e266b8 100644 --- a/internal/git/housekeeping/optimize_repository_ext_test.go +++ b/internal/git/housekeeping/optimize_repository_ext_test.go @@ -105,7 +105,7 @@ func TestPruneIfNeeded(t *testing.T) { createRepoCfg.RelativePath = gittest.NewObjectPoolName(t) } - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, createRepoCfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, createRepoCfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) for _, looseObjectPath := range tc.looseObjects { diff --git a/internal/git/housekeeping/optimize_repository_test.go b/internal/git/housekeeping/optimize_repository_test.go index 030ab1eef..ebf5afa75 100644 --- a/internal/git/housekeeping/optimize_repository_test.go +++ b/internal/git/housekeeping/optimize_repository_test.go @@ -43,7 +43,7 @@ func TestNeedsRepacking(t *testing.T) { { desc: "empty repo does nothing", setup: func(t *testing.T, relativePath string) *gitalypb.Repository { - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: relativePath, }) @@ -53,7 +53,7 @@ func TestNeedsRepacking(t *testing.T) { { desc: "missing bitmap", setup: func(t *testing.T, relativePath string) *gitalypb.Repository { - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: relativePath, @@ -69,7 +69,7 @@ func TestNeedsRepacking(t *testing.T) { { desc: "missing bitmap with alternate", setup: func(t *testing.T, relativePath string) *gitalypb.Repository { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: relativePath, @@ -89,7 +89,7 @@ func TestNeedsRepacking(t *testing.T) { { desc: "missing commit-graph", setup: func(t *testing.T, relativePath string) *gitalypb.Repository { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: relativePath, @@ -107,7 +107,7 @@ func TestNeedsRepacking(t *testing.T) { { desc: "commit-graph without bloom filters", setup: func(t *testing.T, relativePath string) *gitalypb.Repository { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: relativePath, @@ -126,7 +126,7 @@ func TestNeedsRepacking(t *testing.T) { { desc: "no repack needed", setup: func(t *testing.T, relativePath string) *gitalypb.Repository { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: relativePath, @@ -201,7 +201,7 @@ func TestNeedsRepacking(t *testing.T) { // Let's not go any further than this, we're thrashing the temporary directory. } { testRepoAndPool(t, fmt.Sprintf("packfile with %d bytes", tc.packfileSize), func(t *testing.T, relativePath string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: relativePath, }) @@ -314,7 +314,7 @@ func TestNeedsRepacking(t *testing.T) { }, } { testRepoAndPool(t, tc.desc, func(t *testing.T, relativePath string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: relativePath, }) @@ -393,7 +393,7 @@ func TestPackRefsIfNeeded(t *testing.T) { }, } { testRepoAndPool(t, fmt.Sprintf("packed-refs with %d bytes", tc.packedRefsSize), func(t *testing.T, relativePath string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: relativePath, }) @@ -449,7 +449,7 @@ func TestEstimateLooseObjectCount(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -545,7 +545,7 @@ func TestOptimizeRepository(t *testing.T) { { desc: "empty repository does nothing", setup: func(t *testing.T, relativePath string) *gitalypb.Repository { - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: relativePath, }) @@ -559,7 +559,7 @@ gitaly_housekeeping_tasks_total{housekeeping_task="total", status="success"} 1 { desc: "repository without bitmap repacks objects", setup: func(t *testing.T, relativePath string) *gitalypb.Repository { - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: relativePath, @@ -577,7 +577,7 @@ gitaly_housekeeping_tasks_total{housekeeping_task="total", status="success"} 1 { desc: "repository without commit-graph writes commit-graph", setup: func(t *testing.T, relativePath string) *gitalypb.Repository { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: relativePath, @@ -594,7 +594,7 @@ gitaly_housekeeping_tasks_total{housekeeping_task="total", status="success"} 1 { desc: "repository with multiple packfiles packs only for object pool", setup: func(t *testing.T, relativePath string) *gitalypb.Repository { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: relativePath, @@ -622,7 +622,7 @@ gitaly_housekeeping_tasks_total{housekeeping_task="total", status="success"} 1 { desc: "well-packed repository does not optimize", setup: func(t *testing.T, relativePath string) *gitalypb.Repository { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: relativePath, @@ -639,7 +639,7 @@ gitaly_housekeeping_tasks_total{housekeeping_task="total", status="success"} 1 { desc: "recent loose objects don't get pruned", setup: func(t *testing.T, relativePath string) *gitalypb.Repository { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: relativePath, @@ -674,7 +674,7 @@ gitaly_housekeeping_tasks_total{housekeeping_task="total", status="success"} 1 { desc: "old loose objects get pruned", setup: func(t *testing.T, relativePath string) *gitalypb.Repository { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: relativePath, @@ -714,7 +714,7 @@ gitaly_housekeeping_tasks_total{housekeeping_task="total", status="success"} 1 { desc: "loose refs get packed", setup: func(t *testing.T, relativePath string) *gitalypb.Repository { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: relativePath, }) @@ -767,7 +767,7 @@ func TestOptimizeRepository_ConcurrencyLimit(t *testing.T) { t.Run("subsequent calls get skipped", func(t *testing.T) { reqReceivedCh, ch := make(chan struct{}), make(chan struct{}) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, }) @@ -798,12 +798,12 @@ func TestOptimizeRepository_ConcurrencyLimit(t *testing.T) { t.Run("multiple repositories concurrently", func(t *testing.T) { reqReceivedCh, ch := make(chan struct{}), make(chan struct{}) - repoProtoFirst, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProtoFirst, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, }) repoFirst := localrepo.NewTestRepo(t, cfg, repoProtoFirst) - repoProtoSecond, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProtoSecond, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, }) @@ -843,7 +843,7 @@ func TestOptimizeRepository_ConcurrencyLimit(t *testing.T) { t.Run("serialized optimizations", func(t *testing.T) { reqReceivedCh, ch := make(chan struct{}), make(chan struct{}) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, }) @@ -899,7 +899,7 @@ func TestPruneIfNeeded(t *testing.T) { cfg := testcfg.Build(t) testRepoAndPool(t, "empty repo does not prune", func(t *testing.T, relativePath string) { - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: relativePath, }) @@ -911,7 +911,7 @@ func TestPruneIfNeeded(t *testing.T) { }) testRepoAndPool(t, "repo with single object does not prune", func(t *testing.T, relativePath string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: relativePath, }) @@ -925,7 +925,7 @@ func TestPruneIfNeeded(t *testing.T) { }) testRepoAndPool(t, "repo with single 17-prefixed objects does not prune", func(t *testing.T, relativePath string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: relativePath, }) @@ -940,7 +940,7 @@ func TestPruneIfNeeded(t *testing.T) { }) testRepoAndPool(t, "repo with four 17-prefixed objects does not prune", func(t *testing.T, relativePath string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: relativePath, }) @@ -957,7 +957,7 @@ func TestPruneIfNeeded(t *testing.T) { }) testRepoAndPool(t, "repo with five 17-prefixed objects does prune after grace period", func(t *testing.T, relativePath string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: relativePath, }) @@ -1039,7 +1039,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) { { desc: "empty repository", setup: func(t *testing.T) (*gitalypb.Repository, string) { - return gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + return gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) }, @@ -1050,7 +1050,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) { { desc: "repository with objects but no refs", setup: func(t *testing.T) (*gitalypb.Repository, string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) gittest.WriteBlob(t, cfg, repoPath, []byte("something")) @@ -1063,7 +1063,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) { { desc: "repository without commit-graph", setup: func(t *testing.T) (*gitalypb.Repository, string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) @@ -1078,7 +1078,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) { { desc: "repository with old-style unsplit commit-graph", setup: func(t *testing.T) (*gitalypb.Repository, string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) @@ -1102,7 +1102,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) { { desc: "repository with split commit-graph without bitmap", setup: func(t *testing.T) (*gitalypb.Repository, string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) @@ -1123,7 +1123,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) { { desc: "repository with split commit-graph with bitmap without repack", setup: func(t *testing.T) (*gitalypb.Repository, string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) @@ -1144,7 +1144,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) { { desc: "repository with split commit-graph with bitmap with repack", setup: func(t *testing.T) (*gitalypb.Repository, string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) @@ -1166,7 +1166,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) { { desc: "repository with split commit-graph with bitmap with pruned objects", setup: func(t *testing.T) (*gitalypb.Repository, string) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) @@ -1209,7 +1209,7 @@ func TestWriteCommitGraphIfNeeded(t *testing.T) { } t.Run("commit-graph with pruned objects", func(t *testing.T) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) diff --git a/internal/git/housekeeping/worktrees_test.go b/internal/git/housekeeping/worktrees_test.go index 8ee923d2d..95c2cf1be 100644 --- a/internal/git/housekeeping/worktrees_test.go +++ b/internal/git/housekeeping/worktrees_test.go @@ -23,7 +23,7 @@ func TestCleanupDisconnectedWorktrees_doesNothingWithoutWorktrees(t *testing.T) cfg, repoProto, repoPath := testcfg.BuildWithRepo(t) worktreePath := filepath.Join(testhelper.TempDir(t), "worktree") - failingGitCmdFactory := gittest.NewInterceptingCommandFactory(ctx, t, cfg, func(git.ExecutionEnvironment) string { + failingGitCmdFactory := gittest.NewInterceptingCommandFactory(t, ctx, cfg, func(git.ExecutionEnvironment) string { return `#!/usr/bin/env bash exit 15 ` diff --git a/internal/git/localrepo/config_test.go b/internal/git/localrepo/config_test.go index 43e4d516a..15d400635 100644 --- a/internal/git/localrepo/config_test.go +++ b/internal/git/localrepo/config_test.go @@ -78,7 +78,7 @@ func TestRepo_SetConfig(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -124,7 +124,7 @@ func TestRepo_SetConfig(t *testing.T) { } t.Run("transactional", func(t *testing.T) { - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := NewTestRepo(t, cfg, repoProto) @@ -233,7 +233,7 @@ func TestRepo_UnsetMatchingConfig(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := NewTestRepo(t, cfg, repoProto) @@ -257,7 +257,7 @@ func TestRepo_UnsetMatchingConfig(t *testing.T) { } t.Run("transactional", func(t *testing.T) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := NewTestRepo(t, cfg, repoProto) diff --git a/internal/git/localrepo/paths_test.go b/internal/git/localrepo/paths_test.go index 6ced8e612..d5a38e25e 100644 --- a/internal/git/localrepo/paths_test.go +++ b/internal/git/localrepo/paths_test.go @@ -24,7 +24,7 @@ func TestRepo_Path(t *testing.T) { cfg := testcfg.Build(t) t.Run("valid repository", func(t *testing.T) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -35,7 +35,7 @@ func TestRepo_Path(t *testing.T) { }) t.Run("deleted repository", func(t *testing.T) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -47,7 +47,7 @@ func TestRepo_Path(t *testing.T) { }) t.Run("non-git repository", func(t *testing.T) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -66,7 +66,7 @@ func TestRepo_ObjectDirectoryPath(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) locator := config.NewLocator(cfg) diff --git a/internal/git/localrepo/refs_test.go b/internal/git/localrepo/refs_test.go index deed4ab3b..47f64c3ab 100644 --- a/internal/git/localrepo/refs_test.go +++ b/internal/git/localrepo/refs_test.go @@ -226,7 +226,7 @@ func TestRepo_GetRemoteReferences(t *testing.T) { cfg := testcfg.Build(t) - gitCmdFactory, readSSHCommand := captureGitSSHCommand(ctx, t, cfg) + gitCmdFactory, readSSHCommand := captureGitSSHCommand(t, ctx, cfg) storagePath, ok := cfg.StoragePath("default") require.True(t, ok) @@ -474,7 +474,7 @@ func TestRepo_UpdateRef(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { // We need to re-seed the repository every time so that we don't carry over // the state. - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := New(repo.locator, repo.gitCmdFactory, repo.catfileCache, repoProto) diff --git a/internal/git/localrepo/remote_extra_test.go b/internal/git/localrepo/remote_extra_test.go index dafd7e8ae..bc433b2c4 100644 --- a/internal/git/localrepo/remote_extra_test.go +++ b/internal/git/localrepo/remote_extra_test.go @@ -27,7 +27,7 @@ func TestRepo_FetchInternal(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(ctx, t, cfg) + protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(t, ctx, cfg) cfg.SocketPath = testserver.RunGitalyServer(t, cfg, nil, func(srv *grpc.Server, deps *service.Dependencies) { gitalypb.RegisterSSHServiceServer(srv, ssh.NewServer( @@ -55,7 +55,7 @@ func TestRepo_FetchInternal(t *testing.T) { testcfg.BuildGitalySSH(t, cfg) testcfg.BuildGitalyHooks(t, cfg) - remoteRepoProto, remoteRepoPath := gittest.CreateRepository(ctx, t, cfg) + remoteRepoProto, remoteRepoPath := gittest.CreateRepository(t, ctx, cfg) remoteOID := gittest.WriteCommit(t, cfg, remoteRepoPath, gittest.WithBranch("master")) tagV100OID := gittest.WriteTag(t, cfg, remoteRepoPath, "v1.0.0", remoteOID.Revision(), gittest.WriteTagConfig{ Message: "v1.0.0", @@ -67,7 +67,7 @@ func TestRepo_FetchInternal(t *testing.T) { t.Run("refspec with tag", func(t *testing.T) { ctx := testhelper.MergeIncomingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) gittest.Exec(t, cfg, "-C", repoPath, "config", "fetch.writeCommitGraph", "true") @@ -99,7 +99,7 @@ func TestRepo_FetchInternal(t *testing.T) { t.Run("refspec without tags", func(t *testing.T) { ctx := testhelper.MergeIncomingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) require.NoError(t, repo.FetchInternal( @@ -117,7 +117,7 @@ func TestRepo_FetchInternal(t *testing.T) { t.Run("object ID", func(t *testing.T) { ctx := testhelper.MergeIncomingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) require.NoError(t, repo.FetchInternal( @@ -133,7 +133,7 @@ func TestRepo_FetchInternal(t *testing.T) { t.Run("nonexistent revision", func(t *testing.T) { ctx := testhelper.MergeIncomingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) var stderr bytes.Buffer @@ -149,7 +149,7 @@ func TestRepo_FetchInternal(t *testing.T) { t.Run("with env", func(t *testing.T) { ctx := testhelper.MergeIncomingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) var stderr bytes.Buffer @@ -164,7 +164,7 @@ func TestRepo_FetchInternal(t *testing.T) { t.Run("with disabled transactions", func(t *testing.T) { ctx := testhelper.MergeIncomingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) var stderr bytes.Buffer @@ -179,7 +179,7 @@ func TestRepo_FetchInternal(t *testing.T) { t.Run("invalid remote repo", func(t *testing.T) { ctx := testhelper.MergeIncomingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) err := repo.FetchInternal(ctx, &gitalypb.Repository{ @@ -200,7 +200,7 @@ func TestRepo_FetchInternal(t *testing.T) { t.Run("pruning", func(t *testing.T) { ctx := testhelper.MergeIncomingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) // Create a local reference. Given that it doesn't exist on the remote side, it diff --git a/internal/git/localrepo/remote_test.go b/internal/git/localrepo/remote_test.go index 00208b461..19ac15bd4 100644 --- a/internal/git/localrepo/remote_test.go +++ b/internal/git/localrepo/remote_test.go @@ -28,7 +28,7 @@ func TestRepo_FetchRemote(t *testing.T) { defer catfileCache.Stop() locator := config.NewLocator(cfg) - _, remoteRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, remoteRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) commitID := gittest.WriteCommit(t, cfg, remoteRepoPath, gittest.WithBranch("main")) @@ -39,7 +39,7 @@ func TestRepo_FetchRemote(t *testing.T) { initBareWithRemote := func(t *testing.T, remote string) (*Repo, string) { t.Helper() - clientRepo, clientRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + clientRepo, clientRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -61,7 +61,7 @@ func TestRepo_FetchRemote(t *testing.T) { }) t.Run("unknown remote", func(t *testing.T) { - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -93,7 +93,7 @@ func TestRepo_FetchRemote(t *testing.T) { }) t.Run("with env", func(t *testing.T) { - testRepo, testRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + testRepo, testRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -106,7 +106,7 @@ func TestRepo_FetchRemote(t *testing.T) { }) t.Run("with disabled transactions", func(t *testing.T) { - testRepo, testRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + testRepo, testRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -123,7 +123,7 @@ func TestRepo_FetchRemote(t *testing.T) { }) t.Run("with globals", func(t *testing.T) { - testRepo, testRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + testRepo, testRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -152,7 +152,7 @@ func TestRepo_FetchRemote(t *testing.T) { }) t.Run("with prune", func(t *testing.T) { - testRepo, testRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + testRepo, testRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -230,10 +230,10 @@ func TestRepo_FetchRemote(t *testing.T) { // captureGitSSHCommand creates a new intercepting command factory which captures the // GIT_SSH_COMMAND environment variable. The returned function can be used to read the variable's // value. -func captureGitSSHCommand(ctx context.Context, tb testing.TB, cfg config.Cfg) (git.CommandFactory, func() ([]byte, error)) { +func captureGitSSHCommand(tb testing.TB, ctx context.Context, cfg config.Cfg) (git.CommandFactory, func() ([]byte, error)) { envPath := filepath.Join(testhelper.TempDir(tb), "GIT_SSH_PATH") - gitCmdFactory := gittest.NewInterceptingCommandFactory(ctx, tb, cfg, func(execEnv git.ExecutionEnvironment) string { + gitCmdFactory := gittest.NewInterceptingCommandFactory(tb, ctx, cfg, func(execEnv git.ExecutionEnvironment) string { return fmt.Sprintf( `#!/usr/bin/env bash if test -z "${GIT_SSH_COMMAND+x}" @@ -256,12 +256,12 @@ func TestRepo_Push(t *testing.T) { cfg := testcfg.Build(t) - gitCmdFactory, readSSHCommand := captureGitSSHCommand(ctx, t, cfg) + gitCmdFactory, readSSHCommand := captureGitSSHCommand(t, ctx, cfg) catfileCache := catfile.NewCache(cfg) t.Cleanup(catfileCache.Stop) locator := config.NewLocator(cfg) - sourceRepoProto, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + sourceRepoProto, sourceRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) sourceRepo := New(locator, gitCmdFactory, catfileCache, sourceRepoProto) @@ -269,14 +269,14 @@ func TestRepo_Push(t *testing.T) { gittest.WriteCommit(t, cfg, sourceRepoPath, gittest.WithBranch("feature")) setupPushRepo := func(tb testing.TB) (*Repo, string, []git.ConfigPair) { - repoProto, repopath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repoProto, repopath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) return New(locator, gitCmdFactory, catfileCache, repoProto), repopath, nil } setupDivergedRepo := func(tb testing.TB) (*Repo, string, []git.ConfigPair) { - repoProto, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := New(locator, gitCmdFactory, catfileCache, repoProto) @@ -352,7 +352,7 @@ func TestRepo_Push(t *testing.T) { { desc: "invalid remote", setupPushRepo: func(tb testing.TB) (*Repo, string, []git.ConfigPair) { - repoProto, _ := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) return New(locator, gitCmdFactory, catfileCache, repoProto), "", nil @@ -363,7 +363,7 @@ func TestRepo_Push(t *testing.T) { { desc: "in-memory remote", setupPushRepo: func(tb testing.TB) (*Repo, string, []git.ConfigPair) { - repoProto, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) return New(locator, gitCmdFactory, catfileCache, repoProto), "inmemory", []git.ConfigPair{ diff --git a/internal/git/localrepo/repo.go b/internal/git/localrepo/repo.go index ccd4db37e..dbb06cc62 100644 --- a/internal/git/localrepo/repo.go +++ b/internal/git/localrepo/repo.go @@ -53,7 +53,7 @@ func NewTestRepo(tb testing.TB, cfg config.Cfg, repo repository.GitRepo, factory tb.Helper() if cfg.SocketPath != testcfg.UnconfiguredSocketPath { - repo = gittest.RewrittenRepository(testhelper.Context(tb), tb, cfg, &gitalypb.Repository{ + repo = gittest.RewrittenRepository(tb, testhelper.Context(tb), cfg, &gitalypb.Repository{ StorageName: repo.GetStorageName(), RelativePath: repo.GetRelativePath(), GitObjectDirectory: repo.GetGitObjectDirectory(), diff --git a/internal/git/localrepo/repo_test.go b/internal/git/localrepo/repo_test.go index 7f26136f2..25d7f9986 100644 --- a/internal/git/localrepo/repo_test.go +++ b/internal/git/localrepo/repo_test.go @@ -22,10 +22,10 @@ import ( func TestRepo(t *testing.T) { cfg := testcfg.Build(t) - gittest.TestRepository(t, cfg, func(ctx context.Context, tb testing.TB) (git.Repository, string) { + gittest.TestRepository(t, cfg, func(tb testing.TB, ctx context.Context) (git.Repository, string) { tb.Helper() - repoProto, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -46,7 +46,7 @@ func TestSize(t *testing.T) { ctx := testhelper.Context(t) commandArgFile := filepath.Join(testhelper.TempDir(t), "args") - interceptingFactory := gittest.NewInterceptingCommandFactory(ctx, t, cfg, func(execEnv git.ExecutionEnvironment) string { + interceptingFactory := gittest.NewInterceptingCommandFactory(t, ctx, cfg, func(execEnv git.ExecutionEnvironment) string { return fmt.Sprintf(`#!/bin/bash echo "$@" >%q exec %q "$@" @@ -71,7 +71,7 @@ func TestSize(t *testing.T) { desc: "empty repository", expectedSize: 0, setup: func(t *testing.T) *gitalypb.Repository { - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) return repoProto @@ -81,7 +81,7 @@ func TestSize(t *testing.T) { { desc: "referenced commit", setup: func(t *testing.T) *gitalypb.Repository { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -100,7 +100,7 @@ func TestSize(t *testing.T) { { desc: "unreferenced commit", setup: func(t *testing.T) *gitalypb.Repository { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -118,7 +118,7 @@ func TestSize(t *testing.T) { { desc: "modification to blob without repack", setup: func(t *testing.T) *gitalypb.Repository { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -145,7 +145,7 @@ func TestSize(t *testing.T) { { desc: "modification to blob after repack", setup: func(t *testing.T) *gitalypb.Repository { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -174,7 +174,7 @@ func TestSize(t *testing.T) { { desc: "excluded single ref", setup: func(t *testing.T) *gitalypb.Repository { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -203,7 +203,7 @@ func TestSize(t *testing.T) { { desc: "excluded everything", setup: func(t *testing.T) *gitalypb.Repository { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -225,10 +225,10 @@ func TestSize(t *testing.T) { { desc: "repo with alternate", setup: func(t *testing.T) *gitalypb.Repository { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) - _, poolPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, poolPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -259,10 +259,10 @@ func TestSize(t *testing.T) { { desc: "exclude alternate with identical contents", setup: func(t *testing.T) *gitalypb.Repository { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) - _, poolPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, poolPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -294,10 +294,10 @@ func TestSize(t *testing.T) { { desc: "exclude alternate with additional contents", setup: func(t *testing.T) *gitalypb.Repository { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) - _, poolPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, poolPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -368,7 +368,7 @@ func TestRepo_StorageTempDir(t *testing.T) { t.Cleanup(catfileCache.Stop) locator := config.NewLocator(cfg) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := New(locator, gitCmdFactory, catfileCache, repoProto) @@ -398,13 +398,13 @@ func TestRepo_ObjectHash(t *testing.T) { // We create an intercepting command factory that detects when we run our object hash // detection logic and, if so, writes a sentinel value into our output file. Like this we // can test how often the logic runs. - gitCmdFactory := gittest.NewInterceptingCommandFactory(ctx, t, cfg, func(execEnv git.ExecutionEnvironment) string { + gitCmdFactory := gittest.NewInterceptingCommandFactory(t, ctx, cfg, func(execEnv git.ExecutionEnvironment) string { return fmt.Sprintf(`#!/bin/sh ( echo "$@" | grep --silent -- '--show-object-format' ) && echo detection-logic >>%q exec %q "$@"`, outputFile, execEnv.BinaryPath) }) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := New(locator, gitCmdFactory, catfileCache, repoProto) diff --git a/internal/git/localrepo/testhelper_test.go b/internal/git/localrepo/testhelper_test.go index 5bc11b2af..4eff61fb1 100644 --- a/internal/git/localrepo/testhelper_test.go +++ b/internal/git/localrepo/testhelper_test.go @@ -44,7 +44,7 @@ func setupRepo(t *testing.T, opts ...setupRepoOption) (config.Cfg, *Repo, string commandFactoryOpts = append(commandFactoryOpts, git.WithSkipHooks()) } - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) diff --git a/internal/git/lstree/list_entries_test.go b/internal/git/lstree/list_entries_test.go index 2d78f9c34..2c3ef8256 100644 --- a/internal/git/lstree/list_entries_test.go +++ b/internal/git/lstree/list_entries_test.go @@ -17,7 +17,7 @@ func TestListEntries(t *testing.T) { cfg := testcfg.Build(t) ctx := testhelper.Context(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) diff --git a/internal/git/lstree/parser_test.go b/internal/git/lstree/parser_test.go index 24108dff2..af4d540d7 100644 --- a/internal/git/lstree/parser_test.go +++ b/internal/git/lstree/parser_test.go @@ -17,7 +17,7 @@ func TestParser(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - _, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -93,7 +93,7 @@ func TestParserReadEntryPath(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - _, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) diff --git a/internal/git/object_id_test.go b/internal/git/object_id_test.go index 6597daf99..69b900cc9 100644 --- a/internal/git/object_id_test.go +++ b/internal/git/object_id_test.go @@ -33,7 +33,7 @@ func TestDetectObjectHash(t *testing.T) { { desc: "defaults to SHA1", setup: func(t *testing.T) *gitalypb.Repository { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, ObjectFormat: "sha1", }) @@ -50,7 +50,7 @@ func TestDetectObjectHash(t *testing.T) { { desc: "explicitly set to SHA1", setup: func(t *testing.T) *gitalypb.Repository { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, ObjectFormat: "sha1", }) @@ -68,7 +68,7 @@ func TestDetectObjectHash(t *testing.T) { { desc: "explicitly set to SHA256", setup: func(t *testing.T) *gitalypb.Repository { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, ObjectFormat: "sha256", }) @@ -85,7 +85,7 @@ func TestDetectObjectHash(t *testing.T) { { desc: "invalid repository configuration", setup: func(t *testing.T) *gitalypb.Repository { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, ObjectFormat: "sha1", }) @@ -102,7 +102,7 @@ func TestDetectObjectHash(t *testing.T) { { desc: "unknown hash", setup: func(t *testing.T) *gitalypb.Repository { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) diff --git a/internal/git/objectpool/fetch_test.go b/internal/git/objectpool/fetch_test.go index 7305697f0..b31e66be8 100644 --- a/internal/git/objectpool/fetch_test.go +++ b/internal/git/objectpool/fetch_test.go @@ -223,7 +223,7 @@ func TestFetchFromOrigin_refs(t *testing.T) { poolPath := pool.FullPath() // Init the source repo with a bunch of refs. - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) diff --git a/internal/git/quarantine/quarantine_test.go b/internal/git/quarantine/quarantine_test.go index 161426bf8..bee26511e 100644 --- a/internal/git/quarantine/quarantine_test.go +++ b/internal/git/quarantine/quarantine_test.go @@ -88,7 +88,7 @@ func TestQuarantine_Migrate(t *testing.T) { t.Run("no changes", func(t *testing.T) { ctx := testhelper.Context(t) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, @@ -107,7 +107,7 @@ func TestQuarantine_Migrate(t *testing.T) { t.Run("simple change", func(t *testing.T) { ctx := testhelper.Context(t) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, }) diff --git a/internal/git/remoterepo/repository_test.go b/internal/git/remoterepo/repository_test.go index 5a8081d2c..8cd38f98f 100644 --- a/internal/git/remoterepo/repository_test.go +++ b/internal/git/remoterepo/repository_test.go @@ -55,13 +55,13 @@ func TestRepository(t *testing.T) { pool := client.NewPool() defer pool.Close() - gittest.TestRepository(t, cfg, func(ctx context.Context, tb testing.TB) (git.Repository, string) { + gittest.TestRepository(t, cfg, func(tb testing.TB, ctx context.Context) (git.Repository, string) { tb.Helper() ctx, err := storage.InjectGitalyServers(ctx, "default", cfg.SocketPath, cfg.Auth.Token) require.NoError(tb, err) - repoProto, repoPath := gittest.CreateRepository(ctx, tb, cfg) + repoProto, repoPath := gittest.CreateRepository(tb, ctx, cfg) repo, err := remoterepo.New(metadata.OutgoingToIncoming(ctx), repoProto, pool) require.NoError(tb, err) diff --git a/internal/git/stats/commit_graph_test.go b/internal/git/stats/commit_graph_test.go index f6a38e104..680825cc8 100644 --- a/internal/git/stats/commit_graph_test.go +++ b/internal/git/stats/commit_graph_test.go @@ -38,7 +38,7 @@ func TestIsMissingBloomFilters(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - _, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, }) diff --git a/internal/git/stats/git_test.go b/internal/git/stats/git_test.go index 70faf4f26..a07e82471 100644 --- a/internal/git/stats/git_test.go +++ b/internal/git/stats/git_test.go @@ -24,11 +24,11 @@ func TestLogObjectInfo(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repo1, repoPath1 := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo1, repoPath1 := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, }) - repo2, repoPath2 := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo2, repoPath2 := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, }) diff --git a/internal/git/stats/http_clone_test.go b/internal/git/stats/http_clone_test.go index 4e9886b77..eb818c124 100644 --- a/internal/git/stats/http_clone_test.go +++ b/internal/git/stats/http_clone_test.go @@ -20,7 +20,7 @@ func TestClone(t *testing.T) { gitCmdFactory := gittest.NewCommandFactory(t, cfg) ctx := testhelper.Context(t) - serverPort, stopGitServer := gittest.HTTPServer(ctx, t, gitCmdFactory, repoPath, nil) + serverPort, stopGitServer := gittest.HTTPServer(t, ctx, gitCmdFactory, repoPath, nil) defer func() { require.NoError(t, stopGitServer()) }() @@ -86,7 +86,7 @@ func TestCloneWithAuth(t *testing.T) { authWasChecked := false - serverPort, stopGitServer := gittest.HTTPServer(ctx, t, gitCmdFactory, repoPath, func(w http.ResponseWriter, r *http.Request, next http.Handler) { + serverPort, stopGitServer := gittest.HTTPServer(t, ctx, gitCmdFactory, repoPath, func(w http.ResponseWriter, r *http.Request, next http.Handler) { authWasChecked = true actualUser, actualPassword, ok := r.BasicAuth() diff --git a/internal/git/stats/http_push_test.go b/internal/git/stats/http_push_test.go index f35bec39f..49531722a 100644 --- a/internal/git/stats/http_push_test.go +++ b/internal/git/stats/http_push_test.go @@ -26,7 +26,7 @@ func TestPerformHTTPPush(t *testing.T) { gitCmdFactory := gittest.NewCommandFactory(t, cfg) ctx := testhelper.Context(t) - serverPort, stopGitServer := gittest.HTTPServer(ctx, t, gitCmdFactory, targetRepoPath, nil) + serverPort, stopGitServer := gittest.HTTPServer(t, ctx, gitCmdFactory, targetRepoPath, nil) defer func() { require.NoError(t, stopGitServer()) }() @@ -42,7 +42,7 @@ func TestPerformHTTPPush(t *testing.T) { { desc: "single revision", preparePush: func(t *testing.T, cfg config.Cfg) ([]PushCommand, io.Reader) { - _, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, }) @@ -79,7 +79,7 @@ func TestPerformHTTPPush(t *testing.T) { { desc: "many revisions", preparePush: func(t *testing.T, cfg config.Cfg) ([]PushCommand, io.Reader) { - _, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, }) diff --git a/internal/git/stats/profile_test.go b/internal/git/stats/profile_test.go index dff0ede48..9d1c5ecf3 100644 --- a/internal/git/stats/profile_test.go +++ b/internal/git/stats/profile_test.go @@ -19,7 +19,7 @@ func TestRepositoryProfile(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - testRepo, testRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + testRepo, testRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) diff --git a/internal/git/updateref/update_with_hooks_test.go b/internal/git/updateref/update_with_hooks_test.go index b47db59fe..3277a53c5 100644 --- a/internal/git/updateref/update_with_hooks_test.go +++ b/internal/git/updateref/update_with_hooks_test.go @@ -32,7 +32,7 @@ func TestUpdaterWithHooks_UpdateReference_invalidParameters(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) gitCmdFactory := gittest.NewCommandFactory(t, cfg) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -101,7 +101,7 @@ func TestUpdaterWithHooks_UpdateReference(t *testing.T) { gitalypb.RegisterHookServiceServer(srv, hookservice.NewServer(deps.GetHookManager(), deps.GetGitCmdFactory(), deps.GetPackObjectsCache(), deps.GetPackObjectsConcurrencyTracker())) }) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) @@ -280,7 +280,7 @@ func TestUpdaterWithHooks_quarantine(t *testing.T) { gitCmdFactory := gittest.NewCommandFactory(t, cfg) locator := config.NewLocator(cfg) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) diff --git a/internal/git/updateref/updateref_test.go b/internal/git/updateref/updateref_test.go index 50c2d7eb1..96a094c44 100644 --- a/internal/git/updateref/updateref_test.go +++ b/internal/git/updateref/updateref_test.go @@ -24,7 +24,7 @@ func setupUpdater(t *testing.T, ctx context.Context) (config.Cfg, *localrepo.Rep cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto, git.WithSkipHooks()) @@ -135,7 +135,7 @@ func TestUpdater_concurrentLocking(t *testing.T) { t.Skip("git does not support flushing yet, which is known to be flaky") } - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto, git.WithSkipHooks()) diff --git a/internal/git2go/apply_test.go b/internal/git2go/apply_test.go index af99a58e9..e92f90a6d 100644 --- a/internal/git2go/apply_test.go +++ b/internal/git2go/apply_test.go @@ -22,7 +22,7 @@ func TestExecutor_Apply(t *testing.T) { cfg := testcfg.Build(t) testcfg.BuildGitalyGit2Go(t, cfg) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) diff --git a/internal/git2go/commit_test.go b/internal/git2go/commit_test.go index 48deee815..711021a10 100644 --- a/internal/git2go/commit_test.go +++ b/internal/git2go/commit_test.go @@ -51,7 +51,7 @@ func TestExecutor_Commit(t *testing.T) { cfg := testcfg.Build(t) testcfg.BuildGitalyGit2Go(t, cfg) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) diff --git a/internal/git2go/featureflags_test.go b/internal/git2go/featureflags_test.go index b4e9117ef..d4b89cf00 100644 --- a/internal/git2go/featureflags_test.go +++ b/internal/git2go/featureflags_test.go @@ -48,7 +48,7 @@ func testExecutorFeatureFlags(t *testing.T, ctx context.Context) { cfg := testcfg.Build(t) testcfg.BuildGitalyGit2Go(t, cfg) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) diff --git a/internal/gitaly/hook/postreceive_test.go b/internal/gitaly/hook/postreceive_test.go index 5fb125ad0..9c6de0ff4 100644 --- a/internal/gitaly/hook/postreceive_test.go +++ b/internal/gitaly/hook/postreceive_test.go @@ -127,7 +127,7 @@ func TestPostReceive_customHook(t *testing.T) { env: []string{payload}, stdin: "changes\n", hook: "#!/bin/sh\nenv | grep -v -e '^SHLVL=' -e '^_=' | sort\n", - expectedStdout: strings.Join(getExpectedEnv(ctx, t, locator, gitCmdFactory, repo), "\n") + "\n", + expectedStdout: strings.Join(getExpectedEnv(t, ctx, locator, gitCmdFactory, repo), "\n") + "\n", }, { desc: "push options are passed through", diff --git a/internal/gitaly/hook/prereceive_test.go b/internal/gitaly/hook/prereceive_test.go index f7bd01325..d0b46e1cd 100644 --- a/internal/gitaly/hook/prereceive_test.go +++ b/internal/gitaly/hook/prereceive_test.go @@ -86,7 +86,7 @@ func TestPrereceive_customHooks(t *testing.T) { env: []string{payload}, hook: "#!/bin/sh\nenv | grep -v -e '^SHLVL=' -e '^_=' | sort\n", stdin: "change\n", - expectedStdout: strings.Join(getExpectedEnv(ctx, t, locator, gitCmdFactory, repo), "\n") + "\n", + expectedStdout: strings.Join(getExpectedEnv(t, ctx, locator, gitCmdFactory, repo), "\n") + "\n", }, { desc: "hook receives push options", diff --git a/internal/gitaly/hook/testhelper_test.go b/internal/gitaly/hook/testhelper_test.go index 683fb2790..f5461d5a5 100644 --- a/internal/gitaly/hook/testhelper_test.go +++ b/internal/gitaly/hook/testhelper_test.go @@ -23,7 +23,7 @@ func TestMain(m *testing.M) { testhelper.Run(m) } -func getExpectedEnv(ctx context.Context, tb testing.TB, locator storage.Locator, gitCmdFactory git.CommandFactory, repo *gitalypb.Repository) []string { +func getExpectedEnv(tb testing.TB, ctx context.Context, locator storage.Locator, gitCmdFactory git.CommandFactory, repo *gitalypb.Repository) []string { repoPath, err := locator.GetPath(repo) require.NoError(tb, err) diff --git a/internal/gitaly/hook/update_test.go b/internal/gitaly/hook/update_test.go index c5b47c76f..e9874a908 100644 --- a/internal/gitaly/hook/update_test.go +++ b/internal/gitaly/hook/update_test.go @@ -89,7 +89,7 @@ func TestUpdate_customHooks(t *testing.T) { oldHash: hash1, newHash: hash2, hook: "#!/bin/sh\nenv | grep -v -e '^SHLVL=' -e '^_=' | sort\n", - expectedStdout: strings.Join(getExpectedEnv(ctx, t, locator, gitCmdFactory, repo), "\n") + "\n", + expectedStdout: strings.Join(getExpectedEnv(t, ctx, locator, gitCmdFactory, repo), "\n") + "\n", }, { desc: "hook receives arguments", diff --git a/internal/gitaly/linguist/language_stats_test.go b/internal/gitaly/linguist/language_stats_test.go index 02ec820c1..d03e71cf1 100644 --- a/internal/gitaly/linguist/language_stats_test.go +++ b/internal/gitaly/linguist/language_stats_test.go @@ -84,7 +84,7 @@ func TestInitLanguageStats(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -98,7 +98,7 @@ func TestLanguageStats_add(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -169,7 +169,7 @@ func TestLanguageStats_drop(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -228,7 +228,7 @@ func TestLanguageStats_save(t *testing.T) { ctx := testhelper.Context(t) cfg := testcfg.Build(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) diff --git a/internal/gitaly/linguist/linguist_test.go b/internal/gitaly/linguist/linguist_test.go index 5d0ae925e..eaa1f4e06 100644 --- a/internal/gitaly/linguist/linguist_test.go +++ b/internal/gitaly/linguist/linguist_test.go @@ -48,7 +48,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "successful", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -71,7 +71,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "documentation is ignored", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -94,7 +94,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "documentation with overrides", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -119,7 +119,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "vendor is ignored", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -140,7 +140,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "vendor with overrides", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -163,7 +163,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "generated is ignored", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -184,7 +184,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "generated with overrides", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -207,7 +207,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "undetectable languages are ignored", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -226,7 +226,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "undetectable languages with overrides", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -253,7 +253,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "file specific documentation override", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -282,7 +282,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "detectable overrides", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -309,7 +309,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "double star file pattern documentation override", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -344,7 +344,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "empty code files", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -362,7 +362,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "preexisting cache", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -395,7 +395,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "preexisting cache with .gitattributes modified", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -428,7 +428,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "corrupted cache", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -453,7 +453,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "old cache", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -493,7 +493,7 @@ func testInstanceStats(t *testing.T, ctx context.Context) { { desc: "missing commit", setup: func(t *testing.T) (*gitalypb.Repository, string, git.ObjectID) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) @@ -583,7 +583,7 @@ func benchmarkInstanceStats(b *testing.B, ctx context.Context) { catfileCache := catfile.NewCache(cfg) b.Cleanup(catfileCache.Stop) - repoProto, repoPath := gittest.CreateRepository(ctx, b, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(b, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: "benchmark.git", }) diff --git a/internal/gitaly/rubyserver/rubyserver_test.go b/internal/gitaly/rubyserver/rubyserver_test.go index cf35f7538..2c6d4ffac 100644 --- a/internal/gitaly/rubyserver/rubyserver_test.go +++ b/internal/gitaly/rubyserver/rubyserver_test.go @@ -206,7 +206,7 @@ func TestServer_gitconfig(t *testing.T) { `[`, ), 0o666)) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, }) diff --git a/internal/gitaly/service/blob/blobs_test.go b/internal/gitaly/service/blob/blobs_test.go index 7fd40fb1f..8a38ad257 100644 --- a/internal/gitaly/service/blob/blobs_test.go +++ b/internal/gitaly/service/blob/blobs_test.go @@ -39,7 +39,7 @@ func TestListBlobs(t *testing.T) { streamio.WriteBufferSize = 200 ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setup(ctx, t) + cfg, repoProto, repoPath, client := setup(t, ctx) bigBlobContents := bytes.Repeat([]byte{1}, streamio.WriteBufferSize*2+1) bigBlobOID := gittest.WriteBlob(t, cfg, repoPath, bigBlobContents) @@ -283,9 +283,9 @@ func TestListBlobs(t *testing.T) { func TestListAllBlobs(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, _, client := setup(ctx, t) + cfg, repo, _, client := setup(t, ctx) - quarantine, err := quarantine.New(ctx, gittest.RewrittenRepository(ctx, t, cfg, repo), config.NewLocator(cfg)) + quarantine, err := quarantine.New(ctx, gittest.RewrittenRepository(t, ctx, cfg, repo), config.NewLocator(cfg)) require.NoError(t, err) // quarantine.New in Gitaly would receive an already rewritten repository. Gitaly would then calculate @@ -300,9 +300,9 @@ func TestListAllBlobs(t *testing.T) { quarantineRepoWithoutAlternates := proto.Clone(quarantinedRepo).(*gitalypb.Repository) quarantineRepoWithoutAlternates.GitAlternateObjectDirectories = []string{} - emptyRepo, _ := gittest.CreateRepository(ctx, t, cfg) + emptyRepo, _ := gittest.CreateRepository(t, ctx, cfg) - singleBlobRepo, singleBlobRepoPath := gittest.CreateRepository(ctx, t, cfg) + singleBlobRepo, singleBlobRepoPath := gittest.CreateRepository(t, ctx, cfg) blobID := gittest.WriteBlob(t, cfg, singleBlobRepoPath, []byte("foobar")) for _, tc := range []struct { @@ -430,7 +430,7 @@ func BenchmarkListAllBlobs(b *testing.B) { b.StopTimer() ctx := testhelper.Context(b) - _, repoProto, _, client := setup(ctx, b) + _, repoProto, _, client := setup(b, ctx) for _, tc := range []struct { desc string @@ -474,7 +474,7 @@ func BenchmarkListBlobs(b *testing.B) { b.StopTimer() ctx := testhelper.Context(b) - _, repoProto, _, client := setup(ctx, b) + _, repoProto, _, client := setup(b, ctx) for _, tc := range []struct { desc string diff --git a/internal/gitaly/service/blob/get_blob_test.go b/internal/gitaly/service/blob/get_blob_test.go index 635553f9c..dc5f13316 100644 --- a/internal/gitaly/service/blob/get_blob_test.go +++ b/internal/gitaly/service/blob/get_blob_test.go @@ -18,7 +18,7 @@ import ( func TestSuccessfulGetBlob(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setup(ctx, t) + _, repo, _, client := setup(t, ctx) maintenanceMdBlobData := testhelper.MustReadFile(t, "testdata/maintenance-md-blob.txt") testCases := []struct { @@ -88,7 +88,7 @@ func TestSuccessfulGetBlob(t *testing.T) { func TestGetBlobNotFound(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setup(ctx, t) + _, repo, _, client := setup(t, ctx) request := &gitalypb.GetBlobRequest{ Repository: repo, @@ -136,7 +136,7 @@ func getBlob(stream gitalypb.BlobService_GetBlobClient) (int64, string, []byte, func TestFailedGetBlobRequestDueToValidationError(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setup(ctx, t) + _, repo, _, client := setup(t, ctx) oid := "d42783470dc29fde2cf459eb3199ee1d7e3f3a72" diff --git a/internal/gitaly/service/blob/get_blobs_test.go b/internal/gitaly/service/blob/get_blobs_test.go index d363a01c4..639f38884 100644 --- a/internal/gitaly/service/blob/get_blobs_test.go +++ b/internal/gitaly/service/blob/get_blobs_test.go @@ -18,7 +18,7 @@ import ( func TestSuccessfulGetBlobsRequest(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setup(ctx, t) + cfg, repo, repoPath, client := setup(t, ctx) expectedBlobs := []*gitalypb.GetBlobsResponse{ { @@ -134,7 +134,7 @@ func TestSuccessfulGetBlobsRequest(t *testing.T) { func TestFailedGetBlobsRequestDueToValidation(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setup(ctx, t) + _, repo, _, client := setup(t, ctx) testCases := []struct { desc string diff --git a/internal/gitaly/service/blob/lfs_pointers_test.go b/internal/gitaly/service/blob/lfs_pointers_test.go index ec127bd12..4e2c1bd38 100644 --- a/internal/gitaly/service/blob/lfs_pointers_test.go +++ b/internal/gitaly/service/blob/lfs_pointers_test.go @@ -68,7 +68,7 @@ var lfsPointers = map[string]*gitalypb.LFSPointer{ func TestListLFSPointers(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setup(ctx, t) + _, repo, _, client := setup(t, ctx) ctx = testhelper.MergeOutgoingMetadata(ctx, metadata.Pairs(catfile.SessionIDField, "1"), @@ -200,7 +200,7 @@ oid sha256:1111111111111111111111111111111111111111111111111111111111111111 size 12345` t.Run("normal repository", func(t *testing.T) { - _, repo, _, client := setup(ctx, t) + _, repo, _, client := setup(t, ctx) stream, err := client.ListAllLFSPointers(ctx, &gitalypb.ListAllLFSPointersRequest{ Repository: repo, }) @@ -216,7 +216,7 @@ size 12345` }) t.Run("dangling LFS pointer", func(t *testing.T) { - cfg, repo, repoPath, client := setup(ctx, t) + cfg, repo, repoPath, client := setup(t, ctx) hash := gittest.ExecOpts(t, cfg, gittest.ExecConfig{Stdin: strings.NewReader(lfsPointerContents)}, "-C", repoPath, "hash-object", "-w", "--stdin", @@ -243,7 +243,7 @@ size 12345` }) t.Run("quarantine", func(t *testing.T) { - cfg, repoProto, repoPath, client := setup(ctx, t) + cfg, repoProto, repoPath, client := setup(t, ctx) // We're emulating the case where git is receiving data via a push, where objects // are stored in a separate quarantine environment. In this case, LFS pointer checks @@ -295,7 +295,7 @@ size 12345` func TestSuccessfulGetLFSPointersRequest(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setup(ctx, t) + _, repo, _, client := setup(t, ctx) lfsPointerIds := []string{ lfsPointer1, @@ -339,7 +339,7 @@ func TestSuccessfulGetLFSPointersRequest(t *testing.T) { func TestFailedGetLFSPointersRequestDueToValidations(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setup(ctx, t) + _, repo, _, client := setup(t, ctx) testCases := []struct { desc string diff --git a/internal/gitaly/service/blob/testhelper_test.go b/internal/gitaly/service/blob/testhelper_test.go index 4554cfc55..c04dd061f 100644 --- a/internal/gitaly/service/blob/testhelper_test.go +++ b/internal/gitaly/service/blob/testhelper_test.go @@ -23,7 +23,7 @@ func TestMain(m *testing.M) { testhelper.Run(m) } -func setup(ctx context.Context, tb testing.TB) (config.Cfg, *gitalypb.Repository, string, gitalypb.BlobServiceClient) { +func setup(tb testing.TB, ctx context.Context) (config.Cfg, *gitalypb.Repository, string, gitalypb.BlobServiceClient) { cfg := testcfg.Build(tb) addr := testserver.RunGitalyServer(tb, cfg, nil, func(srv *grpc.Server, deps *service.Dependencies) { @@ -50,7 +50,7 @@ func setup(ctx context.Context, tb testing.TB) (config.Cfg, *gitalypb.Repository require.NoError(tb, err) tb.Cleanup(func() { conn.Close() }) - repo, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go b/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go index 9bdacdfad..ab97c0e3f 100644 --- a/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go +++ b/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go @@ -23,7 +23,7 @@ import ( func TestApplyBfgObjectMapStreamSuccess(t *testing.T) { ctx := testhelper.Context(t) - cfg, protoRepo, repoPath, client := setupCleanupService(ctx, t) + cfg, protoRepo, repoPath, client := setupCleanupService(t, ctx) testcfg.BuildGitalyHooks(t, cfg) @@ -64,7 +64,7 @@ func TestApplyBfgObjectMapStreamSuccess(t *testing.T) { tagID, tagID, ) - entries, err := doStreamingRequest(ctx, t, protoRepo, client, objectMapData) + entries, err := doStreamingRequest(t, ctx, protoRepo, client, objectMapData) require.NoError(t, err) // Ensure that the internal refs are gone, but the others still exist @@ -107,14 +107,14 @@ func requireEntry(t *testing.T, entry *gitalypb.ApplyBfgObjectMapStreamResponse_ func TestApplyBfgObjectMapStreamFailsOnInvalidInput(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupCleanupService(ctx, t) + _, repo, _, client := setupCleanupService(t, ctx) - entries, err := doStreamingRequest(ctx, t, repo, client, "invalid-data here as you can see") + entries, err := doStreamingRequest(t, ctx, repo, client, "invalid-data here as you can see") require.Empty(t, entries) testhelper.RequireGrpcCode(t, err, codes.InvalidArgument) } -func doStreamingRequest(ctx context.Context, t *testing.T, repo *gitalypb.Repository, client gitalypb.CleanupServiceClient, objectMap string) ([]*gitalypb.ApplyBfgObjectMapStreamResponse_Entry, error) { +func doStreamingRequest(t *testing.T, ctx context.Context, repo *gitalypb.Repository, client gitalypb.CleanupServiceClient, objectMap string) ([]*gitalypb.ApplyBfgObjectMapStreamResponse_Entry, error) { t.Helper() // Split the data across multiple requests diff --git a/internal/gitaly/service/cleanup/testhelper_test.go b/internal/gitaly/service/cleanup/testhelper_test.go index 6909d67da..b607f87b5 100644 --- a/internal/gitaly/service/cleanup/testhelper_test.go +++ b/internal/gitaly/service/cleanup/testhelper_test.go @@ -23,12 +23,12 @@ func TestMain(m *testing.M) { testhelper.Run(m) } -func setupCleanupService(ctx context.Context, t *testing.T) (config.Cfg, *gitalypb.Repository, string, gitalypb.CleanupServiceClient) { +func setupCleanupService(t *testing.T, ctx context.Context) (config.Cfg, *gitalypb.Repository, string, gitalypb.CleanupServiceClient) { cfg := testcfg.Build(t) cfg.SocketPath = runCleanupServiceServer(t, cfg) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/commit/check_objects_exist_test.go b/internal/gitaly/service/commit/check_objects_exist_test.go index 9628bba02..a40264360 100644 --- a/internal/gitaly/service/commit/check_objects_exist_test.go +++ b/internal/gitaly/service/commit/check_objects_exist_test.go @@ -18,9 +18,9 @@ func TestCheckObjectsExist(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, client := setupCommitService(ctx, t) + cfg, client := setupCommitService(t, ctx) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) commitID1 := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("master"), gittest.WithMessage("commit-1"), diff --git a/internal/gitaly/service/commit/commit_messages_test.go b/internal/gitaly/service/commit/commit_messages_test.go index 8a8534426..257a47892 100644 --- a/internal/gitaly/service/commit/commit_messages_test.go +++ b/internal/gitaly/service/commit/commit_messages_test.go @@ -19,7 +19,7 @@ func TestSuccessfulGetCommitMessagesRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, repoPath, client := setupCommitServiceWithRepo(t, ctx) message1 := strings.Repeat("a\n", helper.MaxCommitOrTagMessageSize*2) message2 := strings.Repeat("b\n", helper.MaxCommitOrTagMessageSize*2) @@ -61,7 +61,7 @@ func TestFailedGetCommitMessagesRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, _, _, client := setupCommitServiceWithRepo(ctx, t) + _, _, _, client := setupCommitServiceWithRepo(t, ctx) testCases := []struct { desc string diff --git a/internal/gitaly/service/commit/commit_signatures_test.go b/internal/gitaly/service/commit/commit_signatures_test.go index 70882228b..7e9237329 100644 --- a/internal/gitaly/service/commit/commit_signatures_test.go +++ b/internal/gitaly/service/commit/commit_signatures_test.go @@ -20,7 +20,7 @@ func TestSuccessfulGetCommitSignaturesRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, repoPath, client := setupCommitServiceWithRepo(t, ctx) commitData := testhelper.MustReadFile(t, "testdata/dc00eb001f41dfac08192ead79c2377c588b82ee.commit") commit := text.ChompBytes(gittest.ExecOpts(t, cfg, gittest.ExecConfig{Stdin: bytes.NewReader(commitData)}, @@ -89,7 +89,7 @@ func TestFailedGetCommitSignaturesRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) testCases := []struct { desc string diff --git a/internal/gitaly/service/commit/commits_by_message_test.go b/internal/gitaly/service/commit/commits_by_message_test.go index b064259d3..a46720f81 100644 --- a/internal/gitaly/service/commit/commits_by_message_test.go +++ b/internal/gitaly/service/commit/commits_by_message_test.go @@ -40,7 +40,7 @@ func TestSuccessfulCommitsByMessageRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) commits := []*gitalypb.GitCommit{ { @@ -161,7 +161,7 @@ func TestFailedCommitsByMessageRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} diff --git a/internal/gitaly/service/commit/count_commits_test.go b/internal/gitaly/service/commit/count_commits_test.go index 301faa742..b2f1a89ed 100644 --- a/internal/gitaly/service/commit/count_commits_test.go +++ b/internal/gitaly/service/commit/count_commits_test.go @@ -19,9 +19,9 @@ func TestSuccessfulCountCommitsRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo1, _, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo1, _, client := setupCommitServiceWithRepo(t, ctx) - repo2, repo2Path := gittest.CreateRepository(ctx, t, cfg) + repo2, repo2Path := gittest.CreateRepository(t, ctx, cfg) commitOID := createCommits(t, cfg, repo2Path, "master", 5, "") createCommits(t, cfg, repo2Path, "another-branch", 3, commitOID) @@ -160,7 +160,7 @@ func TestFailedCountCommitsRequestDueToValidationError(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) revision := []byte("d42783470dc29fde2cf459eb3199ee1d7e3f3a72") diff --git a/internal/gitaly/service/commit/count_diverging_commits_test.go b/internal/gitaly/service/commit/count_diverging_commits_test.go index 25ca341f9..763627010 100644 --- a/internal/gitaly/service/commit/count_diverging_commits_test.go +++ b/internal/gitaly/service/commit/count_diverging_commits_test.go @@ -16,7 +16,7 @@ import ( "google.golang.org/grpc/codes" ) -func createRepoWithDivergentBranches(ctx context.Context, t *testing.T, cfg config.Cfg, leftCommits, rightCommits int, leftBranchName, rightBranchName string) *gitalypb.Repository { +func createRepoWithDivergentBranches(t *testing.T, ctx context.Context, cfg config.Cfg, leftCommits, rightCommits int, leftBranchName, rightBranchName string) *gitalypb.Repository { /* create a branch structure as follows a | @@ -29,7 +29,7 @@ func createRepoWithDivergentBranches(ctx context.Context, t *testing.T, cfg conf f h */ - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) mainCommitOID := createCommits(t, cfg, repoPath, "main", 2, "") createCommits(t, cfg, repoPath, leftBranchName, leftCommits, mainCommitOID) @@ -42,9 +42,9 @@ func TestSuccessfulCountDivergentCommitsRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, client := setupCommitService(ctx, t) + cfg, client := setupCommitService(t, ctx) - testRepo := createRepoWithDivergentBranches(ctx, t, cfg, 3, 3, "left", "right") + testRepo := createRepoWithDivergentBranches(t, ctx, cfg, 3, 3, "left", "right") testCases := []struct { leftRevision string @@ -116,9 +116,9 @@ func TestSuccessfulCountDivergentCommitsRequestWithMaxCount(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, client := setupCommitService(ctx, t) + cfg, client := setupCommitService(t, ctx) - testRepo := createRepoWithDivergentBranches(ctx, t, cfg, 4, 4, "left", "right") + testRepo := createRepoWithDivergentBranches(t, ctx, cfg, 4, 4, "left", "right") testCases := []struct { leftRevision string @@ -161,7 +161,7 @@ func TestFailedCountDivergentCommitsRequestDueToValidationError(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) revision := []byte("d42783470dc29fde2cf459eb3199ee1d7e3f3a72") diff --git a/internal/gitaly/service/commit/filter_shas_with_signatures_test.go b/internal/gitaly/service/commit/filter_shas_with_signatures_test.go index ddd59f018..0bc1cd4eb 100644 --- a/internal/gitaly/service/commit/filter_shas_with_signatures_test.go +++ b/internal/gitaly/service/commit/filter_shas_with_signatures_test.go @@ -15,7 +15,7 @@ func TestFilterShasWithSignaturesSuccessful(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) type testCase struct { desc string diff --git a/internal/gitaly/service/commit/find_all_commits_test.go b/internal/gitaly/service/commit/find_all_commits_test.go index aadbb305b..2a70f45a9 100644 --- a/internal/gitaly/service/commit/find_all_commits_test.go +++ b/internal/gitaly/service/commit/find_all_commits_test.go @@ -18,7 +18,7 @@ func TestSuccessfulFindAllCommitsRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repoProto, _, client := setupCommitServiceWithRepo(ctx, t) + cfg, repoProto, _, client := setupCommitServiceWithRepo(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) refs, err := repo.GetReferences(ctx, "refs/") @@ -161,7 +161,7 @@ func TestFailedFindAllCommitsRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} diff --git a/internal/gitaly/service/commit/find_commit_test.go b/internal/gitaly/service/commit/find_commit_test.go index d7d2a962e..5b593a6da 100644 --- a/internal/gitaly/service/commit/find_commit_test.go +++ b/internal/gitaly/service/commit/find_commit_test.go @@ -22,7 +22,7 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { windows1251Message := testhelper.MustReadFile(t, "testdata/commit-c809470461118b7bcab850f6e9a7ca97ac42f8ea-message.txt") ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupCommitServiceWithRepo(ctx, t) + cfg, repoProto, repoPath, client := setupCommitServiceWithRepo(t, ctx) bigMessage := "An empty commit with REALLY BIG message\n\n" + strings.Repeat("MOAR!\n", 20*1024) bigCommitID := gittest.WriteCommit(t, cfg, repoPath, @@ -240,7 +240,7 @@ func TestFailedFindCommitRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} @@ -301,7 +301,7 @@ func BenchmarkFindCommitWithCache(b *testing.B) { func benchmarkFindCommit(b *testing.B, withCache bool) { ctx := testhelper.Context(b) - cfg, repo, _, client := setupCommitServiceWithRepo(ctx, b) + cfg, repo, _, client := setupCommitServiceWithRepo(b, ctx) // get a list of revisions gitCmdFactory := gittest.NewCommandFactory(b, cfg) @@ -339,12 +339,12 @@ func TestFindCommitWithCache(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, _, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, _, client := setupCommitServiceWithRepo(t, ctx) // get a list of revisions gitCmdFactory := gittest.NewCommandFactory(t, cfg) - logCmd, err := gitCmdFactory.New(ctx, gittest.RewrittenRepository(ctx, t, cfg, repo), + logCmd, err := gitCmdFactory.New(ctx, gittest.RewrittenRepository(t, ctx, cfg, repo), git.SubCmd{Name: "log", Flags: []git.Option{git.Flag{Name: "--format=format:%H"}}}) require.NoError(t, err) diff --git a/internal/gitaly/service/commit/find_commits_test.go b/internal/gitaly/service/commit/find_commits_test.go index 226dc3b33..406cd171e 100644 --- a/internal/gitaly/service/commit/find_commits_test.go +++ b/internal/gitaly/service/commit/find_commits_test.go @@ -23,7 +23,7 @@ func TestFindCommitsFields(t *testing.T) { windows1251Message := testhelper.MustReadFile(t, "testdata/commit-c809470461118b7bcab850f6e9a7ca97ac42f8ea-message.txt") ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) testCases := []struct { id string @@ -179,7 +179,7 @@ func TestSuccessfulFindCommitsRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) testCases := []struct { desc string @@ -437,7 +437,7 @@ func TestSuccessfulFindCommitsRequestWithAltGitObjectDirs(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, repoPath, client := setupCommitServiceWithRepo(t, ctx) altObjectsDir := "./alt-objects" commitID := gittest.WriteCommit(t, cfg, repoPath, @@ -484,7 +484,7 @@ func TestSuccessfulFindCommitsRequestWithAmbiguousRef(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, repoPath, client := setupCommitServiceWithRepo(t, ctx) // These are arbitrary SHAs in the repository. The important part is // that we create a branch using one of them with a different SHA so @@ -512,7 +512,7 @@ func TestFailureFindCommitsRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) testCases := []struct { desc string @@ -556,7 +556,7 @@ func TestFindCommitsRequestWithFollowAndOffset(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) request := &gitalypb.FindCommitsRequest{ Repository: repo, @@ -564,7 +564,7 @@ func TestFindCommitsRequestWithFollowAndOffset(t *testing.T) { Paths: [][]byte{[]byte("CHANGELOG")}, Limit: 100, } - allCommits := getCommits(ctx, t, request, client) + allCommits := getCommits(t, ctx, request, client) totalCommits := len(allCommits) for offset := 0; offset < totalCommits; offset++ { @@ -572,7 +572,7 @@ func TestFindCommitsRequestWithFollowAndOffset(t *testing.T) { ctx := testhelper.Context(t) request.Offset = int32(offset) request.Limit = int32(totalCommits) - commits := getCommits(ctx, t, request, client) + commits := getCommits(t, ctx, request, client) assert.Len(t, commits, totalCommits-offset) assert.Equal(t, allCommits[offset:], commits) }) @@ -583,7 +583,7 @@ func TestFindCommitsWithExceedingOffset(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) stream, err := client.FindCommits(ctx, &gitalypb.FindCommitsRequest{ Repository: repo, @@ -598,7 +598,7 @@ func TestFindCommitsWithExceedingOffset(t *testing.T) { require.EqualError(t, err, "EOF") } -func getCommits(ctx context.Context, t *testing.T, request *gitalypb.FindCommitsRequest, client gitalypb.CommitServiceClient) []*gitalypb.GitCommit { +func getCommits(t *testing.T, ctx context.Context, request *gitalypb.FindCommitsRequest, client gitalypb.CommitServiceClient) []*gitalypb.GitCommit { t.Helper() stream, err := client.FindCommits(ctx, request) @@ -619,7 +619,7 @@ func TestFindCommits_withStats(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) type commitInfo struct { id string @@ -766,7 +766,7 @@ func TestFindCommits_withStats(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - commits := getCommits(ctx, t, tc.request, client) + commits := getCommits(t, ctx, tc.request, client) assert.Equal(t, len(tc.commitStats), len(commits)) for i, commit := range commits { @@ -779,7 +779,7 @@ func TestFindCommits_withStats(t *testing.T) { func BenchmarkCommitStats(b *testing.B) { ctx := testhelper.Context(b) - _, repo, _, client := setupCommitServiceWithRepo(ctx, b) + _, repo, _, client := setupCommitServiceWithRepo(b, ctx) request := &gitalypb.FindCommitsRequest{ Repository: repo, Limit: 100, diff --git a/internal/gitaly/service/commit/isancestor_test.go b/internal/gitaly/service/commit/isancestor_test.go index f1d522d33..413815ecf 100644 --- a/internal/gitaly/service/commit/isancestor_test.go +++ b/internal/gitaly/service/commit/isancestor_test.go @@ -21,7 +21,7 @@ func TestCommitIsAncestorFailure(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) queries := []struct { Request *gitalypb.CommitIsAncestorRequest @@ -81,7 +81,7 @@ func TestCommitIsAncestorSuccess(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) queries := []struct { Request *gitalypb.CommitIsAncestorRequest @@ -168,7 +168,7 @@ func TestSuccessfulIsAncestorRequestWithAltGitObjectDirs(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, repoPath, client := setupCommitServiceWithRepo(t, ctx) parentCommitID := git.ObjectID(text.ChompBytes(gittest.Exec(t, cfg, "-C", repoPath, "rev-parse", "--verify", "HEAD"))) diff --git a/internal/gitaly/service/commit/languages_test.go b/internal/gitaly/service/commit/languages_test.go index 71a79c0ce..df96ae3fe 100644 --- a/internal/gitaly/service/commit/languages_test.go +++ b/internal/gitaly/service/commit/languages_test.go @@ -26,7 +26,7 @@ func testLanguagesFeatured(t *testing.T, ctx context.Context) { cfg.SocketPath = startTestServices(t, cfg) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -59,7 +59,7 @@ func TestFileCountIsZeroWhenFeatureIsDisabled(t *testing.T) { func testFileCountIsZeroWhenFeatureIsDisabled(t *testing.T, ctx context.Context) { t.Parallel() - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) request := &gitalypb.CommitLanguagesRequest{ Repository: repo, @@ -85,7 +85,7 @@ func TestLanguagesEmptyRevision(t *testing.T) { func testLanguagesEmptyRevisionFeatured(t *testing.T, ctx context.Context) { t.Parallel() - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) request := &gitalypb.CommitLanguagesRequest{ Repository: repo, @@ -112,7 +112,7 @@ func TestInvalidCommitLanguagesRequestRevision(t *testing.T) { func testInvalidCommitLanguagesRequestRevisionFeatured(t *testing.T, ctx context.Context) { t.Parallel() - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) _, err := client.CommitLanguages(ctx, &gitalypb.CommitLanguagesRequest{ Repository: repo, @@ -129,7 +129,7 @@ func TestAmbiguousRefCommitLanguagesRequestRevision(t *testing.T) { func testAmbiguousRefCommitLanguagesRequestRevisionFeatured(t *testing.T, ctx context.Context) { t.Parallel() - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) // gitlab-test repo has both a branch and a tag named 'v1.1.0' // b83d6e391c22777fca1ed3012fce84f633d7fed0 refs/heads/v1.1.0 diff --git a/internal/gitaly/service/commit/last_commit_for_path_test.go b/internal/gitaly/service/commit/last_commit_for_path_test.go index 84a7297e5..33261dadb 100644 --- a/internal/gitaly/service/commit/last_commit_for_path_test.go +++ b/internal/gitaly/service/commit/last_commit_for_path_test.go @@ -17,7 +17,7 @@ func TestSuccessfulLastCommitForPathRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) commit := testhelper.GitLabTestCommit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") @@ -77,7 +77,7 @@ func TestFailedLastCommitForPathRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} @@ -135,7 +135,7 @@ func TestSuccessfulLastCommitWithGlobCharacters(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, repoPath, client := setupCommitServiceWithRepo(t, ctx) // This is an arbitrary blob known to exist in the test repository const blobID = "c60514b6d3d6bf4bec1030f70026e34dfbd69ad5" diff --git a/internal/gitaly/service/commit/list_all_commits_test.go b/internal/gitaly/service/commit/list_all_commits_test.go index ae30a7fa3..b5368f57d 100644 --- a/internal/gitaly/service/commit/list_all_commits_test.go +++ b/internal/gitaly/service/commit/list_all_commits_test.go @@ -35,9 +35,9 @@ func TestListAllCommits(t *testing.T) { ctx := testhelper.Context(t) t.Run("empty repo", func(t *testing.T) { - cfg, client := setupCommitService(ctx, t) + cfg, client := setupCommitService(t, ctx) - repo, _ := gittest.CreateRepository(ctx, t, cfg) + repo, _ := gittest.CreateRepository(t, ctx, cfg) stream, err := client.ListAllCommits(ctx, &gitalypb.ListAllCommitsRequest{ Repository: repo, @@ -48,7 +48,7 @@ func TestListAllCommits(t *testing.T) { }) t.Run("normal repo", func(t *testing.T) { - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) stream, err := client.ListAllCommits(ctx, &gitalypb.ListAllCommitsRequest{ Repository: repo, @@ -79,7 +79,7 @@ func TestListAllCommits(t *testing.T) { }) t.Run("pagination", func(t *testing.T) { - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) stream, err := client.ListAllCommits(ctx, &gitalypb.ListAllCommitsRequest{ Repository: repo, @@ -96,7 +96,7 @@ func TestListAllCommits(t *testing.T) { }) t.Run("quarantine directory", func(t *testing.T) { - cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, repoPath, client := setupCommitServiceWithRepo(t, ctx) quarantineDir := filepath.Join("objects", "incoming-123456") require.NoError(t, os.Mkdir(filepath.Join(repoPath, quarantineDir), 0o777)) @@ -140,7 +140,7 @@ func BenchmarkListAllCommits(b *testing.B) { b.StopTimer() ctx := testhelper.Context(b) - _, repo, _, client := setupCommitServiceWithRepo(ctx, b) + _, repo, _, client := setupCommitServiceWithRepo(b, ctx) b.Run("ListAllCommits", func(b *testing.B) { b.ReportAllocs() diff --git a/internal/gitaly/service/commit/list_commits_by_oid_test.go b/internal/gitaly/service/commit/list_commits_by_oid_test.go index 583224673..b597b0c32 100644 --- a/internal/gitaly/service/commit/list_commits_by_oid_test.go +++ b/internal/gitaly/service/commit/list_commits_by_oid_test.go @@ -14,7 +14,7 @@ func TestSuccessfulListCommitsByOidRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) commits := []*gitalypb.GitCommit{ { @@ -156,7 +156,7 @@ func TestSuccessfulListCommitsByOidLargeRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) req := &gitalypb.ListCommitsByOidRequest{ Oid: masterCommitids, diff --git a/internal/gitaly/service/commit/list_commits_by_ref_name_test.go b/internal/gitaly/service/commit/list_commits_by_ref_name_test.go index 73ce4a9ef..ea5546ce8 100644 --- a/internal/gitaly/service/commit/list_commits_by_ref_name_test.go +++ b/internal/gitaly/service/commit/list_commits_by_ref_name_test.go @@ -15,7 +15,7 @@ func TestSuccessfulListCommitsByRefNameRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) testCases := []struct { desc string @@ -171,7 +171,7 @@ func TestSuccessfulListCommitsByRefNameLargeRequest(t *testing.T) { } ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) refNames := [][]byte{} for _, refName := range repositoryRefNames { diff --git a/internal/gitaly/service/commit/list_commits_test.go b/internal/gitaly/service/commit/list_commits_test.go index 9a22fb07a..302cdcef3 100644 --- a/internal/gitaly/service/commit/list_commits_test.go +++ b/internal/gitaly/service/commit/list_commits_test.go @@ -16,7 +16,7 @@ import ( func TestListCommits(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) for _, tc := range []struct { desc string diff --git a/internal/gitaly/service/commit/list_files_test.go b/internal/gitaly/service/commit/list_files_test.go index 628cccc28..5352a271d 100644 --- a/internal/gitaly/service/commit/list_files_test.go +++ b/internal/gitaly/service/commit/list_files_test.go @@ -40,7 +40,7 @@ var defaultFiles = [][]byte{ func TestListFiles_success(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, repoPath, client := setupCommitServiceWithRepo(t, ctx) gittest.Exec(t, cfg, "-C", repoPath, "symbolic-ref", "HEAD", "refs/heads/test-do-not-touch") @@ -127,8 +127,8 @@ func TestListFiles_unbornBranch(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, _, _, client := setupCommitServiceWithRepo(ctx, t) - repo, _ := gittest.CreateRepository(ctx, t, cfg) + cfg, _, _, client := setupCommitServiceWithRepo(t, ctx) + repo, _ := gittest.CreateRepository(t, ctx, cfg) tests := []struct { desc string @@ -201,7 +201,7 @@ func TestListFiles_failure(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, _, _, client := setupCommitServiceWithRepo(ctx, t) + _, _, _, client := setupCommitServiceWithRepo(t, ctx) tests := []struct { desc string @@ -255,7 +255,7 @@ func TestListFiles_invalidRevision(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) stream, err := client.ListFiles(ctx, &gitalypb.ListFilesRequest{ Repository: repo, diff --git a/internal/gitaly/service/commit/list_last_commits_for_tree_test.go b/internal/gitaly/service/commit/list_last_commits_for_tree_test.go index e9d897834..16f7dcba1 100644 --- a/internal/gitaly/service/commit/list_last_commits_for_tree_test.go +++ b/internal/gitaly/service/commit/list_last_commits_for_tree_test.go @@ -24,7 +24,7 @@ func TestSuccessfulListLastCommitsForTreeRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) testCases := []struct { desc string @@ -213,7 +213,7 @@ func TestFailedListLastCommitsForTreeRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) invalidRepo := &gitalypb.Repository{StorageName: "broken", RelativePath: "path"} @@ -321,7 +321,7 @@ func TestNonUtf8ListLastCommitsForTreeRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, repoPath, client := setupCommitServiceWithRepo(t, ctx) // This is an arbitrary blob known to exist in the test repository const blobID = "c60514b6d3d6bf4bec1030f70026e34dfbd69ad5" @@ -352,7 +352,7 @@ func TestSuccessfulListLastCommitsForTreeRequestWithGlobCharacters(t *testing.T) t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, repoPath, client := setupCommitServiceWithRepo(t, ctx) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(gittest.TreeEntry{ Path: ":wq", Mode: "040000", OID: gittest.WriteTree(t, cfg, repoPath, []gittest.TreeEntry{ diff --git a/internal/gitaly/service/commit/raw_blame_test.go b/internal/gitaly/service/commit/raw_blame_test.go index caaf0fba1..aa2375a3d 100644 --- a/internal/gitaly/service/commit/raw_blame_test.go +++ b/internal/gitaly/service/commit/raw_blame_test.go @@ -18,7 +18,7 @@ func TestSuccessfulRawBlameRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) testCases := []struct { revision, path, data, blameRange []byte @@ -77,7 +77,7 @@ func TestFailedRawBlameRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} diff --git a/internal/gitaly/service/commit/stats_test.go b/internal/gitaly/service/commit/stats_test.go index 7f506f65d..744e76a15 100644 --- a/internal/gitaly/service/commit/stats_test.go +++ b/internal/gitaly/service/commit/stats_test.go @@ -18,7 +18,7 @@ func TestCommitStatsSuccess(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) tests := []struct { desc string @@ -82,7 +82,7 @@ func TestCommitStatsFailure(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, _, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, _, client := setupCommitServiceWithRepo(t, ctx) for _, tc := range []struct { desc string diff --git a/internal/gitaly/service/commit/testhelper_test.go b/internal/gitaly/service/commit/testhelper_test.go index d19934928..ececb79e2 100644 --- a/internal/gitaly/service/commit/testhelper_test.go +++ b/internal/gitaly/service/commit/testhelper_test.go @@ -28,8 +28,8 @@ func TestMain(m *testing.M) { } // setupCommitService makes a basic configuration and starts the service with the client. -func setupCommitService(ctx context.Context, tb testing.TB) (config.Cfg, gitalypb.CommitServiceClient) { - cfg, _, _, client := setupCommitServiceCreateRepo(ctx, tb, func(ctx context.Context, tb testing.TB, cfg config.Cfg) (*gitalypb.Repository, string) { +func setupCommitService(tb testing.TB, ctx context.Context) (config.Cfg, gitalypb.CommitServiceClient) { + cfg, _, _, client := setupCommitServiceCreateRepo(tb, ctx, func(tb testing.TB, ctx context.Context, cfg config.Cfg) (*gitalypb.Repository, string) { return nil, "" }) return cfg, client @@ -37,10 +37,10 @@ func setupCommitService(ctx context.Context, tb testing.TB) (config.Cfg, gitalyp // setupCommitServiceWithRepo makes a basic configuration, creates a test repository and starts the service with the client. func setupCommitServiceWithRepo( - ctx context.Context, tb testing.TB, + tb testing.TB, ctx context.Context, ) (config.Cfg, *gitalypb.Repository, string, gitalypb.CommitServiceClient) { - return setupCommitServiceCreateRepo(ctx, tb, func(ctx context.Context, tb testing.TB, cfg config.Cfg) (*gitalypb.Repository, string) { - repo, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + return setupCommitServiceCreateRepo(tb, ctx, func(tb testing.TB, ctx context.Context, cfg config.Cfg) (*gitalypb.Repository, string) { + repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) return repo, repoPath @@ -48,16 +48,16 @@ func setupCommitServiceWithRepo( } func setupCommitServiceCreateRepo( - ctx context.Context, tb testing.TB, - createRepo func(context.Context, testing.TB, config.Cfg) (*gitalypb.Repository, string), + ctx context.Context, + createRepo func(testing.TB, context.Context, config.Cfg) (*gitalypb.Repository, string), ) (config.Cfg, *gitalypb.Repository, string, gitalypb.CommitServiceClient) { cfg := testcfg.Build(tb) cfg.SocketPath = startTestServices(tb, cfg) client := newCommitServiceClient(tb, cfg.SocketPath) - repo, repoPath := createRepo(ctx, tb, cfg) + repo, repoPath := createRepo(tb, ctx, cfg) return cfg, repo, repoPath, client } diff --git a/internal/gitaly/service/commit/tree_entries_test.go b/internal/gitaly/service/commit/tree_entries_test.go index e763619a4..000cbb19c 100644 --- a/internal/gitaly/service/commit/tree_entries_test.go +++ b/internal/gitaly/service/commit/tree_entries_test.go @@ -23,7 +23,7 @@ func TestGetTreeEntries_curlyBraces(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, repoPath, client := setupCommitServiceWithRepo(t, ctx) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(gittest.TreeEntry{ Path: "issue-46261", Mode: "040000", OID: gittest.WriteTree(t, cfg, repoPath, []gittest.TreeEntry{ @@ -85,7 +85,7 @@ func TestGetTreeEntries_successful(t *testing.T) { commitID := "d25b6d94034242f3930dfcfeb6d8d9aac3583992" rootOid := "21bdc8af908562ae485ed46d71dd5426c08b084a" - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) rootEntries := []*gitalypb.TreeEntry{ { @@ -516,7 +516,7 @@ func TestGetTreeEntries_unsuccessful(t *testing.T) { commitID := "d25b6d94034242f3930dfcfeb6d8d9aac3583992" - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) testCases := []struct { description string @@ -563,7 +563,7 @@ func TestGetTreeEntries_deepFlatpath(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, repoPath, client := setupCommitServiceWithRepo(t, ctx) nestingLevel := 12 require.Greater(t, nestingLevel, defaultFlatTreeRecursion, "sanity check: construct folder deeper than default recursion value") @@ -614,7 +614,7 @@ func TestGetTreeEntries_file(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t) + cfg, repo, repoPath, client := setupCommitServiceWithRepo(t, ctx) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(gittest.TreeEntry{ @@ -644,7 +644,7 @@ func TestGetTreeEntries_validation(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) revision := []byte("d42783470dc29fde2cf459eb3199ee1d7e3f3a72") path := []byte("a/b/c") @@ -717,9 +717,9 @@ func TestGetTreeEntries_validation(t *testing.T) { func BenchmarkGetTreeEntries(b *testing.B) { ctx := testhelper.Context(b) - cfg, client := setupCommitService(ctx, b) + cfg, client := setupCommitService(b, ctx) - repo, _ := gittest.CreateRepository(ctx, b, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(b, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: "benchmark.git", }) diff --git a/internal/gitaly/service/commit/tree_entry_test.go b/internal/gitaly/service/commit/tree_entry_test.go index 8d408fc48..ead25eabc 100644 --- a/internal/gitaly/service/commit/tree_entry_test.go +++ b/internal/gitaly/service/commit/tree_entry_test.go @@ -26,7 +26,7 @@ func TestSuccessfulTreeEntry(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) testCases := []struct { revision []byte @@ -155,7 +155,7 @@ func TestFailedTreeEntry(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupCommitServiceWithRepo(ctx, t) + _, repo, _, client := setupCommitServiceWithRepo(t, ctx) revision := []byte("d42783470dc29fde2cf459eb3199ee1d7e3f3a72") path := []byte("a/b/c") diff --git a/internal/gitaly/service/conflicts/list_conflict_files_test.go b/internal/gitaly/service/conflicts/list_conflict_files_test.go index 6052ccd01..64e67216b 100644 --- a/internal/gitaly/service/conflicts/list_conflict_files_test.go +++ b/internal/gitaly/service/conflicts/list_conflict_files_test.go @@ -22,7 +22,7 @@ type conflictFile struct { func TestSuccessfulListConflictFilesRequest(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupConflictsService(ctx, t, nil) + _, repo, _, client := setupConflictsService(t, ctx, nil) ourCommitOid := "1a35b5a77cf6af7edf6703f88e82f6aff613666f" theirCommitOid := "8309e68585b28d61eb85b7e2834849dda6bf1733" @@ -88,7 +88,7 @@ end func TestSuccessfulListConflictFilesRequestWithAncestor(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupConflictsService(ctx, t, nil) + _, repo, _, client := setupConflictsService(t, ctx, nil) ourCommitOid := "824be604a34828eb682305f0d963056cfac87b2d" theirCommitOid := "1450cd639e0bc6721eb02800169e464f212cde06" @@ -134,7 +134,7 @@ func TestSuccessfulListConflictFilesRequestWithAncestor(t *testing.T) { func TestListConflictFilesHugeDiff(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupConflictsService(ctx, t, nil) + cfg, repo, repoPath, client := setupConflictsService(t, ctx, nil) ourCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries( gittest.TreeEntry{Path: "a", Mode: "100644", Content: strings.Repeat("a\n", 128*1024)}, @@ -173,7 +173,7 @@ func TestListConflictFilesHugeDiff(t *testing.T) { func TestListConflictFilesFailedPrecondition(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupConflictsService(ctx, t, nil) + _, repo, _, client := setupConflictsService(t, ctx, nil) testCases := []struct { desc string @@ -230,7 +230,7 @@ func TestListConflictFilesFailedPrecondition(t *testing.T) { func TestListConflictFilesAllowTreeConflicts(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupConflictsService(ctx, t, nil) + _, repo, _, client := setupConflictsService(t, ctx, nil) ourCommitOid := "eb227b3e214624708c474bdab7bde7afc17cefcc" theirCommitOid := "824be604a34828eb682305f0d963056cfac87b2d" @@ -322,7 +322,7 @@ end func TestFailedListConflictFilesRequestDueToValidation(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupConflictsService(ctx, t, nil) + _, repo, _, client := setupConflictsService(t, ctx, nil) ourCommitOid := "0b4bc9a49b562e85de7cc9e834518ea6828729b9" theirCommitOid := "bb5206fee213d983da88c47f9cf4cc6caf9c66dc" diff --git a/internal/gitaly/service/conflicts/resolve_conflicts_test.go b/internal/gitaly/service/conflicts/resolve_conflicts_test.go index d1b0ed41f..f4374784c 100644 --- a/internal/gitaly/service/conflicts/resolve_conflicts_test.go +++ b/internal/gitaly/service/conflicts/resolve_conflicts_test.go @@ -69,7 +69,7 @@ func TestSuccessfulResolveConflictsRequestHelper(t *testing.T) { ctx := testhelper.Context(t) hookManager := hook.NewMockManager(t, verifyFuncProxy, verifyFuncProxy, hook.NopUpdate, hook.NopReferenceTransaction) - cfg, repoProto, repoPath, client := setupConflictsService(ctx, t, hookManager) + cfg, repoProto, repoPath, client := setupConflictsService(t, ctx, hookManager) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -203,7 +203,7 @@ func TestResolveConflictsWithRemoteRepo(t *testing.T) { ctx := testhelper.Context(t) hookManager := hook.NewMockManager(t, hook.NopPreReceive, hook.NopPostReceive, hook.NopUpdate, hook.NopReferenceTransaction) - cfg, sourceRepo, sourceRepoPath, client := setupConflictsService(ctx, t, hookManager) + cfg, sourceRepo, sourceRepoPath, client := setupConflictsService(t, ctx, hookManager) testcfg.BuildGitalySSH(t, cfg) testcfg.BuildGitalyHooks(t, cfg) @@ -216,7 +216,7 @@ func TestResolveConflictsWithRemoteRepo(t *testing.T) { ) gittest.Exec(t, cfg, "-C", sourceRepoPath, "update-ref", "refs/heads/source", sourceCommitOID.String()) - targetRepo, targetRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + targetRepo, targetRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) targetBlobOID := gittest.WriteBlob(t, cfg, targetRepoPath, []byte("contents-2\n")) @@ -273,7 +273,7 @@ func TestResolveConflictsWithRemoteRepo(t *testing.T) { func TestResolveConflictsLineEndings(t *testing.T) { ctx := testhelper.Context(t) hookManager := hook.NewMockManager(t, hook.NopPreReceive, hook.NopPostReceive, hook.NopUpdate, hook.NopReferenceTransaction) - cfg, repo, repoPath, client := setupConflictsService(ctx, t, hookManager) + cfg, repo, repoPath, client := setupConflictsService(t, ctx, hookManager) ctx = testhelper.MergeOutgoingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) @@ -393,7 +393,7 @@ func TestResolveConflictsLineEndings(t *testing.T) { func TestResolveConflictsNonOIDRequests(t *testing.T) { ctx := testhelper.Context(t) hookManager := hook.NewMockManager(t, hook.NopPreReceive, hook.NopPostReceive, hook.NopUpdate, hook.NopReferenceTransaction) - cfg, repoProto, _, client := setupConflictsService(ctx, t, hookManager) + cfg, repoProto, _, client := setupConflictsService(t, ctx, hookManager) ctx = testhelper.MergeOutgoingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) @@ -431,7 +431,7 @@ func TestResolveConflictsIdenticalContent(t *testing.T) { ctx := testhelper.Context(t) hookManager := hook.NewMockManager(t, hook.NopPreReceive, hook.NopPostReceive, hook.NopUpdate, hook.NopReferenceTransaction) - cfg, repoProto, repoPath, client := setupConflictsService(ctx, t, hookManager) + cfg, repoProto, repoPath, client := setupConflictsService(t, ctx, hookManager) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -528,7 +528,7 @@ func TestResolveConflictsStableID(t *testing.T) { ctx := testhelper.Context(t) hookManager := hook.NewMockManager(t, hook.NopPreReceive, hook.NopPostReceive, hook.NopUpdate, hook.NopReferenceTransaction) - cfg, repoProto, _, client := setupConflictsService(ctx, t, hookManager) + cfg, repoProto, _, client := setupConflictsService(t, ctx, hookManager) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -596,7 +596,7 @@ func TestResolveConflictsStableID(t *testing.T) { func TestFailedResolveConflictsRequestDueToResolutionError(t *testing.T) { ctx := testhelper.Context(t) hookManager := hook.NewMockManager(t, hook.NopPreReceive, hook.NopPostReceive, hook.NopUpdate, hook.NopReferenceTransaction) - cfg, repo, _, client := setupConflictsService(ctx, t, hookManager) + cfg, repo, _, client := setupConflictsService(t, ctx, hookManager) mdGS := testcfg.GitalyServersMetadataFromCfg(t, cfg) mdFF, _ := metadata.FromOutgoingContext(ctx) @@ -652,7 +652,7 @@ func TestFailedResolveConflictsRequestDueToResolutionError(t *testing.T) { func TestFailedResolveConflictsRequestDueToValidation(t *testing.T) { ctx := testhelper.Context(t) hookManager := hook.NewMockManager(t, hook.NopPreReceive, hook.NopPostReceive, hook.NopUpdate, hook.NopReferenceTransaction) - cfg, repo, _, client := setupConflictsService(ctx, t, hookManager) + cfg, repo, _, client := setupConflictsService(t, ctx, hookManager) mdGS := testcfg.GitalyServersMetadataFromCfg(t, cfg) ourCommitOid := "1450cd639e0bc6721eb02800169e464f212cde06" @@ -818,7 +818,7 @@ func TestResolveConflictsQuarantine(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, sourceRepoProto, sourceRepoPath, client := setupConflictsService(ctx, t, nil) + cfg, sourceRepoProto, sourceRepoPath, client := setupConflictsService(t, ctx, nil) testcfg.BuildGitalySSH(t, cfg) testcfg.BuildGitalyHooks(t, cfg) @@ -843,7 +843,7 @@ func TestResolveConflictsQuarantine(t *testing.T) { exit 1 `)) - targetRepoProto, targetRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + targetRepoProto, targetRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) targetBlobOID := gittest.WriteBlob(t, cfg, targetRepoPath, []byte("contents-2\n")) diff --git a/internal/gitaly/service/conflicts/testhelper_test.go b/internal/gitaly/service/conflicts/testhelper_test.go index d7add6e0b..0c9d3cfa3 100644 --- a/internal/gitaly/service/conflicts/testhelper_test.go +++ b/internal/gitaly/service/conflicts/testhelper_test.go @@ -26,7 +26,7 @@ func TestMain(m *testing.M) { testhelper.Run(m) } -func setupConflictsService(ctx context.Context, tb testing.TB, hookManager hook.Manager) (config.Cfg, *gitalypb.Repository, string, gitalypb.ConflictsServiceClient) { +func setupConflictsService(tb testing.TB, ctx context.Context, hookManager hook.Manager) (config.Cfg, *gitalypb.Repository, string, gitalypb.ConflictsServiceClient) { cfg := testcfg.Build(tb) testcfg.BuildGitalyGit2Go(tb, cfg) @@ -37,7 +37,7 @@ func setupConflictsService(ctx context.Context, tb testing.TB, hookManager hook. client, conn := NewConflictsClient(tb, serverSocketPath) tb.Cleanup(func() { conn.Close() }) - repo, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/diff/commit_test.go b/internal/gitaly/service/diff/commit_test.go index 62f2ed282..90b7bedb3 100644 --- a/internal/gitaly/service/diff/commit_test.go +++ b/internal/gitaly/service/diff/commit_test.go @@ -19,7 +19,7 @@ import ( func TestSuccessfulCommitDiffRequest(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupDiffService(ctx, t) + cfg, repo, repoPath, client := setupDiffService(t, ctx) rightCommit := "ab2c9622c02288a2bbaaf35d96088cfdff31d9d9" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" @@ -185,7 +185,7 @@ func TestSuccessfulCommitDiffRequest(t *testing.T) { func TestSuccessfulCommitDiffRequestWithPaths(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) rightCommit := "e4003da16c1c2c3fc4567700121b17bf8e591c6c" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" @@ -252,7 +252,7 @@ func TestSuccessfulCommitDiffRequestWithPaths(t *testing.T) { func TestSuccessfulCommitDiffRequestWithTypeChangeDiff(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) rightCommit := "184a47d38677e2e439964859b877ae9bc424ab11" leftCommit := "80d56eb72ba5d77fd8af857eced17a7d0640cb82" @@ -292,7 +292,7 @@ func TestSuccessfulCommitDiffRequestWithTypeChangeDiff(t *testing.T) { func TestSuccessfulCommitDiffRequestWithIgnoreWhitespaceChange(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) rightCommit := "e4003da16c1c2c3fc4567700121b17bf8e591c6c" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" @@ -395,7 +395,7 @@ func TestSuccessfulCommitDiffRequestWithIgnoreWhitespaceChange(t *testing.T) { func TestSuccessfulCommitDiffRequestWithWordDiff(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupDiffService(ctx, t) + cfg, repo, repoPath, client := setupDiffService(t, ctx) rightCommit := "ab2c9622c02288a2bbaaf35d96088cfdff31d9d9" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" @@ -580,7 +580,7 @@ func TestSuccessfulCommitDiffRequestWithWordDiff(t *testing.T) { func TestSuccessfulCommitDiffRequestWithLimits(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) rightCommit := "899d3d27b04690ac1cd9ef4d8a74fde0667c57f1" leftCommit := "184a47d38677e2e439964859b877ae9bc424ab11" @@ -791,7 +791,7 @@ func TestSuccessfulCommitDiffRequestWithLimits(t *testing.T) { func TestFailedCommitDiffRequestDueToValidationError(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) rightCommit := "d42783470dc29fde2cf459eb3199ee1d7e3f3a72" leftCommit := rightCommit + "~" // Parent of rightCommit @@ -816,7 +816,7 @@ func TestFailedCommitDiffRequestDueToValidationError(t *testing.T) { func TestFailedCommitDiffRequestWithNonExistentCommit(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) nonExistentCommitID := "deadfacedeadfacedeadfacedeadfacedeadface" leftCommit := nonExistentCommitID + "~" // Parent of rightCommit @@ -830,7 +830,7 @@ func TestFailedCommitDiffRequestWithNonExistentCommit(t *testing.T) { func TestSuccessfulCommitDeltaRequest(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) rightCommit := "742518b2be68fc750bb4c357c0df821a88113286" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" @@ -942,7 +942,7 @@ func TestSuccessfulCommitDeltaRequest(t *testing.T) { func TestSuccessfulCommitDeltaRequestWithPaths(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) rightCommit := "e4003da16c1c2c3fc4567700121b17bf8e591c6c" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" @@ -1000,7 +1000,7 @@ func TestSuccessfulCommitDeltaRequestWithPaths(t *testing.T) { func TestFailedCommitDeltaRequestDueToValidationError(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) rightCommit := "d42783470dc29fde2cf459eb3199ee1d7e3f3a72" leftCommit := rightCommit + "~" // Parent of rightCommit @@ -1025,7 +1025,7 @@ func TestFailedCommitDeltaRequestDueToValidationError(t *testing.T) { func TestFailedCommitDeltaRequestWithNonExistentCommit(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) nonExistentCommitID := "deadfacedeadfacedeadfacedeadfacedeadface" leftCommit := nonExistentCommitID + "~" // Parent of rightCommit diff --git a/internal/gitaly/service/diff/find_changed_paths_test.go b/internal/gitaly/service/diff/find_changed_paths_test.go index 1d771d9bd..997cd656a 100644 --- a/internal/gitaly/service/diff/find_changed_paths_test.go +++ b/internal/gitaly/service/diff/find_changed_paths_test.go @@ -16,7 +16,7 @@ import ( func TestFindChangedPathsRequest_success(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) testCases := []struct { desc string @@ -468,7 +468,7 @@ func TestFindChangedPathsRequest_success(t *testing.T) { func TestFindChangedPathsRequest_failing(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, _, client := setupDiffService(ctx, t, testserver.WithDisablePraefect()) + cfg, repo, _, client := setupDiffService(t, ctx, testserver.WithDisablePraefect()) tests := []struct { desc string diff --git a/internal/gitaly/service/diff/numstat_test.go b/internal/gitaly/service/diff/numstat_test.go index 730e63259..a43dc23cb 100644 --- a/internal/gitaly/service/diff/numstat_test.go +++ b/internal/gitaly/service/diff/numstat_test.go @@ -15,7 +15,7 @@ import ( func TestSuccessfulDiffStatsRequest(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) rightCommit := "e4003da16c1c2c3fc4567700121b17bf8e591c6c" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" @@ -119,7 +119,7 @@ func TestSuccessfulDiffStatsRequest(t *testing.T) { func TestFailedDiffStatsRequest(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) tests := []struct { desc string diff --git a/internal/gitaly/service/diff/raw_test.go b/internal/gitaly/service/diff/raw_test.go index 9dff35451..f1a7d1154 100644 --- a/internal/gitaly/service/diff/raw_test.go +++ b/internal/gitaly/service/diff/raw_test.go @@ -22,7 +22,7 @@ func TestRawDiff_successful(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupDiffService(ctx, t) + cfg, repoProto, repoPath, client := setupDiffService(t, ctx) testcfg.BuildGitalyGit2Go(t, cfg) gitCmdFactory := gittest.NewCommandFactory(t, cfg) @@ -53,7 +53,7 @@ func TestRawDiff_successful(t *testing.T) { // Now that we have read the patch in we verify that it indeed round-trips to the same tree // as the right commit is referring to by reapplying the diff on top of the left commit. - patchedCommitID, err := git2goExecutor.Apply(ctx, gittest.RewrittenRepository(ctx, t, cfg, repoProto), git2go.ApplyParams{ + patchedCommitID, err := git2goExecutor.Apply(ctx, gittest.RewrittenRepository(t, ctx, cfg, repoProto), git2go.ApplyParams{ Repository: repoPath, Committer: signature, ParentCommit: leftCommit, @@ -77,7 +77,7 @@ func TestRawDiff_inputValidation(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) testCases := []struct { desc string @@ -125,7 +125,7 @@ func TestRawPatch_successful(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupDiffService(ctx, t) + cfg, repoProto, repoPath, client := setupDiffService(t, ctx) testcfg.BuildGitalyGit2Go(t, cfg) gitCmdFactory := gittest.NewCommandFactory(t, cfg) @@ -156,7 +156,7 @@ func TestRawPatch_successful(t *testing.T) { // Now that we have read the patch in we verify that it indeed round-trips to the same tree // as the right commit is referring to by reapplying the diff on top of the left commit. - patchedCommitID, err := git2goExecutor.Apply(ctx, gittest.RewrittenRepository(ctx, t, cfg, repoProto), git2go.ApplyParams{ + patchedCommitID, err := git2goExecutor.Apply(ctx, gittest.RewrittenRepository(t, ctx, cfg, repoProto), git2go.ApplyParams{ Repository: repoPath, Committer: signature, ParentCommit: leftCommit, @@ -180,7 +180,7 @@ func TestRawPatch_inputValidation(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) testCases := []struct { desc string @@ -228,7 +228,7 @@ func TestRawPatch_gitlabSignature(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupDiffService(ctx, t) + _, repo, _, client := setupDiffService(t, ctx) rightCommit := "e395f646b1499e8e0279445fc99a0596a65fab7e" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" diff --git a/internal/gitaly/service/diff/testhelper_test.go b/internal/gitaly/service/diff/testhelper_test.go index fe1c4db28..2e5ef12a8 100644 --- a/internal/gitaly/service/diff/testhelper_test.go +++ b/internal/gitaly/service/diff/testhelper_test.go @@ -23,7 +23,7 @@ func TestMain(m *testing.M) { testhelper.Run(m) } -func setupDiffService(ctx context.Context, tb testing.TB, opt ...testserver.GitalyServerOpt) (config.Cfg, *gitalypb.Repository, string, gitalypb.DiffServiceClient) { +func setupDiffService(tb testing.TB, ctx context.Context, opt ...testserver.GitalyServerOpt) (config.Cfg, *gitalypb.Repository, string, gitalypb.DiffServiceClient) { cfg := testcfg.Build(tb) addr := testserver.RunGitalyServer(tb, cfg, nil, func(srv *grpc.Server, deps *service.Dependencies) { @@ -50,7 +50,7 @@ func setupDiffService(ctx context.Context, tb testing.TB, opt ...testserver.Gita require.NoError(tb, err) tb.Cleanup(func() { testhelper.MustClose(tb, conn) }) - repo, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/hook/pack_objects_test.go b/internal/gitaly/service/hook/pack_objects_test.go index 403f3fe77..117c41102 100644 --- a/internal/gitaly/service/hook/pack_objects_test.go +++ b/internal/gitaly/service/hook/pack_objects_test.go @@ -91,7 +91,7 @@ func testServerPackObjectsHookSeparateContextWithRuntimeDir(t *testing.T, ctx co ctx1, cancel := context.WithCancel(ctx) defer cancel() - repo, repoPath := gittest.CreateRepository(ctx1, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx1, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -212,7 +212,7 @@ func testServerPackObjectsHookUsesCache(t *testing.T, ctx context.Context, runti s.packObjectsCache = tlc }}) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -320,7 +320,7 @@ func testServerPackObjectsHookWithSidechannelWithRuntimeDir(t *testing.T, ctx co testserver.WithLogger(logger), testserver.WithConcurrencyTracker(concurrencyTracker), ) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -481,7 +481,7 @@ func TestServer_PackObjectsHookWithSidechannel_invalidArgument(t *testing.T) { cfg.SocketPath = runHooksServer(t, cfg, nil) ctx := testhelper.Context(t) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -542,7 +542,7 @@ func testServerPackObjectsHookWithSidechannelCanceledWithRuntimeDir(t *testing.T defer testhelper.MustClose(t, wt) cfg.SocketPath = runHooksServer(t, cfg, nil) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/hook/post_receive_test.go b/internal/gitaly/service/hook/post_receive_test.go index 90a84a1b8..3e1c4ca8c 100644 --- a/internal/gitaly/service/hook/post_receive_test.go +++ b/internal/gitaly/service/hook/post_receive_test.go @@ -27,7 +27,7 @@ import ( func TestPostReceiveInvalidArgument(t *testing.T) { ctx := testhelper.Context(t) - _, _, _, client := setupHookService(ctx, t) + _, _, _, client := setupHookService(t, ctx) stream, err := client.PostReceiveHook(ctx) require.NoError(t, err) diff --git a/internal/gitaly/service/hook/pre_receive_test.go b/internal/gitaly/service/hook/pre_receive_test.go index c6171174d..791d51eaf 100644 --- a/internal/gitaly/service/hook/pre_receive_test.go +++ b/internal/gitaly/service/hook/pre_receive_test.go @@ -31,7 +31,7 @@ import ( func TestPreReceiveInvalidArgument(t *testing.T) { ctx := testhelper.Context(t) - _, _, _, client := setupHookService(ctx, t) + _, _, _, client := setupHookService(t, ctx) stream, err := client.PreReceiveHook(ctx) require.NoError(t, err) @@ -256,7 +256,7 @@ func TestPreReceive_APIErrors(t *testing.T) { cfg.SocketPath = runHooksServer(t, cfg, nil, testserver.WithGitLabClient(gitlabClient)) ctx := testhelper.Context(t) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -322,7 +322,7 @@ func TestPreReceiveHook_CustomHookErrors(t *testing.T) { cfg.SocketPath = runHooksServer(t, cfg, nil, testserver.WithGitLabClient(gitlabClient)) ctx := testhelper.Context(t) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -457,7 +457,7 @@ func TestPreReceiveHook_Primary(t *testing.T) { cfg.SocketPath = runHooksServer(t, cfg, nil, testserver.WithGitLabClient(gitlabClient)) ctx := testhelper.Context(t) - testRepo, testRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + testRepo, testRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/hook/reference_transaction_test.go b/internal/gitaly/service/hook/reference_transaction_test.go index f8e32ed24..ca038bd21 100644 --- a/internal/gitaly/service/hook/reference_transaction_test.go +++ b/internal/gitaly/service/hook/reference_transaction_test.go @@ -143,7 +143,7 @@ func TestReferenceTransactionHook(t *testing.T) { cfg.SocketPath = runHooksServer(t, cfg, nil, testserver.WithBackchannelRegistry(registry)) ctx := testhelper.Context(t) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/hook/testhelper_test.go b/internal/gitaly/service/hook/testhelper_test.go index 926d16ca4..98e307f07 100644 --- a/internal/gitaly/service/hook/testhelper_test.go +++ b/internal/gitaly/service/hook/testhelper_test.go @@ -23,7 +23,7 @@ func TestMain(m *testing.M) { testhelper.Run(m) } -func setupHookService(ctx context.Context, tb testing.TB) (config.Cfg, *gitalypb.Repository, string, gitalypb.HookServiceClient) { +func setupHookService(tb testing.TB, ctx context.Context) (config.Cfg, *gitalypb.Repository, string, gitalypb.HookServiceClient) { tb.Helper() cfg := testcfg.Build(tb) @@ -31,7 +31,7 @@ func setupHookService(ctx context.Context, tb testing.TB) (config.Cfg, *gitalypb client, conn := newHooksClient(tb, cfg.SocketPath) tb.Cleanup(func() { conn.Close() }) - repo, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/hook/update_test.go b/internal/gitaly/service/hook/update_test.go index 0152dae4f..b5e5b2994 100644 --- a/internal/gitaly/service/hook/update_test.go +++ b/internal/gitaly/service/hook/update_test.go @@ -37,7 +37,7 @@ func TestUpdateInvalidArgument(t *testing.T) { func TestUpdate_CustomHooks(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupHookService(ctx, t) + cfg, repo, repoPath, client := setupHookService(t, ctx) hooksPayload, err := git.NewHooksPayload( cfg, diff --git a/internal/gitaly/service/internalgitaly/walkrepos_test.go b/internal/gitaly/service/internalgitaly/walkrepos_test.go index a29313e5a..f5732ec32 100644 --- a/internal/gitaly/service/internalgitaly/walkrepos_test.go +++ b/internal/gitaly/service/internalgitaly/walkrepos_test.go @@ -47,17 +47,17 @@ func TestWalkRepos(t *testing.T) { // file walk happens lexicographically, so we delete repository in the middle // of the sequence to ensure the walk proceeds normally - testRepo1, testRepo1Path := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + testRepo1, testRepo1Path := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: "a", }) - deletedRepo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + deletedRepo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: "b", }) - testRepo2, testRepo2Path := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + testRepo2, testRepo2Path := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, RelativePath: "c", diff --git a/internal/gitaly/service/objectpool/alternates_test.go b/internal/gitaly/service/objectpool/alternates_test.go index f4b6f14fb..9c4d8a1e1 100644 --- a/internal/gitaly/service/objectpool/alternates_test.go +++ b/internal/gitaly/service/objectpool/alternates_test.go @@ -28,7 +28,7 @@ func TestDisconnectGitAlternates(t *testing.T) { } func testDisconnectGitAlternates(t *testing.T, ctx context.Context) { - cfg, repoProto, repoPath, _, client := setup(ctx, t) + cfg, repoProto, repoPath, _, client := setup(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) gitCmdFactory := gittest.NewCommandFactory(t, cfg) @@ -74,7 +74,7 @@ func TestDisconnectGitAlternatesNoAlternates(t *testing.T) { } func testDisconnectGitAlternatesNoAlternates(t *testing.T, ctx context.Context) { - cfg, repoProto, repoPath, _, client := setup(ctx, t) + cfg, repoProto, repoPath, _, client := setup(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) altPath, err := repo.InfoAlternatesPath() @@ -96,7 +96,7 @@ func TestDisconnectGitAlternatesUnexpectedAlternates(t *testing.T) { } func testDisconnectGitAlternatesUnexpectedAlternates(t *testing.T, ctx context.Context) { - cfg, _, _, _, client := setup(ctx, t) + cfg, _, _, _, client := setup(t, ctx) testCases := []struct { desc string @@ -109,7 +109,7 @@ func testDisconnectGitAlternatesUnexpectedAlternates(t *testing.T, ctx context.C for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -138,7 +138,7 @@ func TestRemoveAlternatesIfOk(t *testing.T) { func testRemoveAlternatesIfOk(t *testing.T, ctx context.Context) { t.Run("pack files are missing", func(t *testing.T) { - cfg, repoProto, repoPath, _, _ := setup(ctx, t) + cfg, repoProto, repoPath, _, _ := setup(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) altPath, err := repo.InfoAlternatesPath() @@ -165,7 +165,7 @@ func testRemoveAlternatesIfOk(t *testing.T, ctx context.Context) { }) t.Run("commit graph exists but object is missing from odb", func(t *testing.T) { - cfg, repoProto, repoPath, _, _ := setup(ctx, t) + cfg, repoProto, repoPath, _, _ := setup(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) altPath, err := repo.InfoAlternatesPath() diff --git a/internal/gitaly/service/objectpool/create_test.go b/internal/gitaly/service/objectpool/create_test.go index f040d6f8f..2ecb56ca8 100644 --- a/internal/gitaly/service/objectpool/create_test.go +++ b/internal/gitaly/service/objectpool/create_test.go @@ -18,7 +18,7 @@ import ( func TestCreate(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, _, _, client := setup(ctx, t) + cfg, repo, _, _, client := setup(t, ctx) pool := initObjectPool(t, cfg, cfg.Storages[0]) @@ -30,7 +30,7 @@ func TestCreate(t *testing.T) { _, err := client.CreateObjectPool(ctx, poolReq) require.NoError(t, err) - pool = rewrittenObjectPool(ctx, t, cfg, pool) + pool = rewrittenObjectPool(t, ctx, cfg, pool) // Checks if the underlying repository is valid require.True(t, pool.IsValid()) @@ -50,7 +50,7 @@ func TestCreate(t *testing.T) { func TestUnsuccessfulCreate(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, _, _, client := setup(ctx, t, testserver.WithDisablePraefect()) + cfg, repo, _, _, client := setup(t, ctx, testserver.WithDisablePraefect()) storageName := repo.GetStorageName() pool := initObjectPool(t, cfg, cfg.Storages[0]) @@ -139,7 +139,7 @@ func TestUnsuccessfulCreate(t *testing.T) { func TestDelete(t *testing.T) { ctx := testhelper.Context(t) - cfg, repoProto, _, _, client := setup(ctx, t) + cfg, repoProto, _, _, client := setup(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) repositoryClient := gitalypb.NewRepositoryServiceClient(extractConn(client)) diff --git a/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go b/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go index 582e7180e..bb4b28984 100644 --- a/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go +++ b/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go @@ -40,7 +40,7 @@ func TestFetchIntoObjectPool_Success(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, locator, client := setup(ctx, t) + cfg, repo, repoPath, locator, client := setup(t, ctx) repoCommit := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch(t.Name())) @@ -59,7 +59,7 @@ func TestFetchIntoObjectPool_Success(t *testing.T) { _, err = client.FetchIntoObjectPool(ctx, req) require.NoError(t, err) - pool = rewrittenObjectPool(ctx, t, cfg, pool) + pool = rewrittenObjectPool(t, ctx, cfg, pool) require.True(t, pool.IsValid(), "ensure underlying repository is valid") @@ -116,7 +116,7 @@ func TestFetchIntoObjectPool_transactional(t *testing.T) { ) testcfg.BuildGitalyHooks(t, cfg) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) conn, err := grpc.Dial(cfg.SocketPath, grpc.WithTransportCredentials(insecure.NewCredentials())) require.NoError(t, err) @@ -227,7 +227,7 @@ func TestFetchIntoObjectPool_CollectLogStatistics(t *testing.T) { ctx := testhelper.Context(t) ctx = ctxlogrus.ToContext(ctx, log.WithField("test", "logging")) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -347,7 +347,7 @@ func TestFetchIntoObjectPool_dfConflict(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, _, client := setup(ctx, t) + cfg, repo, repoPath, _, client := setup(t, ctx) pool := initObjectPool(t, cfg, cfg.Storages[0]) _, err := client.CreateObjectPool(ctx, &gitalypb.CreateObjectPoolRequest{ @@ -380,7 +380,7 @@ func TestFetchIntoObjectPool_dfConflict(t *testing.T) { }) require.NoError(t, err) - poolPath, err := config.NewLocator(cfg).GetRepoPath(gittest.RewrittenRepository(ctx, t, cfg, pool.ToProto().GetRepository())) + poolPath, err := config.NewLocator(cfg).GetRepoPath(gittest.RewrittenRepository(t, ctx, cfg, pool.ToProto().GetRepository())) require.NoError(t, err) // Verify that the conflicting reference exists now. diff --git a/internal/gitaly/service/objectpool/get_test.go b/internal/gitaly/service/objectpool/get_test.go index 3fcef9f97..5bb52c1e7 100644 --- a/internal/gitaly/service/objectpool/get_test.go +++ b/internal/gitaly/service/objectpool/get_test.go @@ -15,7 +15,7 @@ import ( func TestGetObjectPoolSuccess(t *testing.T) { poolCtx := testhelper.Context(t) - cfg, repoProto, _, _, client := setup(poolCtx, t) + cfg, repoProto, _, _, client := setup(t, poolCtx) repo := localrepo.NewTestRepo(t, cfg, repoProto) pool := initObjectPool(t, cfg, cfg.Storages[0]) @@ -39,7 +39,7 @@ func TestGetObjectPoolSuccess(t *testing.T) { func TestGetObjectPoolNoFile(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, _, client := setup(ctx, t) + _, repo, _, _, client := setup(t, ctx) resp, err := client.GetObjectPool(ctx, &gitalypb.GetObjectPoolRequest{ Repository: repo, @@ -51,7 +51,7 @@ func TestGetObjectPoolNoFile(t *testing.T) { func TestGetObjectPoolBadFile(t *testing.T) { ctx := testhelper.Context(t) - _, repo, repoPath, _, client := setup(ctx, t) + _, repo, repoPath, _, client := setup(t, ctx) alternatesFilePath := filepath.Join(repoPath, "objects", "info", "alternates") require.NoError(t, os.MkdirAll(filepath.Dir(alternatesFilePath), 0o755)) diff --git a/internal/gitaly/service/objectpool/link_test.go b/internal/gitaly/service/objectpool/link_test.go index 0ccae96a6..3577fe730 100644 --- a/internal/gitaly/service/objectpool/link_test.go +++ b/internal/gitaly/service/objectpool/link_test.go @@ -20,7 +20,7 @@ import ( func TestLink(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, _, _, client := setup(ctx, t, testserver.WithDisablePraefect()) + cfg, repo, _, _, client := setup(t, ctx, testserver.WithDisablePraefect()) localRepo := localrepo.NewTestRepo(t, cfg, repo) @@ -87,7 +87,7 @@ func TestLink(t *testing.T) { func TestLinkIdempotent(t *testing.T) { ctx := testhelper.Context(t) - cfg, repoProto, _, _, client := setup(ctx, t) + cfg, repoProto, _, _, client := setup(t, ctx) pool := initObjectPool(t, cfg, cfg.Storages[0]) _, err := client.CreateObjectPool(ctx, &gitalypb.CreateObjectPoolRequest{ @@ -110,7 +110,7 @@ func TestLinkIdempotent(t *testing.T) { func TestLinkNoClobber(t *testing.T) { ctx := testhelper.Context(t) - cfg, repoProto, repoPath, _, client := setup(ctx, t) + cfg, repoProto, repoPath, _, client := setup(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) pool := initObjectPool(t, cfg, cfg.Storages[0]) @@ -137,7 +137,7 @@ func TestLinkNoClobber(t *testing.T) { func TestLinkNoPool(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, _, _, client := setup(ctx, t) + cfg, repo, _, _, client := setup(t, ctx) pool := initObjectPool(t, cfg, cfg.Storages[0]) _, err := client.CreateObjectPool(ctx, &gitalypb.CreateObjectPoolRequest{ diff --git a/internal/gitaly/service/objectpool/reduplicate_test.go b/internal/gitaly/service/objectpool/reduplicate_test.go index e05a86309..2eb1e8723 100644 --- a/internal/gitaly/service/objectpool/reduplicate_test.go +++ b/internal/gitaly/service/objectpool/reduplicate_test.go @@ -17,7 +17,7 @@ import ( func TestReduplicate(t *testing.T) { ctx := testhelper.Context(t) - cfg, repoProto, repoPath, _, client := setup(ctx, t) + cfg, repoProto, repoPath, _, client := setup(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) gitCmdFactory := gittest.NewCommandFactory(t, cfg) diff --git a/internal/gitaly/service/objectpool/testhelper_test.go b/internal/gitaly/service/objectpool/testhelper_test.go index 0d37c3f23..f360bfaee 100644 --- a/internal/gitaly/service/objectpool/testhelper_test.go +++ b/internal/gitaly/service/objectpool/testhelper_test.go @@ -45,7 +45,7 @@ func extractConn(client gitalypb.ObjectPoolServiceClient) *grpc.ClientConn { return client.(clientWithConn).conn } -func setup(ctx context.Context, t *testing.T, opts ...testserver.GitalyServerOpt) (config.Cfg, *gitalypb.Repository, string, storage.Locator, gitalypb.ObjectPoolServiceClient) { +func setup(t *testing.T, ctx context.Context, opts ...testserver.GitalyServerOpt) (config.Cfg, *gitalypb.Repository, string, storage.Locator, gitalypb.ObjectPoolServiceClient) { t.Helper() cfg := testcfg.Build(t) @@ -59,7 +59,7 @@ func setup(ctx context.Context, t *testing.T, opts ...testserver.GitalyServerOpt require.NoError(t, err) t.Cleanup(func() { testhelper.MustClose(t, conn) }) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -140,7 +140,7 @@ func initObjectPool(tb testing.TB, cfg config.Cfg, storage config.Storage) *obje // rewrittenObjectPool returns a pool that is rewritten as if it was passed through Praefect. This should be used // to access the pool on the disk if the tests are running with Praefect in front of them. -func rewrittenObjectPool(ctx context.Context, tb testing.TB, cfg config.Cfg, pool *objectpool.ObjectPool) *objectpool.ObjectPool { - replicaPath := gittest.GetReplicaPath(ctx, tb, cfg, pool) +func rewrittenObjectPool(tb testing.TB, ctx context.Context, cfg config.Cfg, pool *objectpool.ObjectPool) *objectpool.ObjectPool { + replicaPath := gittest.GetReplicaPath(tb, ctx, cfg, pool) return newObjectPool(tb, cfg, pool.GetStorageName(), replicaPath) } diff --git a/internal/gitaly/service/operations/apply_patch_test.go b/internal/gitaly/service/operations/apply_patch_test.go index e1a38ab82..5a307e2a0 100644 --- a/internal/gitaly/service/operations/apply_patch_test.go +++ b/internal/gitaly/service/operations/apply_patch_test.go @@ -277,10 +277,10 @@ To restore the original branch and stop patching, run "git am --abort". }, } { t.Run(tc.desc, func(t *testing.T) { - repoPb, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoPb, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoPb) - rewrittenRepo := gittest.RewrittenRepository(ctx, t, cfg, repoPb) + rewrittenRepo := gittest.RewrittenRepository(t, ctx, cfg, repoPb) executor := git2go.NewExecutor(cfg, gittest.NewCommandFactory(t, cfg), config.NewLocator(cfg)) diff --git a/internal/gitaly/service/operations/branches_test.go b/internal/gitaly/service/operations/branches_test.go index 04a91d486..baa8920b9 100644 --- a/internal/gitaly/service/operations/branches_test.go +++ b/internal/gitaly/service/operations/branches_test.go @@ -515,7 +515,7 @@ func TestUserDeleteBranch_allowed(t *testing.T) { gitlab.NewMockClient(t, tc.allowed, gitlab.MockPreReceive, gitlab.MockPostReceive), )) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("branch")) response, err := client.UserDeleteBranch(ctx, &gitalypb.UserDeleteBranchRequest{ diff --git a/internal/gitaly/service/operations/cherry_pick_test.go b/internal/gitaly/service/operations/cherry_pick_test.go index df8cddb24..075b095bb 100644 --- a/internal/gitaly/service/operations/cherry_pick_test.go +++ b/internal/gitaly/service/operations/cherry_pick_test.go @@ -39,7 +39,7 @@ func TestServer_UserCherryPick_successful(t *testing.T) { cherryPickedCommit, err := repo.ReadCommit(ctx, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab") require.NoError(t, err) - testRepoCopy, testRepoCopyPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + testRepoCopy, testRepoCopyPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) // read-only repo diff --git a/internal/gitaly/service/operations/commit_files_test.go b/internal/gitaly/service/operations/commit_files_test.go index 1c23a7646..e51d604fa 100644 --- a/internal/gitaly/service/operations/commit_files_test.go +++ b/internal/gitaly/service/operations/commit_files_test.go @@ -40,7 +40,7 @@ func TestUserCommitFiles(t *testing.T) { targetRelativePath = "target-repository" ) - startRepo, _ := gittest.CreateRepository(ctx, t, cfg) + startRepo, _ := gittest.CreateRepository(t, ctx, cfg) type step struct { actions []*gitalypb.UserCommitFilesRequest @@ -871,7 +871,7 @@ func TestUserCommitFiles(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { const branch = "main" - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ RelativePath: targetRelativePath, }) @@ -929,7 +929,7 @@ func TestUserCommitFilesStableCommitID(t *testing.T) { ctx, cfg, _, _, client := setupOperationsService(t, ctx) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) for key, values := range testcfg.GitalyServersMetadataFromCfg(t, cfg) { @@ -987,7 +987,7 @@ func TestUserCommitFilesQuarantine(t *testing.T) { ctx, cfg, _, _, client := setupOperationsService(t, ctx) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) ctx = testhelper.MergeOutgoingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) @@ -1030,7 +1030,7 @@ func TestSuccessfulUserCommitFilesRequest(t *testing.T) { ctx, cfg, repo, repoPath, client := setupOperationsService(t, ctx) - newRepo, newRepoPath := gittest.CreateRepository(ctx, t, cfg) + newRepo, newRepoPath := gittest.CreateRepository(t, ctx, cfg) filePath := "héllo/wörld" authorName := []byte("Jane Doe") @@ -1155,7 +1155,7 @@ func TestSuccessfulUserCommitFilesRequestMove(t *testing.T) { {content: "foo", infer: true}, } { t.Run(strconv.Itoa(i), func(t *testing.T) { - testRepo, testRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + testRepo, testRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -1293,7 +1293,7 @@ func testSuccessfulUserCommitFilesRemoteRepositoryRequest(setHeader func(header repo := localrepo.NewTestRepo(t, cfg, repoProto) - newRepoProto, _ := gittest.CreateRepository(ctx, t, cfg) + newRepoProto, _ := gittest.CreateRepository(t, ctx, cfg) newRepo := localrepo.NewTestRepo(t, cfg, newRepoProto) targetBranchName := "new" @@ -1329,7 +1329,7 @@ func TestSuccessfulUserCommitFilesRequestWithSpecialCharactersInSignature(t *tes ctx, cfg, _, _, client := setupOperationsService(t, ctx) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) targetBranchName := "master" diff --git a/internal/gitaly/service/operations/merge_test.go b/internal/gitaly/service/operations/merge_test.go index 7e7ab424b..3965bb435 100644 --- a/internal/gitaly/service/operations/merge_test.go +++ b/internal/gitaly/service/operations/merge_test.go @@ -126,7 +126,7 @@ func TestUserMergeBranch_failure(t *testing.T) { ctx := testhelper.Context(t) ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) _ = localrepo.NewTestRepo(t, cfg, repoProto) diff --git a/internal/gitaly/service/operations/rebase_test.go b/internal/gitaly/service/operations/rebase_test.go index d8e216d94..3c3d3a3d1 100644 --- a/internal/gitaly/service/operations/rebase_test.go +++ b/internal/gitaly/service/operations/rebase_test.go @@ -39,7 +39,7 @@ func TestUserRebaseConfirmable_successful(t *testing.T) { repo := localrepo.NewTestRepo(t, cfg, repoProto) - repoCopyProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoCopyProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -347,7 +347,7 @@ func TestUserRebaseConfirmable_inputValidation(t *testing.T) { ctx, cfg, repo, repoPath, client := setupOperationsService(t, ctx) - repoCopy, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoCopy, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -422,8 +422,8 @@ func TestUserRebaseConfirmable_abortViaClose(t *testing.T) { for i, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { createRepoOpts := gittest.CreateRepositoryConfig{Seed: gittest.SeedGitLabTest} - testRepo, testRepoPath := gittest.CreateRepository(ctx, t, cfg, createRepoOpts) - testRepoCopy, _ := gittest.CreateRepository(ctx, t, cfg, createRepoOpts) + testRepo, testRepoPath := gittest.CreateRepository(t, ctx, cfg, createRepoOpts) + testRepoCopy, _ := gittest.CreateRepository(t, ctx, cfg, createRepoOpts) branchCommitID := gittest.ResolveRevision(t, cfg, testRepoPath, rebaseBranchName) @@ -469,7 +469,7 @@ func TestUserRebaseConfirmable_abortViaApply(t *testing.T) { repo := localrepo.NewTestRepo(t, cfg, repoProto) - testRepoCopy, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + testRepoCopy, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -509,7 +509,7 @@ func TestUserRebaseConfirmable_preReceiveError(t *testing.T) { ctx, cfg, repoProto, repoPath, client := setupOperationsService(t, testhelper.Context(t)) repo := localrepo.NewTestRepo(t, cfg, repoProto) - repoCopyProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoCopyProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -569,7 +569,7 @@ func TestUserRebaseConfirmable_gitError(t *testing.T) { ctx, cfg, repoProto, repoPath, client := setupOperationsService(t, testhelper.Context(t)) - repoCopyProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoCopyProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -613,10 +613,10 @@ func TestUserRebaseConfirmable_deletedFileInLocalRepo(t *testing.T) { ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) - localRepoProto, localRepoPath := gittest.CreateRepository(ctx, t, cfg) + localRepoProto, localRepoPath := gittest.CreateRepository(t, ctx, cfg) localRepo := localrepo.NewTestRepo(t, cfg, localRepoProto) - remoteRepoProto, remoteRepoPath := gittest.CreateRepository(ctx, t, cfg) + remoteRepoProto, remoteRepoPath := gittest.CreateRepository(t, ctx, cfg) // Write the root commit into both repositories as common history. var rootCommitID git.ObjectID @@ -683,10 +683,10 @@ func TestUserRebaseConfirmable_deletedFileInRemoteRepo(t *testing.T) { ctx := testhelper.Context(t) ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) - localRepoProto, localRepoPath := gittest.CreateRepository(ctx, t, cfg) + localRepoProto, localRepoPath := gittest.CreateRepository(t, ctx, cfg) localRepo := localrepo.NewTestRepo(t, cfg, localRepoProto) - remoteRepoProto, remoteRepoPath := gittest.CreateRepository(ctx, t, cfg) + remoteRepoProto, remoteRepoPath := gittest.CreateRepository(t, ctx, cfg) // Write the root commit into both repositories as common history. var rootCommitID git.ObjectID diff --git a/internal/gitaly/service/operations/revert_test.go b/internal/gitaly/service/operations/revert_test.go index d829d9db9..4dcbe97e2 100644 --- a/internal/gitaly/service/operations/revert_test.go +++ b/internal/gitaly/service/operations/revert_test.go @@ -35,7 +35,7 @@ func TestServer_UserRevert_successful(t *testing.T) { revertedCommit, err := repo.ReadCommit(ctx, "d59c60028b053793cecfb4022de34602e1a9218e") require.NoError(t, err) - testRepoCopy, testRepoCopyPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + testRepoCopy, testRepoCopyPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) // read-only repo @@ -286,7 +286,7 @@ func TestServer_UserRevert_successfulIntoEmptyRepo(t *testing.T) { masterHeadCommit, err := startRepo.ReadCommit(ctx, "master") require.NoError(t, err) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) request := &gitalypb.UserRevertRequest{ diff --git a/internal/gitaly/service/operations/squash_test.go b/internal/gitaly/service/operations/squash_test.go index 3a418a6b0..0c482a330 100644 --- a/internal/gitaly/service/operations/squash_test.go +++ b/internal/gitaly/service/operations/squash_test.go @@ -168,7 +168,7 @@ func TestUserSquash_transactional(t *testing.T) { return nil } - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -326,7 +326,7 @@ func TestUserSquash_renames(t *testing.T) { ctx := testhelper.Context(t) ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) diff --git a/internal/gitaly/service/operations/submodules_test.go b/internal/gitaly/service/operations/submodules_test.go index 43ab9856b..e572224b5 100644 --- a/internal/gitaly/service/operations/submodules_test.go +++ b/internal/gitaly/service/operations/submodules_test.go @@ -374,7 +374,7 @@ func TestFailedUserUpdateSubmoduleRequestDueToRepositoryEmpty(t *testing.T) { ctx, cfg, _, _, client := setupOperationsService(t, ctx) - repo, _ := gittest.CreateRepository(ctx, t, cfg) + repo, _ := gittest.CreateRepository(t, ctx, cfg) request := &gitalypb.UserUpdateSubmoduleRequest{ Repository: repo, diff --git a/internal/gitaly/service/operations/tags_test.go b/internal/gitaly/service/operations/tags_test.go index 12e65e110..64e59f2de 100644 --- a/internal/gitaly/service/operations/tags_test.go +++ b/internal/gitaly/service/operations/tags_test.go @@ -134,7 +134,7 @@ func TestUserCreateTag_successful(t *testing.T) { ctx := testhelper.Context(t) ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents()) @@ -258,7 +258,7 @@ func TestUserCreateTag_transactional(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { *transactionServer = testTransactionServer{} - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) hooksOutputDir := testhelper.TempDir(t) @@ -326,7 +326,7 @@ func TestUserCreateTag_quarantine(t *testing.T) { ctx := testhelper.Context(t) ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents()) @@ -444,7 +444,7 @@ func TestUserCreateTag_message(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents()) @@ -539,7 +539,7 @@ func TestUserCreateTag_targetRevision(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) baseCommit := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithMessage("1")) @@ -587,7 +587,7 @@ func TestUserCreateTag_nonCommitTarget(t *testing.T) { ctx := testhelper.Context(t) ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) blobID := gittest.WriteBlob(t, cfg, repoPath, []byte("content")) treeID := gittest.WriteTree(t, cfg, repoPath, []gittest.TreeEntry{ {Path: "file", Mode: "100644", Content: "something"}, @@ -797,7 +797,7 @@ func TestUserCreateTag_stableTagIDs(t *testing.T) { ctx := testhelper.Context(t) ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents()) @@ -873,7 +873,7 @@ func TestUserCreateTag_prefixedTag(t *testing.T) { ctx := testhelper.Context(t) ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents()) @@ -911,7 +911,7 @@ func TestUserCreateTag_gitHooks(t *testing.T) { for _, hookName := range GitlabHooks { t.Run(hookName, func(t *testing.T) { - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents()) @@ -1065,7 +1065,7 @@ func TestUserCreateTag_hookFailure(t *testing.T) { }, } { t.Run(tc.hook, func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents()) gittest.WriteCustomHook(t, repoPath, tc.hook, []byte( @@ -1102,7 +1102,7 @@ func TestUserCreateTag_preexisting(t *testing.T) { ctx := testhelper.Context(t) ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents()) gittest.WriteTag(t, cfg, repoPath, "v1.1.0", commitID.Revision()) @@ -1158,7 +1158,7 @@ func TestUserCreateTag_invalidArgument(t *testing.T) { ctx := testhelper.Context(t) ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"), gittest.WithParents()) injectedTag := "inject-tag\ntagger . <> 0 +0000\n\nInjected subject\n\n" diff --git a/internal/gitaly/service/operations/testhelper_test.go b/internal/gitaly/service/operations/testhelper_test.go index 13639d586..9ce7a0973 100644 --- a/internal/gitaly/service/operations/testhelper_test.go +++ b/internal/gitaly/service/operations/testhelper_test.go @@ -60,7 +60,7 @@ func setupOperationsServiceWithCfg( md := testcfg.GitalyServersMetadataFromCfg(tb, cfg) ctx = testhelper.MergeOutgoingMetadata(ctx, md) - repo, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/operations/update_branches_test.go b/internal/gitaly/service/operations/update_branches_test.go index 3cffdd11a..ecdce3fda 100644 --- a/internal/gitaly/service/operations/update_branches_test.go +++ b/internal/gitaly/service/operations/update_branches_test.go @@ -175,7 +175,7 @@ func TestSuccessfulGitHooksForUserUpdateBranchRequest(t *testing.T) { for _, hookName := range GitlabHooks { t.Run(hookName, func(t *testing.T) { - testRepo, testRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + testRepo, testRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/ref/branches_test.go b/internal/gitaly/service/ref/branches_test.go index f96fea503..c8519f912 100644 --- a/internal/gitaly/service/ref/branches_test.go +++ b/internal/gitaly/service/ref/branches_test.go @@ -16,7 +16,7 @@ import ( func TestSuccessfulFindBranchRequest(t *testing.T) { ctx := testhelper.Context(t) - cfg, repoProto, _, client := setupRefService(ctx, t) + cfg, repoProto, _, client := setupRefService(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -84,7 +84,7 @@ func TestSuccessfulFindBranchRequest(t *testing.T) { func TestFailedFindBranchRequest(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) testCases := []struct { desc string diff --git a/internal/gitaly/service/ref/delete_refs_test.go b/internal/gitaly/service/ref/delete_refs_test.go index a821999f7..e0e28c7ac 100644 --- a/internal/gitaly/service/ref/delete_refs_test.go +++ b/internal/gitaly/service/ref/delete_refs_test.go @@ -60,7 +60,7 @@ func testDeleteRefSuccessful(t *testing.T, ctx context.Context) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -157,7 +157,7 @@ func testDeleteRefsTransaction(t *testing.T, ctx context.Context) { }, } { t.Run(tc.desc, func(t *testing.T) { - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) txManager.Reset() @@ -183,7 +183,7 @@ func TestDeleteRefs_invalidRefFormat(t *testing.T) { } func testDeleteRefsInvalidRefFormat(t *testing.T, ctx context.Context) { - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) request := &gitalypb.DeleteRefsRequest{ Repository: repo, @@ -221,7 +221,7 @@ func TestDeleteRefs_refLocked(t *testing.T) { } func testDeleteRefsRefLocked(t *testing.T, ctx context.Context) { - cfg, repoProto, _, client := setupRefService(ctx, t) + cfg, repoProto, _, client := setupRefService(t, ctx) if !gittest.GitSupportsStatusFlushing(t, ctx, cfg) { t.Skip("git does not support flushing yet, which is known to be flaky") @@ -270,7 +270,7 @@ func TestDeleteRefs_validation(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) testCases := []struct { desc string diff --git a/internal/gitaly/service/ref/find_all_tags_test.go b/internal/gitaly/service/ref/find_all_tags_test.go index d025afefe..4e69f07f1 100644 --- a/internal/gitaly/service/ref/find_all_tags_test.go +++ b/internal/gitaly/service/ref/find_all_tags_test.go @@ -28,7 +28,7 @@ import ( func TestFindAllTags_successful(t *testing.T) { ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupRefService(ctx, t) + cfg, repoProto, repoPath, client := setupRefService(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) // reconstruct the v1.1.2 tag from patches to test truncated tag message @@ -204,7 +204,7 @@ func TestFindAllTags_simpleNestedTags(t *testing.T) { cfg, client := setupRefServiceWithoutRepo(t) ctx := testhelper.Context(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) commitID := gittest.WriteCommit(t, cfg, repoPath) @@ -243,7 +243,7 @@ func TestFindAllTags_duplicateAnnotatedTags(t *testing.T) { ctx := testhelper.Context(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) commitID := gittest.WriteCommit(t, cfg, repoPath) @@ -316,7 +316,7 @@ func TestFindAllTags_duplicateAnnotatedTags(t *testing.T) { func TestFindAllTags_nestedTags(t *testing.T) { ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupRefService(ctx, t) + cfg, repoProto, repoPath, client := setupRefService(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -464,7 +464,7 @@ func TestFindAllTags_invalidRequest(t *testing.T) { func TestFindAllTags_pagination(t *testing.T) { ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupRefService(ctx, t) + cfg, repoProto, repoPath, client := setupRefService(t, ctx) catfileCache := catfile.NewCache(cfg) defer catfileCache.Stop() @@ -572,7 +572,7 @@ func TestFindAllTags_pagination(t *testing.T) { func TestFindAllTags_sorted(t *testing.T) { ctx := testhelper.Context(t) - cfg, repoProto, _, client := setupRefService(ctx, t) + cfg, repoProto, _, client := setupRefService(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) headCommit, err := repo.ReadCommit(ctx, "HEAD") @@ -703,7 +703,7 @@ func TestFindAllTags_sorted(t *testing.T) { }) t.Run("no tags", func(t *testing.T) { - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) c, err := client.FindAllTags(ctx, &gitalypb.FindAllTagsRequest{ Repository: repoProto, SortBy: &gitalypb.FindAllTagsRequest_SortBy{Key: gitalypb.FindAllTagsRequest_SortBy_REFNAME}, @@ -722,7 +722,7 @@ func BenchmarkFindAllTags(b *testing.B) { cfg, client := setupRefServiceWithoutRepo(b) - repoProto, repoPath := gittest.CreateRepository(ctx, b, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(b, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/ref/find_refs_by_oid_test.go b/internal/gitaly/service/ref/find_refs_by_oid_test.go index cf50884a6..43c305ce8 100644 --- a/internal/gitaly/service/ref/find_refs_by_oid_test.go +++ b/internal/gitaly/service/ref/find_refs_by_oid_test.go @@ -19,7 +19,7 @@ import ( func TestFindRefsByOID_successful(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRefService(ctx, t) + cfg, repo, repoPath, client := setupRefService(t, ctx) oid := gittest.WriteCommit(t, cfg, repoPath) @@ -128,7 +128,7 @@ func TestFindRefsByOID_failure(t *testing.T) { { desc: "no ref exists for OID", setup: func(t *testing.T) (*gitalypb.FindRefsByOIDRequest, error) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) oid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("no ref exists for OID")) @@ -142,7 +142,7 @@ func TestFindRefsByOID_failure(t *testing.T) { { desc: "repository is corrupted", setup: func(t *testing.T) (*gitalypb.FindRefsByOIDRequest, error) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) oid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("no ref exists for OID")) @@ -159,7 +159,7 @@ func TestFindRefsByOID_failure(t *testing.T) { { desc: "repository is missing", setup: func(t *testing.T) (*gitalypb.FindRefsByOIDRequest, error) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) oid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("repository is missing")) @@ -174,7 +174,7 @@ func TestFindRefsByOID_failure(t *testing.T) { { desc: "oid is not a commit", setup: func(t *testing.T) (*gitalypb.FindRefsByOIDRequest, error) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) oid := gittest.WriteBlob(t, cfg, repoPath, []byte("the blob")) @@ -188,7 +188,7 @@ func TestFindRefsByOID_failure(t *testing.T) { { desc: "oid prefix too short", setup: func(t *testing.T) (*gitalypb.FindRefsByOIDRequest, error) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) oid := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("oid prefix too short")) @@ -216,7 +216,7 @@ func TestFindRefsByOID_failure(t *testing.T) { func TestFindRefsByOID_validation(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) testCases := map[string]struct { req *gitalypb.FindRefsByOIDRequest diff --git a/internal/gitaly/service/ref/find_tag_test.go b/internal/gitaly/service/ref/find_tag_test.go index 9baebb4e3..16a159fda 100644 --- a/internal/gitaly/service/ref/find_tag_test.go +++ b/internal/gitaly/service/ref/find_tag_test.go @@ -24,7 +24,7 @@ func TestFindTag_successful(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupRefService(ctx, t) + cfg, repoProto, repoPath, client := setupRefService(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -170,7 +170,7 @@ func TestFindTag_nestedTag(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupRefService(ctx, t) + cfg, repoProto, repoPath, client := setupRefService(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -264,7 +264,7 @@ func TestFindTag_notFound(t *testing.T) { ctx := testhelper.Context(t) cfg, client := setupRefServiceWithoutRepo(t) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) response, err := client.FindTag(ctx, &gitalypb.FindTagRequest{ Repository: repoProto, @@ -290,7 +290,7 @@ func TestFindTag_invalidRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) testCases := []struct { desc string diff --git a/internal/gitaly/service/ref/list_refs_test.go b/internal/gitaly/service/ref/list_refs_test.go index dd89caaf0..b80726367 100644 --- a/internal/gitaly/service/ref/list_refs_test.go +++ b/internal/gitaly/service/ref/list_refs_test.go @@ -17,9 +17,9 @@ import ( func TestServer_ListRefs(t *testing.T) { ctx := testhelper.Context(t) - cfg, _, _, client := setupRefService(ctx, t) + cfg, _, _, client := setupRefService(t, ctx) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) oldCommitID := gittest.WriteCommit(t, cfg, repoPath) newCommitID := gittest.WriteCommit(t, cfg, repoPath, diff --git a/internal/gitaly/service/ref/pack_refs_test.go b/internal/gitaly/service/ref/pack_refs_test.go index cdaa080c0..8ddbdcf4d 100644 --- a/internal/gitaly/service/ref/pack_refs_test.go +++ b/internal/gitaly/service/ref/pack_refs_test.go @@ -25,7 +25,7 @@ func TestPackRefsSuccessfulRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupRefService(ctx, t) + cfg, repoProto, repoPath, client := setupRefService(t, ctx) packedRefs := linesInPackfile(t, repoPath) diff --git a/internal/gitaly/service/ref/refexists_test.go b/internal/gitaly/service/ref/refexists_test.go index c30e2e814..b2f3ff7de 100644 --- a/internal/gitaly/service/ref/refexists_test.go +++ b/internal/gitaly/service/ref/refexists_test.go @@ -13,7 +13,7 @@ import ( func TestRefExists(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) badRepo := &gitalypb.Repository{StorageName: "invalid", RelativePath: "/etc/"} diff --git a/internal/gitaly/service/ref/refs_test.go b/internal/gitaly/service/ref/refs_test.go index 1a09d9fa2..4825363fe 100644 --- a/internal/gitaly/service/ref/refs_test.go +++ b/internal/gitaly/service/ref/refs_test.go @@ -35,7 +35,7 @@ func containsRef(refs [][]byte, ref string) bool { func TestSuccessfulFindAllBranchNames(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) rpcRequest := &gitalypb.FindAllBranchNamesRequest{Repository: repo} c, err := client.FindAllBranchNames(ctx, rpcRequest) @@ -60,7 +60,7 @@ func TestSuccessfulFindAllBranchNames(t *testing.T) { func TestFindAllBranchNamesVeryLargeResponse(t *testing.T) { ctx := testhelper.Context(t) - cfg, repoProto, _, client := setupRefService(ctx, t) + cfg, repoProto, _, client := setupRefService(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) updater, err := updateref.New(ctx, repo) @@ -145,7 +145,7 @@ func TestInvalidRepoFindAllBranchNamesRequest(t *testing.T) { func TestSuccessfulFindAllTagNames(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) rpcRequest := &gitalypb.FindAllTagNamesRequest{Repository: repo} c, err := client.FindAllTagNames(ctx, rpcRequest) @@ -207,7 +207,7 @@ func TestInvalidRepoFindAllTagNamesRequest(t *testing.T) { func TestSuccessfulFindDefaultBranchName(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRefService(ctx, t) + cfg, repo, repoPath, client := setupRefService(t, ctx) rpcRequest := &gitalypb.FindDefaultBranchNameRequest{Repository: repo} // The testing repository has no main branch, so we create it and update @@ -222,7 +222,7 @@ func TestSuccessfulFindDefaultBranchName(t *testing.T) { func TestSuccessfulFindDefaultBranchNameLegacy(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) rpcRequest := &gitalypb.FindDefaultBranchNameRequest{Repository: repo} r, err := client.FindDefaultBranchName(ctx, rpcRequest) require.NoError(t, err) @@ -259,7 +259,7 @@ func TestSuccessfulFindLocalBranches(t *testing.T) { } func testSuccessfulFindLocalBranches(t *testing.T, ctx context.Context) { - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) rpcRequest := &gitalypb.FindLocalBranchesRequest{Repository: repo} c, err := client.FindLocalBranches(ctx, rpcRequest) @@ -325,7 +325,7 @@ func TestFindLocalBranchesHugeCommitter(t *testing.T) { } func testFindLocalBranchesHugeCommitter(t *testing.T, ctx context.Context) { - cfg, repo, repoPath, client := setupRefService(ctx, t) + cfg, repo, repoPath, client := setupRefService(t, ctx) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("refs/heads/improve/awesome"), @@ -352,7 +352,7 @@ func TestFindLocalBranchesPagination(t *testing.T) { } func testFindLocalBranchesPagination(t *testing.T, ctx context.Context) { - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) limit := 1 rpcRequest := &gitalypb.FindLocalBranchesRequest{ @@ -425,7 +425,7 @@ func TestFindLocalBranchesPaginationSequence(t *testing.T) { } func testFindLocalBranchesPaginationSequence(t *testing.T, ctx context.Context) { - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) limit := 2 firstRPCRequest := &gitalypb.FindLocalBranchesRequest{ @@ -516,7 +516,7 @@ func TestFindLocalBranchesPaginationWithIncorrectToken(t *testing.T) { } func testFindLocalBranchesPaginationWithIncorrectToken(t *testing.T, ctx context.Context) { - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) limit := 1 rpcRequest := &gitalypb.FindLocalBranchesRequest{ @@ -580,7 +580,7 @@ func testFindLocalBranchesSort(t *testing.T, ctx context.Context) { }, } - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { @@ -644,7 +644,7 @@ func testEmptyFindLocalBranchesRequest(t *testing.T, ctx context.Context) { func TestSuccessfulFindAllBranchesRequest(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRefService(ctx, t) + cfg, repo, repoPath, client := setupRefService(t, ctx) remoteBranch := &gitalypb.FindAllBranchesResponse_Branch{ Name: []byte("refs/remotes/origin/fake-remote-branch"), @@ -694,7 +694,7 @@ func TestSuccessfulFindAllBranchesRequest(t *testing.T) { func TestSuccessfulFindAllBranchesRequestWithMergedBranches(t *testing.T) { ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupRefService(ctx, t) + cfg, repoProto, repoPath, client := setupRefService(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -839,7 +839,7 @@ func readFindAllBranchesResponsesFromClient(t *testing.T, c gitalypb.RefService_ func TestListTagNamesContainingCommit(t *testing.T) { ctx := testhelper.Context(t) - _, repoProto, _, client := setupRefService(ctx, t) + _, repoProto, _, client := setupRefService(t, ctx) testCases := []struct { description string @@ -907,7 +907,7 @@ func TestListTagNamesContainingCommit(t *testing.T) { func TestListBranchNamesContainingCommit(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) testCases := []struct { description string diff --git a/internal/gitaly/service/ref/remote_branches_test.go b/internal/gitaly/service/ref/remote_branches_test.go index a3ec8843d..0379ae780 100644 --- a/internal/gitaly/service/ref/remote_branches_test.go +++ b/internal/gitaly/service/ref/remote_branches_test.go @@ -19,7 +19,7 @@ import ( func TestSuccessfulFindAllRemoteBranchesRequest(t *testing.T) { ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupRefService(ctx, t) + cfg, repoProto, repoPath, client := setupRefService(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -76,7 +76,7 @@ func TestSuccessfulFindAllRemoteBranchesRequest(t *testing.T) { func TestInvalidFindAllRemoteBranchesRequest(t *testing.T) { ctx := testhelper.Context(t) - _, repo, _, client := setupRefService(ctx, t) + _, repo, _, client := setupRefService(t, ctx) testCases := []struct { description string diff --git a/internal/gitaly/service/ref/tag_messages_test.go b/internal/gitaly/service/ref/tag_messages_test.go index 68199f401..0b1cad963 100644 --- a/internal/gitaly/service/ref/tag_messages_test.go +++ b/internal/gitaly/service/ref/tag_messages_test.go @@ -17,7 +17,7 @@ import ( func TestSuccessfulGetTagMessagesRequest(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRefService(ctx, t) + cfg, repo, repoPath, client := setupRefService(t, ctx) message1 := strings.Repeat("a", helper.MaxCommitOrTagMessageSize*2) message2 := strings.Repeat("b", helper.MaxCommitOrTagMessageSize) diff --git a/internal/gitaly/service/ref/tag_signatures_test.go b/internal/gitaly/service/ref/tag_signatures_test.go index 35f91762e..2f5f2a902 100644 --- a/internal/gitaly/service/ref/tag_signatures_test.go +++ b/internal/gitaly/service/ref/tag_signatures_test.go @@ -21,7 +21,7 @@ import ( func TestGetTagSignatures(t *testing.T) { ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupRefService(ctx, t) + cfg, repoProto, repoPath, client := setupRefService(t, ctx) message1 := strings.Repeat("a", helper.MaxCommitOrTagMessageSize) + "\n" signature1 := string(testhelper.MustReadFile(t, "testdata/tag-1e292f8fedd741b75372e19097c76d327140c312-signature")) diff --git a/internal/gitaly/service/ref/testhelper_test.go b/internal/gitaly/service/ref/testhelper_test.go index cd5e4ee1c..2f66789cf 100644 --- a/internal/gitaly/service/ref/testhelper_test.go +++ b/internal/gitaly/service/ref/testhelper_test.go @@ -37,9 +37,9 @@ func TestMain(m *testing.M) { })) } -func setupRefService(ctx context.Context, tb testing.TB) (config.Cfg, *gitalypb.Repository, string, gitalypb.RefServiceClient) { +func setupRefService(tb testing.TB, ctx context.Context) (config.Cfg, *gitalypb.Repository, string, gitalypb.RefServiceClient) { cfg, client := setupRefServiceWithoutRepo(tb) - repo, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) return cfg, repo, repoPath, client diff --git a/internal/gitaly/service/remote/find_remote_repository_test.go b/internal/gitaly/service/remote/find_remote_repository_test.go index 2cd1b2263..9279648b0 100644 --- a/internal/gitaly/service/remote/find_remote_repository_test.go +++ b/internal/gitaly/service/remote/find_remote_repository_test.go @@ -19,7 +19,7 @@ func TestFindRemoteRepository(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRemoteService(ctx, t) + _, repo, _, client := setupRemoteService(t, ctx) ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { infoRefs := testhelper.MustReadFile(t, "testdata/lsremotedata.txt") @@ -39,7 +39,7 @@ func TestFailedFindRemoteRepository(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRemoteService(ctx, t) + _, repo, _, client := setupRemoteService(t, ctx) testCases := []struct { description string diff --git a/internal/gitaly/service/remote/find_remote_root_ref_test.go b/internal/gitaly/service/remote/find_remote_root_ref_test.go index 193946176..d2f937917 100644 --- a/internal/gitaly/service/remote/find_remote_root_ref_test.go +++ b/internal/gitaly/service/remote/find_remote_root_ref_test.go @@ -22,7 +22,7 @@ func TestFindRemoteRootRefSuccess(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRemoteService(ctx, t) + cfg, repo, repoPath, client := setupRemoteService(t, ctx) gitCmdFactory := gittest.NewCommandFactory(t, cfg) const ( @@ -30,7 +30,7 @@ func TestFindRemoteRootRefSuccess(t *testing.T) { secret = "mysecret" ) - port, stopGitServer := gittest.HTTPServer(ctx, t, gitCmdFactory, repoPath, newGitRequestValidationMiddleware(host, secret)) + port, stopGitServer := gittest.HTTPServer(t, ctx, gitCmdFactory, repoPath, newGitRequestValidationMiddleware(host, secret)) defer func() { require.NoError(t, stopGitServer()) }() originURL := fmt.Sprintf("http://127.0.0.1:%d/%s", port, filepath.Base(repoPath)) @@ -61,11 +61,11 @@ func TestFindRemoteRootRefWithUnbornRemoteHead(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, remoteRepo, remoteRepoPath, client := setupRemoteService(ctx, t) + cfg, remoteRepo, remoteRepoPath, client := setupRemoteService(t, ctx) // We're creating an empty repository. Empty repositories do have a HEAD set up, but they // point to an unborn branch because the default branch hasn't yet been created. - _, clientRepoPath := gittest.CreateRepository(ctx, t, cfg) + _, clientRepoPath := gittest.CreateRepository(t, ctx, cfg) gittest.Exec(t, cfg, "-C", remoteRepoPath, "remote", "add", "foo", "file://"+clientRepoPath) response, err := client.FindRemoteRootRef(ctx, &gitalypb.FindRemoteRootRefRequest{ Repository: remoteRepo, @@ -82,7 +82,7 @@ func TestFindRemoteRootRefFailedDueToValidation(t *testing.T) { ctx := testhelper.Context(t) // We're running tests with Praefect disabled given that we don't want to exercise // Praefect's validation, but Gitaly's. - _, repo, _, client := setupRemoteService(ctx, t, testserver.WithDisablePraefect()) + _, repo, _, client := setupRemoteService(t, ctx, testserver.WithDisablePraefect()) invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} @@ -127,7 +127,7 @@ func TestFindRemoteRootRefFailedDueToInvalidRemote(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRemoteService(ctx, t) + _, repo, _, client := setupRemoteService(t, ctx) t.Run("invalid remote URL", func(t *testing.T) { fakeRepoDir := testhelper.TempDir(t) diff --git a/internal/gitaly/service/remote/testhelper_test.go b/internal/gitaly/service/remote/testhelper_test.go index f0a84b358..6736b75d0 100644 --- a/internal/gitaly/service/remote/testhelper_test.go +++ b/internal/gitaly/service/remote/testhelper_test.go @@ -22,7 +22,7 @@ func TestMain(m *testing.M) { testhelper.Run(m) } -func setupRemoteService(ctx context.Context, t *testing.T, opts ...testserver.GitalyServerOpt) (config.Cfg, *gitalypb.Repository, string, gitalypb.RemoteServiceClient) { +func setupRemoteService(t *testing.T, ctx context.Context, opts ...testserver.GitalyServerOpt) (config.Cfg, *gitalypb.Repository, string, gitalypb.RemoteServiceClient) { t.Helper() cfg := testcfg.Build(t) @@ -49,7 +49,7 @@ func setupRemoteService(ctx context.Context, t *testing.T, opts ...testserver.Gi }, opts...) cfg.SocketPath = addr - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/remote/update_remote_mirror_test.go b/internal/gitaly/service/remote/update_remote_mirror_test.go index 18f071787..b1304699c 100644 --- a/internal/gitaly/service/remote/update_remote_mirror_test.go +++ b/internal/gitaly/service/remote/update_remote_mirror_test.go @@ -529,9 +529,9 @@ func TestUpdateRemoteMirror(t *testing.T) { testcfg.BuildGitalyGit2Go(t, cfg) - mirrorRepoPb, mirrorRepoPath := gittest.CreateRepository(ctx, t, cfg) + mirrorRepoPb, mirrorRepoPath := gittest.CreateRepository(t, ctx, cfg) - sourceRepoPb, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg) + sourceRepoPb, sourceRepoPath := gittest.CreateRepository(t, ctx, cfg) // create identical commits in both repositories so we can use them for // the references @@ -559,7 +559,7 @@ func TestUpdateRemoteMirror(t *testing.T) { var commitOID git.ObjectID for _, commit := range commits { var err error - commitOID, err = executor.Commit(ctx, gittest.RewrittenRepository(ctx, t, cfg, c.repoProto), + commitOID, err = executor.Commit(ctx, gittest.RewrittenRepository(t, ctx, cfg, c.repoProto), git2go.CommitCommand{ Repository: c.repoPath, Author: commitSignature, @@ -636,8 +636,8 @@ func TestSuccessfulUpdateRemoteMirrorRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, testRepo, testRepoPath, client := setupRemoteService(ctx, t) - _, mirrorPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + cfg, testRepo, testRepoPath, client := setupRemoteService(t, ctx) + _, mirrorPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -723,9 +723,9 @@ func TestSuccessfulUpdateRemoteMirrorRequestWithWildcards(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, testRepo, testRepoPath, client := setupRemoteService(ctx, t) + cfg, testRepo, testRepoPath, client := setupRemoteService(t, ctx) - _, mirrorPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, mirrorPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -794,10 +794,10 @@ func TestUpdateRemoteMirrorInmemory(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, localRepo, localPath, client := setupRemoteService(ctx, t) + cfg, localRepo, localPath, client := setupRemoteService(t, ctx) gittest.WriteCommit(t, cfg, localPath) - _, remotePath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, remotePath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -824,8 +824,8 @@ func TestSuccessfulUpdateRemoteMirrorRequestWithKeepDivergentRefs(t *testing.T) t.Parallel() ctx := testhelper.Context(t) - cfg, testRepo, testRepoPath, client := setupRemoteService(ctx, t) - _, mirrorPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + cfg, testRepo, testRepoPath, client := setupRemoteService(t, ctx) + _, mirrorPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -896,7 +896,7 @@ func TestFailedUpdateRemoteMirrorRequestDueToValidation(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, testRepo, _, client := setupRemoteService(ctx, t) + _, testRepo, _, client := setupRemoteService(t, ctx) testCases := []struct { desc string diff --git a/internal/gitaly/service/repository/apply_gitattributes_test.go b/internal/gitaly/service/repository/apply_gitattributes_test.go index ddfc888fc..699439040 100644 --- a/internal/gitaly/service/repository/apply_gitattributes_test.go +++ b/internal/gitaly/service/repository/apply_gitattributes_test.go @@ -29,7 +29,7 @@ func TestApplyGitattributesSuccess(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) infoPath := filepath.Join(repoPath, "info") attributesPath := filepath.Join(infoPath, "attributes") @@ -206,7 +206,7 @@ func TestApplyGitattributesFailure(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) tests := []struct { repo *gitalypb.Repository diff --git a/internal/gitaly/service/repository/archive_test.go b/internal/gitaly/service/repository/archive_test.go index b5ac1f0d2..a61f1910e 100644 --- a/internal/gitaly/service/repository/archive_test.go +++ b/internal/gitaly/service/repository/archive_test.go @@ -37,7 +37,7 @@ func TestGetArchive_success(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) formats := []gitalypb.GetArchiveRequest_Format{ gitalypb.GetArchiveRequest_ZIP, @@ -191,7 +191,7 @@ func TestGetArchive_includeLfsBlobs(t *testing.T) { client, serverSocketPath := runRepositoryService(t, cfg, nil) cfg.SocketPath = serverSocketPath - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -282,7 +282,7 @@ func TestGetArchive_inputValidation(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) commitID := "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863" @@ -409,7 +409,7 @@ func TestGetArchive_pathInjection(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) // It used to be possible to inject options into `git-archive(1)`, with the worst outcome // being that an adversary may create or overwrite arbitrary files in the filesystem in case @@ -468,7 +468,7 @@ func TestGetArchive_environment(t *testing.T) { // Intercept commands to git-archive(1) to print the environment. Note that we continue to // execute any other Git commands so that the command factory behaves as expected. - gitCmdFactory := gittest.NewInterceptingCommandFactory(ctx, t, cfg, func(execEnv git.ExecutionEnvironment) string { + gitCmdFactory := gittest.NewInterceptingCommandFactory(t, ctx, cfg, func(execEnv git.ExecutionEnvironment) string { return fmt.Sprintf(`#!/bin/bash if [[ ! "$@" =~ "archive" ]]; then exec %q "$@" @@ -482,7 +482,7 @@ func TestGetArchive_environment(t *testing.T) { client, serverSocketPath := runRepositoryService(t, cfg, nil, testserver.WithGitCommandFactory(gitCmdFactory)) cfg.SocketPath = serverSocketPath - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/repository/backup_custom_hooks_test.go b/internal/gitaly/service/repository/backup_custom_hooks_test.go index 25e898cda..1419bb69e 100644 --- a/internal/gitaly/service/repository/backup_custom_hooks_test.go +++ b/internal/gitaly/service/repository/backup_custom_hooks_test.go @@ -20,7 +20,7 @@ import ( func TestSuccessfullBackupCustomHooksRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) expectedTarResponse := []string{ "custom_hooks/", @@ -58,7 +58,7 @@ func TestSuccessfullBackupCustomHooksRequest(t *testing.T) { func TestSuccessfullBackupCustomHooksSymlink(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) linkTarget := "/var/empty" require.NoError(t, os.Symlink(linkTarget, filepath.Join(repoPath, "custom_hooks")), "Could not create custom_hooks symlink") @@ -86,7 +86,7 @@ func TestSuccessfullBackupCustomHooksSymlink(t *testing.T) { func TestSuccessfullBackupCustomHooksRequestWithNoHooks(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) backupRequest := &gitalypb.BackupCustomHooksRequest{Repository: repo} backupStream, err := client.BackupCustomHooks(ctx, backupRequest) diff --git a/internal/gitaly/service/repository/calculate_checksum_test.go b/internal/gitaly/service/repository/calculate_checksum_test.go index e8f705904..3243f85a4 100644 --- a/internal/gitaly/service/repository/calculate_checksum_test.go +++ b/internal/gitaly/service/repository/calculate_checksum_test.go @@ -20,7 +20,7 @@ func TestSuccessfulCalculateChecksum(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) // Force the refs database of testRepo into a known state require.NoError(t, os.RemoveAll(filepath.Join(repoPath, "refs"))) @@ -44,7 +44,7 @@ func TestEmptyRepositoryCalculateChecksum(t *testing.T) { ctx := testhelper.Context(t) cfg, client := setupRepositoryServiceWithoutRepo(t) - repo, _ := gittest.CreateRepository(ctx, t, cfg) + repo, _ := gittest.CreateRepository(t, ctx, cfg) request := &gitalypb.CalculateChecksumRequest{Repository: repo} @@ -59,7 +59,7 @@ func TestBrokenRepositoryCalculateChecksum(t *testing.T) { ctx := testhelper.Context(t) cfg, client := setupRepositoryServiceWithoutRepo(t) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) // Force an empty HEAD file require.NoError(t, os.Truncate(filepath.Join(repoPath, "HEAD"), 0)) @@ -105,7 +105,7 @@ func TestInvalidRefsCalculateChecksum(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) // Force the refs database of testRepo into a known state require.NoError(t, os.RemoveAll(filepath.Join(repoPath, "refs"))) diff --git a/internal/gitaly/service/repository/cleanup_test.go b/internal/gitaly/service/repository/cleanup_test.go index 3f8901a5a..858ec4ed0 100644 --- a/internal/gitaly/service/repository/cleanup_test.go +++ b/internal/gitaly/service/repository/cleanup_test.go @@ -54,7 +54,7 @@ func TestCleanupDeletesStaleWorktrees(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -91,7 +91,7 @@ func TestCleanupDeletesOrphanedWorktrees(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) worktreeCheckoutPath := filepath.Join(repoPath, worktreePrefix, "test-worktree") basePath := filepath.Join(repoPath, "worktrees") @@ -120,7 +120,7 @@ func TestCleanupDisconnectedWorktrees(t *testing.T) { worktreeAdminDir = "worktrees" ) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) worktreePath := filepath.Join(repoPath, worktreePrefix, worktreeName) worktreeAdminPath := filepath.Join( diff --git a/internal/gitaly/service/repository/commit_graph_test.go b/internal/gitaly/service/repository/commit_graph_test.go index 3d59dd272..889087027 100644 --- a/internal/gitaly/service/repository/commit_graph_test.go +++ b/internal/gitaly/service/repository/commit_graph_test.go @@ -24,7 +24,7 @@ func TestWriteCommitGraph_withExistingCommitGraphCreatedWithDefaults(t *testing. t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) commitGraphPath := filepath.Join(repoPath, stats.CommitGraphRelPath) require.NoError(t, os.RemoveAll(commitGraphPath)) @@ -62,7 +62,7 @@ func TestWriteCommitGraph_withExistingCommitGraphCreatedWithSplit(t *testing.T) t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) commitGraphPath := filepath.Join(repoPath, stats.CommitGraphRelPath) require.NoError(t, os.RemoveAll(commitGraphPath)) @@ -100,7 +100,7 @@ func TestWriteCommitGraph(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) chainPath := filepath.Join(repoPath, stats.CommitGraphChainRelPath) @@ -121,7 +121,7 @@ func TestWriteCommitGraph_validationChecks(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, _, client := setupRepositoryService(ctx, t, testserver.WithDisablePraefect()) + cfg, repo, _, client := setupRepositoryService(t, ctx, testserver.WithDisablePraefect()) for _, tc := range []struct { desc string @@ -164,7 +164,7 @@ func TestUpdateCommitGraph(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) chainPath := filepath.Join(repoPath, stats.CommitGraphChainRelPath) require.NoFileExists(t, chainPath) diff --git a/internal/gitaly/service/repository/config_test.go b/internal/gitaly/service/repository/config_test.go index b07de01f5..7c902e029 100644 --- a/internal/gitaly/service/repository/config_test.go +++ b/internal/gitaly/service/repository/config_test.go @@ -48,7 +48,7 @@ func TestGetConfig(t *testing.T) { } t.Run("normal repo", func(t *testing.T) { - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -64,7 +64,7 @@ func TestGetConfig(t *testing.T) { }) t.Run("missing config", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/repository/create_bundle_from_ref_list_test.go b/internal/gitaly/service/repository/create_bundle_from_ref_list_test.go index ad101c775..8b7bceef6 100644 --- a/internal/gitaly/service/repository/create_bundle_from_ref_list_test.go +++ b/internal/gitaly/service/repository/create_bundle_from_ref_list_test.go @@ -23,7 +23,7 @@ func TestCreateBundleFromRefList_success(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) // Create a work tree with a HEAD pointing to a commit that is missing. CreateBundle should // clean this up before creating the bundle. @@ -73,7 +73,7 @@ func TestCreateBundleFromRefList_missing_ref(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) masterOID := text.ChompBytes(gittest.Exec(t, cfg, "-C", repoPath, "rev-parse", "refs/heads/master")) @@ -111,7 +111,7 @@ func TestCreateBundleFromRefList_validations(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) testCases := []struct { desc string diff --git a/internal/gitaly/service/repository/create_bundle_test.go b/internal/gitaly/service/repository/create_bundle_test.go index 5af46df83..c41982f5f 100644 --- a/internal/gitaly/service/repository/create_bundle_test.go +++ b/internal/gitaly/service/repository/create_bundle_test.go @@ -23,7 +23,7 @@ func TestSuccessfulCreateBundleRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) // Create a work tree with a HEAD pointing to a commit that is missing. CreateBundle should // clean this up before creating the bundle. diff --git a/internal/gitaly/service/repository/create_fork_test.go b/internal/gitaly/service/repository/create_fork_test.go index a9f6d99cb..9542d24f1 100644 --- a/internal/gitaly/service/repository/create_fork_test.go +++ b/internal/gitaly/service/repository/create_fork_test.go @@ -77,7 +77,7 @@ func TestCreateFork_successful(t *testing.T) { client, cfg.SocketPath = runRepositoryService(t, cfg, nil) } - repo, _ := gittest.CreateRepository(ctx, t, cfg, createRepoConfig) + repo, _ := gittest.CreateRepository(t, ctx, cfg, createRepoConfig) ctx = testhelper.MergeOutgoingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) @@ -92,7 +92,7 @@ func TestCreateFork_successful(t *testing.T) { }) require.NoError(t, err) - replicaPath := gittest.GetReplicaPath(ctx, t, cfg, forkedRepo, getReplicaPathConfig) + replicaPath := gittest.GetReplicaPath(t, ctx, cfg, forkedRepo, getReplicaPathConfig) forkedRepoPath := filepath.Join(cfg.Storages[0].Path, replicaPath) gittest.Exec(t, cfg, "-C", forkedRepoPath, "fsck") @@ -115,7 +115,7 @@ func TestCreateFork_refs(t *testing.T) { client, socketPath := runRepositoryService(t, cfg, nil) cfg.SocketPath = socketPath - sourceRepo, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg) + sourceRepo, sourceRepoPath := gittest.CreateRepository(t, ctx, cfg) // Prepare the source repository with a bunch of refs and a non-default HEAD ref so we can // assert that the target repo gets created with the correct set of refs. @@ -146,7 +146,7 @@ func TestCreateFork_refs(t *testing.T) { storagePath, err := config.NewLocator(cfg).GetStorageByName(targetRepo.GetStorageName()) require.NoError(t, err) - targetRepoPath := filepath.Join(storagePath, gittest.GetReplicaPath(ctx, t, cfg, targetRepo)) + targetRepoPath := filepath.Join(storagePath, gittest.GetReplicaPath(t, ctx, cfg, targetRepo)) require.Equal(t, []string{ @@ -176,7 +176,7 @@ func TestCreateFork_fsck(t *testing.T) { ctx := testhelper.Context(t) ctx = testhelper.MergeOutgoingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) // Write a tree into the repository that's known-broken. treeID := gittest.WriteTree(t, cfg, repoPath, []gittest.TreeEntry{ @@ -206,7 +206,7 @@ func TestCreateFork_fsck(t *testing.T) { }) require.NoError(t, err) - forkedRepoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(ctx, t, cfg, forkedRepo)) + forkedRepoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(t, ctx, cfg, forkedRepo)) // Verify that the broken tree is indeed in the fork and that it is reported as broken by // git-fsck(1). @@ -256,7 +256,7 @@ func TestCreateFork_targetExists(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - cfg, repo, _, client := setupRepositoryService(ctx, t) + cfg, repo, _, client := setupRepositoryService(t, ctx) ctx = testhelper.MergeOutgoingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) diff --git a/internal/gitaly/service/repository/create_repository_from_bundle_test.go b/internal/gitaly/service/repository/create_repository_from_bundle_test.go index 015b0d9e6..3de17233b 100644 --- a/internal/gitaly/service/repository/create_repository_from_bundle_test.go +++ b/internal/gitaly/service/repository/create_repository_from_bundle_test.go @@ -36,7 +36,7 @@ func TestCreateRepositoryFromBundle_successful(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) locator := config.NewLocator(cfg) tmpdir, err := tempdir.New(ctx, repo.GetStorageName(), locator) @@ -84,7 +84,7 @@ func TestCreateRepositoryFromBundle_successful(t *testing.T) { require.NoError(t, err) importedRepo := localrepo.NewTestRepo(t, cfg, importedRepoProto) - importedRepoPath, err := locator.GetPath(gittest.RewrittenRepository(ctx, t, cfg, importedRepoProto)) + importedRepoPath, err := locator.GetPath(gittest.RewrittenRepository(t, ctx, cfg, importedRepoProto)) require.NoError(t, err) defer func() { require.NoError(t, os.RemoveAll(importedRepoPath)) }() @@ -108,7 +108,7 @@ func TestCreateRepositoryFromBundle_transactional(t *testing.T) { ctx := testhelper.Context(t) txManager := transaction.NewTrackingManager() - cfg, repoProto, repoPath, client := setupRepositoryService(ctx, t, testserver.WithTransactionManager(txManager)) + cfg, repoProto, repoPath, client := setupRepositoryService(t, ctx, testserver.WithTransactionManager(txManager)) // Reset the votes casted while creating the test repository. txManager.Reset() @@ -160,7 +160,7 @@ func TestCreateRepositoryFromBundle_transactional(t *testing.T) { return transaction.PhasedVote{Vote: vote, Phase: phase} } - createdRepoPath, err := config.NewLocator(cfg).GetRepoPath(gittest.RewrittenRepository(ctx, t, cfg, createdRepo)) + createdRepoPath, err := config.NewLocator(cfg).GetRepoPath(gittest.RewrittenRepository(t, ctx, cfg, createdRepo)) require.NoError(t, err) refsVote := voting.VoteFromData([]byte(strings.Join([]string{ @@ -265,7 +265,7 @@ func TestCreateRepositoryFromBundle_existingRepository(t *testing.T) { // The above test creates the second repository on the server. As this test can run with Praefect in front of it, // we'll use the next replica path Praefect will assign in order to ensure this repository creation conflicts even // with Praefect in front of it. - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ RelativePath: praefectutil.DeriveReplicaPath(1), Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/repository/create_repository_from_snapshot_test.go b/internal/gitaly/service/repository/create_repository_from_snapshot_test.go index a5983eb68..9dde0aea0 100644 --- a/internal/gitaly/service/repository/create_repository_from_snapshot_test.go +++ b/internal/gitaly/service/repository/create_repository_from_snapshot_test.go @@ -76,7 +76,7 @@ func TestCreateRepositoryFromSnapshot_success(t *testing.T) { client, socketPath := runRepositoryService(t, cfg, nil) cfg.SocketPath = socketPath - _, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, sourceRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -107,7 +107,7 @@ func TestCreateRepositoryFromSnapshot_success(t *testing.T) { require.NoError(t, err) testhelper.ProtoEqual(t, rsp, &gitalypb.CreateRepositoryFromSnapshotResponse{}) - repoAbsolutePath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(ctx, t, cfg, repo)) + repoAbsolutePath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(t, ctx, cfg, repo)) require.DirExists(t, repoAbsolutePath) for _, entry := range entries { if strings.HasSuffix(entry, "/") { @@ -132,7 +132,7 @@ func TestCreateRepositoryFromSnapshot_repositoryExists(t *testing.T) { // This creates the first repository on the server. As this test can run with Praefect in front of it, // we'll use the next replica path Praefect will assign in order to ensure this repository creation // conflicts even with Praefect in front of it. - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ RelativePath: praefectutil.DeriveReplicaPath(1), Seed: gittest.SeedGitLabTest, }) @@ -239,7 +239,7 @@ func TestCreateRepositoryFromSnapshot_malformedResponse(t *testing.T) { client, socketPath := runRepositoryService(t, cfg, nil) cfg.SocketPath = socketPath - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/repository/create_repository_from_url_test.go b/internal/gitaly/service/repository/create_repository_from_url_test.go index b2274bd27..3f40a8a72 100644 --- a/internal/gitaly/service/repository/create_repository_from_url_test.go +++ b/internal/gitaly/service/repository/create_repository_from_url_test.go @@ -25,7 +25,7 @@ func TestCreateRepositoryFromURL_successful(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, _, repoPath, client := setupRepositoryService(ctx, t) + cfg, _, repoPath, client := setupRepositoryService(t, ctx) gitCmdFactory := gittest.NewCommandFactory(t, cfg) importedRepo := &gitalypb.Repository{ @@ -35,7 +35,7 @@ func TestCreateRepositoryFromURL_successful(t *testing.T) { user := "username123" password := "password321localhost" - port, stopGitServer := gitServerWithBasicAuth(ctx, t, gitCmdFactory, user, password, repoPath) + port, stopGitServer := gitServerWithBasicAuth(t, ctx, gitCmdFactory, user, password, repoPath) defer func() { require.NoError(t, stopGitServer()) }() @@ -50,7 +50,7 @@ func TestCreateRepositoryFromURL_successful(t *testing.T) { _, err := client.CreateRepositoryFromURL(ctx, req) require.NoError(t, err) - importedRepoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(ctx, t, cfg, importedRepo)) + importedRepoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(t, ctx, cfg, importedRepo)) gittest.Exec(t, cfg, "-C", importedRepoPath, "fsck") @@ -65,7 +65,7 @@ func TestCreateRepositoryFromURL_successfulWithOptionalParameters(t *testing.T) t.Parallel() ctx := testhelper.Context(t) - cfg, _, repoPath, client := setupRepositoryServiceFromMirror(ctx, t) + cfg, _, repoPath, client := setupRepositoryServiceFromMirror(t, ctx) gitCmdFactory := gittest.NewCommandFactory(t, cfg) importedRepo := &gitalypb.Repository{ @@ -75,7 +75,7 @@ func TestCreateRepositoryFromURL_successfulWithOptionalParameters(t *testing.T) user := "username123" password := "password321localhost" - port, stopGitServer := gitServerWithBasicAuth(ctx, t, gitCmdFactory, user, password, repoPath) + port, stopGitServer := gitServerWithBasicAuth(t, ctx, gitCmdFactory, user, password, repoPath) defer func() { require.NoError(t, stopGitServer()) }() @@ -96,7 +96,7 @@ func TestCreateRepositoryFromURL_successfulWithOptionalParameters(t *testing.T) _, err := client.CreateRepositoryFromURL(ctx, req) require.NoError(t, err) - importedRepoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(ctx, t, cfg, importedRepo)) + importedRepoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(t, ctx, cfg, importedRepo)) gittest.Exec(t, cfg, "-C", importedRepoPath, "fsck") @@ -193,7 +193,7 @@ func TestCreateRepositoryFromURL_fsck(t *testing.T) { cfg, client := setupRepositoryServiceWithoutRepo(t) - _, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg) + _, sourceRepoPath := gittest.CreateRepository(t, ctx, cfg) // We're creating a new commit which has a root tree with duplicate entries. git-mktree(1) // allows us to create these trees just fine, but git-fsck(1) complains. @@ -310,8 +310,8 @@ func TestServer_CloneFromURLCommand_withMirror(t *testing.T) { require.Error(t, cmd.Wait()) } -func gitServerWithBasicAuth(ctx context.Context, tb testing.TB, gitCmdFactory git.CommandFactory, user, pass, repoPath string) (int, func() error) { - return gittest.HTTPServer(ctx, tb, gitCmdFactory, repoPath, basicAuthMiddleware(tb, user, pass)) +func gitServerWithBasicAuth(tb testing.TB, ctx context.Context, gitCmdFactory git.CommandFactory, user, pass, repoPath string) (int, func() error) { + return gittest.HTTPServer(tb, ctx, gitCmdFactory, repoPath, basicAuthMiddleware(tb, user, pass)) } func basicAuthMiddleware(tb testing.TB, user, pass string) func(http.ResponseWriter, *http.Request, http.Handler) { diff --git a/internal/gitaly/service/repository/create_repository_test.go b/internal/gitaly/service/repository/create_repository_test.go index d1976715e..40a51873a 100644 --- a/internal/gitaly/service/repository/create_repository_test.go +++ b/internal/gitaly/service/repository/create_repository_test.go @@ -55,7 +55,7 @@ func TestCreateRepository_successful(t *testing.T) { _, err := client.CreateRepository(ctx, req) require.NoError(t, err) - repoDir := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(ctx, t, cfg, repo)) + repoDir := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(t, ctx, cfg, repo)) require.NoError(t, unix.Access(repoDir, unix.R_OK)) require.NoError(t, unix.Access(repoDir, unix.W_OK)) @@ -114,7 +114,7 @@ func TestCreateRepository_withDefaultBranch(t *testing.T) { require.Contains(t, err.Error(), tc.expectedErrString) } else { require.NoError(t, err) - repoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(ctx, t, cfg, repo)) + repoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(t, ctx, cfg, repo)) symRef := text.ChompBytes(gittest.Exec( t, cfg, @@ -197,7 +197,7 @@ func TestCreateRepository_transactional(t *testing.T) { _, err = client.CreateRepository(ctx, &gitalypb.CreateRepositoryRequest{Repository: repo}) require.NoError(t, err) - require.DirExists(t, filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(ctx, t, cfg, repo))) + require.DirExists(t, filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(t, ctx, cfg, repo))) require.Equal(t, 2, len(txManager.Votes()), "expected transactional vote") }) @@ -207,7 +207,7 @@ func TestCreateRepository_transactional(t *testing.T) { // The above test creates the second repository on the server. As this test can run with Praefect in front of it, // we'll use the next replica path Praefect will assign in order to ensure this repository creation conflicts even // with Praefect in front of it. - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ RelativePath: praefectutil.DeriveReplicaPath(2), }) @@ -235,7 +235,7 @@ func TestCreateRepository_idempotent(t *testing.T) { // conflicts even with Praefect in front of it. RelativePath: praefectutil.DeriveReplicaPath(1), } - gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ RelativePath: repo.RelativePath, }) diff --git a/internal/gitaly/service/repository/fetch_bundle_test.go b/internal/gitaly/service/repository/fetch_bundle_test.go index 993c1aab3..81293b39b 100644 --- a/internal/gitaly/service/repository/fetch_bundle_test.go +++ b/internal/gitaly/service/repository/fetch_bundle_test.go @@ -27,7 +27,7 @@ func TestServer_FetchBundle_success(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, _, repoPath, client := setupRepositoryService(ctx, t) + cfg, _, repoPath, client := setupRepositoryService(t, ctx) tmp := testhelper.TempDir(t) bundlePath := filepath.Join(tmp, "test.bundle") @@ -36,7 +36,7 @@ func TestServer_FetchBundle_success(t *testing.T) { gittest.Exec(t, cfg, "-C", repoPath, "bundle", "create", bundlePath, "--all") expectedRefs := gittest.Exec(t, cfg, "-C", repoPath, "show-ref", "--head") - targetRepo, targetRepoPath := gittest.CreateRepository(ctx, t, cfg) + targetRepo, targetRepoPath := gittest.CreateRepository(t, ctx, cfg) stream, err := client.FetchBundle(ctx) require.NoError(t, err) @@ -84,7 +84,7 @@ func TestServer_FetchBundle_transaction(t *testing.T) { gittest.BundleRepo(t, cfg, repoPath, bundlePath) hookManager.Reset() - _, stopGitServer := gittest.HTTPServer(ctx, t, gitCmdFactory, repoPath, nil) + _, stopGitServer := gittest.HTTPServer(t, ctx, gitCmdFactory, repoPath, nil) defer func() { require.NoError(t, stopGitServer()) }() ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true) diff --git a/internal/gitaly/service/repository/fetch_remote_test.go b/internal/gitaly/service/repository/fetch_remote_test.go index 939767ed0..61ea7b92d 100644 --- a/internal/gitaly/service/repository/fetch_remote_test.go +++ b/internal/gitaly/service/repository/fetch_remote_test.go @@ -38,12 +38,12 @@ func TestFetchRemote_checkTagsChanged(t *testing.T) { ctx := testhelper.Context(t) cfg, client := setupRepositoryServiceWithoutRepo(t) - _, remoteRepoPath := gittest.CreateRepository(ctx, t, cfg) + _, remoteRepoPath := gittest.CreateRepository(t, ctx, cfg) gittest.WriteCommit(t, cfg, remoteRepoPath, gittest.WithBranch("main")) t.Run("check tags without tags", func(t *testing.T) { - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) response, err := client.FetchRemote(ctx, &gitalypb.FetchRemoteRequest{ Repository: repoProto, @@ -59,7 +59,7 @@ func TestFetchRemote_checkTagsChanged(t *testing.T) { gittest.WriteTag(t, cfg, remoteRepoPath, "testtag", "main") t.Run("check tags with tags", func(t *testing.T) { - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) // The first fetch should report that the tags have changed, ... response, err := client.FetchRemote(ctx, &gitalypb.FetchRemoteRequest{ @@ -88,7 +88,7 @@ func TestFetchRemote_checkTagsChanged(t *testing.T) { }) t.Run("without checking for changed tags", func(t *testing.T) { - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) // We fetch into the same repository multiple times to assert that `TagsChanged` is // `true` regardless of whether we have the tag locally already or not. @@ -120,7 +120,7 @@ func TestFetchRemote_sshCommand(t *testing.T) { // We ain't got a nice way to intercept the SSH call, so we just write a custom git command // which simply prints the GIT_SSH_COMMAND environment variable. - gitCmdFactory := gittest.NewInterceptingCommandFactory(ctx, t, cfg, func(git.ExecutionEnvironment) string { + gitCmdFactory := gittest.NewInterceptingCommandFactory(t, ctx, cfg, func(git.ExecutionEnvironment) string { return fmt.Sprintf( `#!/bin/sh for arg in $GIT_SSH_COMMAND @@ -183,17 +183,17 @@ func TestFetchRemote_withDefaultRefmaps(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, sourceRepoProto, sourceRepoPath, client := setupRepositoryService(ctx, t) + cfg, sourceRepoProto, sourceRepoPath, client := setupRepositoryService(t, ctx) gitCmdFactory := gittest.NewCommandFactory(t, cfg) sourceRepo := localrepo.NewTestRepo(t, cfg, sourceRepoProto) - targetRepoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + targetRepoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) targetRepo := localrepo.NewTestRepo(t, cfg, targetRepoProto) - port, stopGitServer := gittest.HTTPServer(ctx, t, gitCmdFactory, sourceRepoPath, nil) + port, stopGitServer := gittest.HTTPServer(t, ctx, gitCmdFactory, sourceRepoPath, nil) defer func() { require.NoError(t, stopGitServer()) }() require.NoError(t, sourceRepo.UpdateRef(ctx, "refs/heads/foobar", "refs/heads/master", "")) @@ -226,7 +226,7 @@ func TestFetchRemote_transaction(t *testing.T) { sourceCfg.SocketPath = addr ctx := testhelper.Context(t) - repo, _ := gittest.CreateRepository(ctx, t, sourceCfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, sourceCfg, gittest.CreateRepositoryConfig{ RelativePath: t.Name(), Seed: gittest.SeedGitLabTest, }) @@ -236,7 +236,7 @@ func TestFetchRemote_transaction(t *testing.T) { targetCfg, targetRepoProto, targetRepoPath := testcfg.BuildWithRepo(t) targetGitCmdFactory := gittest.NewCommandFactory(t, targetCfg) - port, stopGitServer := gittest.HTTPServer(ctx, t, targetGitCmdFactory, targetRepoPath, nil) + port, stopGitServer := gittest.HTTPServer(t, ctx, targetGitCmdFactory, targetRepoPath, nil) defer func() { require.NoError(t, stopGitServer()) }() ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true) @@ -260,10 +260,10 @@ func TestFetchRemote_prune(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, _, sourceRepoPath, client := setupRepositoryService(ctx, t) + cfg, _, sourceRepoPath, client := setupRepositoryService(t, ctx) gitCmdFactory := gittest.NewCommandFactory(t, cfg) - port, stopGitServer := gittest.HTTPServer(ctx, t, gitCmdFactory, sourceRepoPath, nil) + port, stopGitServer := gittest.HTTPServer(t, ctx, gitCmdFactory, sourceRepoPath, nil) defer func() { require.NoError(t, stopGitServer()) }() remoteURL := fmt.Sprintf("http://127.0.0.1:%d/%s", port, filepath.Base(sourceRepoPath)) @@ -312,7 +312,7 @@ func TestFetchRemote_prune(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - targetRepoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + targetRepoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) targetRepo := localrepo.NewTestRepo(t, cfg, targetRepoProto) @@ -335,7 +335,7 @@ func TestFetchRemote_force(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, sourceRepoProto, sourceRepoPath, client := setupRepositoryService(ctx, t) + cfg, sourceRepoProto, sourceRepoPath, client := setupRepositoryService(t, ctx) gitCmdFactory := gittest.NewCommandFactory(t, cfg) sourceRepo := localrepo.NewTestRepo(t, cfg, sourceRepoProto) @@ -349,7 +349,7 @@ func TestFetchRemote_force(t *testing.T) { divergingBranchOID := gittest.WriteCommit(t, cfg, sourceRepoPath, gittest.WithBranch("b1")) divergingTagOID := gittest.WriteCommit(t, cfg, sourceRepoPath, gittest.WithBranch("b2")) - port, stopGitServer := gittest.HTTPServer(ctx, t, gitCmdFactory, sourceRepoPath, nil) + port, stopGitServer := gittest.HTTPServer(t, ctx, gitCmdFactory, sourceRepoPath, nil) defer func() { require.NoError(t, stopGitServer()) }() remoteURL := fmt.Sprintf("http://127.0.0.1:%d/%s", port, filepath.Base(sourceRepoPath)) @@ -439,7 +439,7 @@ func TestFetchRemote_force(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - targetRepoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + targetRepoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -480,7 +480,7 @@ func TestFetchRemote_inputValidation(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) const remoteName = "test-repo" httpSrv, _ := remoteHTTPServer(t, remoteName, httpHost, httpToken) @@ -644,7 +644,7 @@ func TestFetchRemote_http(t *testing.T) { for _, tc := range testCases { t.Run(tc.description, func(t *testing.T) { - forkedRepo, forkedRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + forkedRepo, forkedRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -683,9 +683,9 @@ func TestFetchRemote_localPath(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, _, sourceRepoPath, client := setupRepositoryService(ctx, t) + cfg, _, sourceRepoPath, client := setupRepositoryService(t, ctx) - mirrorRepo, mirrorRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + mirrorRepo, mirrorRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -704,7 +704,7 @@ func TestFetchRemote_httpWithRedirect(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) s := httptest.NewServer( http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -729,7 +729,7 @@ func TestFetchRemote_httpWithTimeout(t *testing.T) { t.Parallel() ctx, cancel := context.WithCancel(testhelper.Context(t)) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) s := httptest.NewServer( http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -812,7 +812,7 @@ func TestFetchRemote_pooledRepository(t *testing.T) { // single reference with an object that is neither in the pool member nor in // the remote. If alternate refs are used, then Git will announce it to the // remote as "have". - _, poolRepoPath := gittest.CreateRepository(ctx, t, cfg) + _, poolRepoPath := gittest.CreateRepository(t, ctx, cfg) poolCommitID := gittest.WriteCommit(t, cfg, poolRepoPath, gittest.WithBranch("pooled"), gittest.WithTreeEntries(gittest.TreeEntry{Path: "pool", Mode: "100644", Content: "pool contents"}), @@ -820,13 +820,13 @@ func TestFetchRemote_pooledRepository(t *testing.T) { // Create the pooled repository and link it to its pool. This is the // repository we're fetching into. - pooledRepoProto, pooledRepoPath := gittest.CreateRepository(ctx, t, cfg) + pooledRepoProto, pooledRepoPath := gittest.CreateRepository(t, ctx, cfg) require.NoError(t, os.WriteFile(filepath.Join(pooledRepoPath, "objects", "info", "alternates"), []byte(filepath.Join(poolRepoPath, "objects")), 0o644)) // And then finally create a third repository that emulates the remote side // we're fetching from. We need to create at least one reference so that Git // would actually try to fetch objects. - _, remoteRepoPath := gittest.CreateRepository(ctx, t, cfg) + _, remoteRepoPath := gittest.CreateRepository(t, ctx, cfg) gittest.WriteCommit(t, cfg, remoteRepoPath, gittest.WithBranch("remote"), gittest.WithTreeEntries(gittest.TreeEntry{Path: "remote", Mode: "100644", Content: "remote contents"}), @@ -836,7 +836,7 @@ func TestFetchRemote_pooledRepository(t *testing.T) { // can observe the reference negotiation and check whether alternate refs // are announced or not. var requestBuffer bytes.Buffer - port, stop := gittest.HTTPServer(ctx, t, gitCmdFactory, remoteRepoPath, func(responseWriter http.ResponseWriter, request *http.Request, handler http.Handler) { + port, stop := gittest.HTTPServer(t, ctx, gitCmdFactory, remoteRepoPath, func(responseWriter http.ResponseWriter, request *http.Request, handler http.Handler) { closer := request.Body defer testhelper.MustClose(t, closer) diff --git a/internal/gitaly/service/repository/fetch_test.go b/internal/gitaly/service/repository/fetch_test.go index 7a3a281fd..f41758e9e 100644 --- a/internal/gitaly/service/repository/fetch_test.go +++ b/internal/gitaly/service/repository/fetch_test.go @@ -19,12 +19,12 @@ func TestFetchSourceBranchSourceRepositorySuccess(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, sourceRepo, sourcePath, client := setupRepositoryService(ctx, t) + cfg, sourceRepo, sourcePath, client := setupRepositoryService(t, ctx) md := testcfg.GitalyServersMetadataFromCfg(t, cfg) ctx = testhelper.MergeOutgoingMetadata(ctx, md) - targetRepoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + targetRepoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) targetRepo := localrepo.NewTestRepo(t, cfg, targetRepoProto) @@ -53,7 +53,7 @@ func TestFetchSourceBranchSameRepositorySuccess(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupRepositoryService(ctx, t) + cfg, repoProto, repoPath, client := setupRepositoryService(t, ctx) md := testcfg.GitalyServersMetadataFromCfg(t, cfg) ctx = testhelper.MergeOutgoingMetadata(ctx, md) @@ -84,12 +84,12 @@ func TestFetchSourceBranchBranchNotFound(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, targetRepo, _, client := setupRepositoryService(ctx, t) + cfg, targetRepo, _, client := setupRepositoryService(t, ctx) md := testcfg.GitalyServersMetadataFromCfg(t, cfg) ctx = testhelper.MergeOutgoingMetadata(ctx, md) - sourceRepo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + sourceRepo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -133,12 +133,12 @@ func TestFetchSourceBranchWrongRef(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, targetRepo, _, client := setupRepositoryService(ctx, t) + cfg, targetRepo, _, client := setupRepositoryService(t, ctx) md := testcfg.GitalyServersMetadataFromCfg(t, cfg) ctx = testhelper.MergeOutgoingMetadata(ctx, md) - sourceRepo, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + sourceRepo, sourceRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/repository/fsck_test.go b/internal/gitaly/service/repository/fsck_test.go index b6b27a8c7..265ee58a2 100644 --- a/internal/gitaly/service/repository/fsck_test.go +++ b/internal/gitaly/service/repository/fsck_test.go @@ -18,7 +18,7 @@ func TestFsckSuccess(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) c, err := client.Fsck(ctx, &gitalypb.FsckRequest{Repository: repo}) assert.NoError(t, err) @@ -30,7 +30,7 @@ func TestFsckFailureSeverelyBrokenRepo(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) // This makes the repo severely broken so that `git` does not identify it as a // proper repo. @@ -49,7 +49,7 @@ func TestFsckFailureSlightlyBrokenRepo(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) // This makes the repo slightly broken so that `git` still identify it as a // proper repo, but `fsck` complains about broken refs... diff --git a/internal/gitaly/service/repository/fullpath_test.go b/internal/gitaly/service/repository/fullpath_test.go index ad7be92dc..556ae07d5 100644 --- a/internal/gitaly/service/repository/fullpath_test.go +++ b/internal/gitaly/service/repository/fullpath_test.go @@ -35,7 +35,7 @@ func TestSetFullPath(t *testing.T) { }) t.Run("missing path", func(t *testing.T) { - repo, _ := gittest.CreateRepository(ctx, t, cfg) + repo, _ := gittest.CreateRepository(t, ctx, cfg) response, err := client.SetFullPath(ctx, &gitalypb.SetFullPathRequest{ Repository: repo, @@ -46,7 +46,7 @@ func TestSetFullPath(t *testing.T) { }) t.Run("invalid storage", func(t *testing.T) { - repo, _ := gittest.CreateRepository(ctx, t, cfg) + repo, _ := gittest.CreateRepository(t, ctx, cfg) repo.StorageName = "" response, err := client.SetFullPath(ctx, &gitalypb.SetFullPathRequest{ @@ -83,7 +83,7 @@ func TestSetFullPath(t *testing.T) { }) t.Run("normal repo", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) response, err := client.SetFullPath(ctx, &gitalypb.SetFullPathRequest{ Repository: repo, @@ -97,7 +97,7 @@ func TestSetFullPath(t *testing.T) { }) t.Run("missing config", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) configPath := filepath.Join(repoPath, "config") require.NoError(t, os.Remove(configPath)) @@ -114,7 +114,7 @@ func TestSetFullPath(t *testing.T) { }) t.Run("multiple times", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) for i := 0; i < 5; i++ { response, err := client.SetFullPath(ctx, &gitalypb.SetFullPathRequest{ @@ -130,7 +130,7 @@ func TestSetFullPath(t *testing.T) { }) t.Run("multiple preexisting paths", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) for i := 0; i < 5; i++ { gittest.Exec(t, cfg, "-C", repoPath, "config", "--add", fullPathKey, fmt.Sprintf("foo/%d", i)) @@ -187,7 +187,7 @@ func TestFullPath(t *testing.T) { }) t.Run("missing config", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) configPath := filepath.Join(repoPath, "config") require.NoError(t, os.Remove(configPath)) @@ -201,7 +201,7 @@ func TestFullPath(t *testing.T) { }) t.Run("existing config", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) gittest.Exec(t, cfg, "-C", repoPath, "config", "--add", fullPathKey, "foo/bar") diff --git a/internal/gitaly/service/repository/gc_test.go b/internal/gitaly/service/repository/gc_test.go index b3fd470d5..e64108ef1 100644 --- a/internal/gitaly/service/repository/gc_test.go +++ b/internal/gitaly/service/repository/gc_test.go @@ -35,7 +35,7 @@ func TestGarbageCollectCommitGraph(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) //nolint:staticcheck c, err := client.GarbageCollect(ctx, &gitalypb.GarbageCollectRequest{Repository: repo}) @@ -50,7 +50,7 @@ func TestGarbageCollectSuccess(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) tests := []struct { req *gitalypb.GarbageCollectRequest @@ -103,7 +103,7 @@ func TestGarbageCollectWithPrune(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) blobHashes := gittest.WriteBlobs(t, cfg, repoPath, 3) oldDanglingObjFile := filepath.Join(repoPath, "objects", blobHashes[0][:2], blobHashes[0][2:]) @@ -147,7 +147,7 @@ func TestGarbageCollectLogStatistics(t *testing.T) { ctx := testhelper.Context(t) logger, hook := test.NewNullLogger() - _, repo, _, client := setupRepositoryService(ctx, t, testserver.WithLogger(logger)) + _, repo, _, client := setupRepositoryService(t, ctx, testserver.WithLogger(logger)) //nolint:staticcheck _, err := client.GarbageCollect(ctx, &gitalypb.GarbageCollectRequest{Repository: repo}) @@ -160,7 +160,7 @@ func TestGarbageCollectDeletesRefsLocks(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) req := &gitalypb.GarbageCollectRequest{Repository: repo} refsPath := filepath.Join(repoPath, "refs") @@ -228,7 +228,7 @@ func TestGarbageCollectDeletesPackedRefsLock(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -298,7 +298,7 @@ func TestGarbageCollectDeletesFileLocks(t *testing.T) { // freshly created GarbageCollect shouldn't remove the not-yet-stale // lockfile. t.Run("with recent lockfile", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -321,7 +321,7 @@ func TestGarbageCollectDeletesFileLocks(t *testing.T) { // Redo the same test, but this time we create the lockfile so that it is // considered stale. GarbageCollect should know to remove it. t.Run("with stale lockfile", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -368,7 +368,7 @@ func TestGarbageCollectDeletesPackedRefsNew(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) req := &gitalypb.GarbageCollectRequest{Repository: repo} packedRefsNewPath := filepath.Join(repoPath, "packed-refs.new") @@ -399,7 +399,7 @@ func TestGarbageCollectFailure(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) storagePath := strings.TrimSuffix(repoPath, "/"+repo.RelativePath) tests := []struct { @@ -439,7 +439,7 @@ func TestCleanupInvalidKeepAroundRefs(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) // Make the directory, so we can create random reflike things in it require.NoError(t, os.MkdirAll(filepath.Join(repoPath, "refs", "keep-around"), 0o755)) @@ -534,7 +534,7 @@ func TestGarbageCollectDeltaIslands(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) gittest.TestDeltaIslands(t, cfg, repoPath, repoPath, false, func() error { //nolint:staticcheck @@ -549,7 +549,7 @@ func TestGarbageCollect_commitGraphsWithPrunedObjects(t *testing.T) { ctx := testhelper.Context(t) cfg, client := setupRepositoryServiceWithoutRepo(t) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) // Write a first commit-graph that contains the root commit, only. rootCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) diff --git a/internal/gitaly/service/repository/info_attributes_test.go b/internal/gitaly/service/repository/info_attributes_test.go index 108322507..c35f9ff48 100644 --- a/internal/gitaly/service/repository/info_attributes_test.go +++ b/internal/gitaly/service/repository/info_attributes_test.go @@ -19,7 +19,7 @@ func TestGetInfoAttributesExisting(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) infoPath := filepath.Join(repoPath, "info") require.NoError(t, os.MkdirAll(infoPath, 0o755)) @@ -48,7 +48,7 @@ func TestGetInfoAttributesNonExisting(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) request := &gitalypb.GetInfoAttributesRequest{Repository: repo} diff --git a/internal/gitaly/service/repository/license_test.go b/internal/gitaly/service/repository/license_test.go index 3f000e80e..9b5d11f03 100644 --- a/internal/gitaly/service/repository/license_test.go +++ b/internal/gitaly/service/repository/license_test.go @@ -143,7 +143,7 @@ SOFTWARE.`, }, } { t.Run(tc.desc, func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) var treeEntries []gittest.TreeEntry for file, content := range tc.files { @@ -180,7 +180,7 @@ SOFTWARE.`, func testFindLicenseRequestEmptyRepo(t *testing.T, cfg config.Cfg, client gitalypb.RepositoryServiceClient, rubySrv *rubyserver.Server) { testhelper.NewFeatureSets(featureflag.GoFindLicense).Run(t, func(t *testing.T, ctx context.Context) { - repo, _ := gittest.CreateRepository(ctx, t, cfg) + repo, _ := gittest.CreateRepository(t, ctx, cfg) resp, err := client.FindLicense(ctx, &gitalypb.FindLicenseRequest{Repository: repo}) require.NoError(t, err) diff --git a/internal/gitaly/service/repository/merge_base_test.go b/internal/gitaly/service/repository/merge_base_test.go index 5079cd954..8a361cd01 100644 --- a/internal/gitaly/service/repository/merge_base_test.go +++ b/internal/gitaly/service/repository/merge_base_test.go @@ -15,7 +15,7 @@ func TestSuccessfulFindFindMergeBaseRequest(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) testCases := []struct { desc string @@ -84,7 +84,7 @@ func TestFailedFindMergeBaseRequestDueToValidations(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) request := &gitalypb.FindMergeBaseRequest{ Repository: repo, diff --git a/internal/gitaly/service/repository/midx_test.go b/internal/gitaly/service/repository/midx_test.go index 5057fbd37..d262bca32 100644 --- a/internal/gitaly/service/repository/midx_test.go +++ b/internal/gitaly/service/repository/midx_test.go @@ -33,7 +33,7 @@ func TestMidxWrite(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) //nolint:staticcheck _, err := client.MidxRepack(ctx, &gitalypb.MidxRepackRequest{Repository: repo}) @@ -52,7 +52,7 @@ func TestMidxRewrite(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) midxPath := filepath.Join(repoPath, MidxRelPath) @@ -80,7 +80,7 @@ func TestMidxRepack(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) // add some pack files with different sizes packsAdded := 5 @@ -122,7 +122,7 @@ func TestMidxRepack_transactional(t *testing.T) { ctx := testhelper.Context(t) txManager := transaction.NewTrackingManager() - cfg, repo, repoPath, client := setupRepositoryService(ctx, t, testserver.WithTransactionManager(txManager)) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx, testserver.WithTransactionManager(txManager)) // Reset the votes after creating the test repository. txManager.Reset() @@ -155,7 +155,7 @@ func TestMidxRepackExpire(t *testing.T) { for _, packsAdded := range []int{3, 5, 11, 20} { t.Run(fmt.Sprintf("Test repack expire with %d added packs", packsAdded), func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/repository/optimize_test.go b/internal/gitaly/service/repository/optimize_test.go index 61a21499c..f2b1b9571 100644 --- a/internal/gitaly/service/repository/optimize_test.go +++ b/internal/gitaly/service/repository/optimize_test.go @@ -47,7 +47,7 @@ func TestOptimizeRepository(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupRepositoryService(ctx, t) + cfg, repoProto, repoPath, client := setupRepositoryService(t, ctx) gittest.Exec(t, cfg, "-C", repoPath, "repack", "-A", "-b") gittest.Exec(t, cfg, "-C", repoPath, "commit-graph", "write", "--size-multiple=4", "--split=replace", "--reachable", "--changed-paths") @@ -95,7 +95,7 @@ func TestOptimizeRepository(t *testing.T) { require.Equal(t, getNewestPackfileModtime(t, repoPath), newestsPackfileTime, "there should not have been a new packfile created") - testRepoProto, testRepoPath := gittest.CreateRepository(ctx, t, cfg) + testRepoProto, testRepoPath := gittest.CreateRepository(t, ctx, cfg) blobs := 10 blobIDs := gittest.WriteBlobs(t, cfg, testRepoPath, blobs) @@ -160,7 +160,7 @@ func TestOptimizeRepositoryValidation(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, _, client := setupRepositoryService(ctx, t) + cfg, repo, _, client := setupRepositoryService(t, ctx) testCases := []struct { desc string diff --git a/internal/gitaly/service/repository/prune_unreachable_objects_test.go b/internal/gitaly/service/repository/prune_unreachable_objects_test.go index 29bb18eac..930eadd6e 100644 --- a/internal/gitaly/service/repository/prune_unreachable_objects_test.go +++ b/internal/gitaly/service/repository/prune_unreachable_objects_test.go @@ -37,7 +37,7 @@ func TestPruneUnreachableObjects(t *testing.T) { }) t.Run("relative path points to removed repository", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) require.NoError(t, os.RemoveAll(repoPath)) _, err := client.PruneUnreachableObjects(ctx, &gitalypb.PruneUnreachableObjectsRequest{ @@ -47,7 +47,7 @@ func TestPruneUnreachableObjects(t *testing.T) { }) t.Run("empty repository", func(t *testing.T) { - repo, _ := gittest.CreateRepository(ctx, t, cfg) + repo, _ := gittest.CreateRepository(t, ctx, cfg) _, err := client.PruneUnreachableObjects(ctx, &gitalypb.PruneUnreachableObjectsRequest{ Repository: repo, @@ -56,7 +56,7 @@ func TestPruneUnreachableObjects(t *testing.T) { }) t.Run("repository with reachable objects", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) // Create the commit and a branch pointing to it to make it reachable. commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("branch")) @@ -71,7 +71,7 @@ func TestPruneUnreachableObjects(t *testing.T) { }) t.Run("repository with recent unreachable objects", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) // Create the commit, but don't create a reference pointing to it. commitID := gittest.WriteCommit(t, cfg, repoPath) @@ -90,7 +90,7 @@ func TestPruneUnreachableObjects(t *testing.T) { }) t.Run("repository with old unreachable objects", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) // Create the commit, but don't create a reference pointing to it. commitID := gittest.WriteCommit(t, cfg, repoPath) @@ -108,7 +108,7 @@ func TestPruneUnreachableObjects(t *testing.T) { }) t.Run("repository with mixed objects", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) reachableOldCommit := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("a"), gittest.WithBranch("branch")) setObjectTime(t, repoPath, reachableOldCommit, time.Now().Add(-31*time.Minute)) @@ -136,7 +136,7 @@ func TestPruneUnreachableObjects(t *testing.T) { }) t.Run("repository with commit-graph", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) // Write two commits into the repository and create a commit-graph. The second // commit will become unreachable and will be pruned, but will be contained in the diff --git a/internal/gitaly/service/repository/raw_changes_test.go b/internal/gitaly/service/repository/raw_changes_test.go index b91d1ecdc..3ce6ff3c7 100644 --- a/internal/gitaly/service/repository/raw_changes_test.go +++ b/internal/gitaly/service/repository/raw_changes_test.go @@ -20,7 +20,7 @@ func TestGetRawChanges(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) testCases := []struct { oldRev string @@ -122,7 +122,7 @@ func TestGetRawChangesSpecialCharacters(t *testing.T) { // characters. ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) req := &gitalypb.GetRawChangesRequest{ Repository: repo, @@ -162,7 +162,7 @@ func TestGetRawChangesFailures(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) for _, tc := range []struct { desc string @@ -216,7 +216,7 @@ func TestGetRawChangesManyFiles(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) initCommit := "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863" req := &gitalypb.GetRawChangesRequest{ @@ -237,7 +237,7 @@ func TestGetRawChangesMappingOperations(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) req := &gitalypb.GetRawChangesRequest{ Repository: repo, @@ -279,7 +279,7 @@ func TestGetRawChangesInvalidUTF8Paths(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) const ( // These are arbitrary blobs known to exist in the test repository diff --git a/internal/gitaly/service/repository/remove_test.go b/internal/gitaly/service/repository/remove_test.go index 5b8ab01b1..4c94f2cd2 100644 --- a/internal/gitaly/service/repository/remove_test.go +++ b/internal/gitaly/service/repository/remove_test.go @@ -56,7 +56,7 @@ func TestRemoveRepository_locking(t *testing.T) { ctx := testhelper.Context(t) // Praefect does not acquire a lock on repository deletion so disable the test case for Praefect. - _, repo, repoPath, client := setupRepositoryService(ctx, t, testserver.WithDisablePraefect()) + _, repo, repoPath, client := setupRepositoryService(t, ctx, testserver.WithDisablePraefect()) // Simulate a concurrent RPC holding the repository lock. lockPath := repoPath + ".lock" diff --git a/internal/gitaly/service/repository/rename_test.go b/internal/gitaly/service/repository/rename_test.go index cf7267308..d034b951e 100644 --- a/internal/gitaly/service/repository/rename_test.go +++ b/internal/gitaly/service/repository/rename_test.go @@ -30,7 +30,7 @@ func testRenameRepositorySuccess(t *testing.T, ctx context.Context) { t.Parallel() // Praefect does not move repositories on the disk so this test case is not run with Praefect. - cfg, repo, _, client := setupRepositoryService(ctx, t, testserver.WithDisablePraefect()) + cfg, repo, _, client := setupRepositoryService(t, ctx, testserver.WithDisablePraefect()) const targetPath = "a-new-location" _, err := client.RenameRepository(ctx, &gitalypb.RenameRepositoryRequest{ @@ -66,7 +66,7 @@ func testRenameRepositoryDestinationExists(t *testing.T, ctx context.Context) { _, err = client.CreateRepository(ctx, &gitalypb.CreateRepositoryRequest{Repository: renamedRepo}) require.NoError(t, err) - destinationRepoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(ctx, t, cfg, existingDestinationRepo)) + destinationRepoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(t, ctx, cfg, existingDestinationRepo)) commitID := gittest.WriteCommit(t, cfg, destinationRepoPath) _, err = client.RenameRepository(ctx, &gitalypb.RenameRepositoryRequest{ @@ -86,7 +86,7 @@ func TestRenameRepository_invalidRequest(t *testing.T) { func testRenameRepositoryInvalidRequest(t *testing.T, ctx context.Context) { t.Parallel() - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) storagePath := strings.TrimSuffix(repoPath, "/"+repo.RelativePath) testCases := []struct { diff --git a/internal/gitaly/service/repository/repack_test.go b/internal/gitaly/service/repository/repack_test.go index fb42f8d04..acb581305 100644 --- a/internal/gitaly/service/repository/repack_test.go +++ b/internal/gitaly/service/repository/repack_test.go @@ -25,7 +25,7 @@ func TestRepackIncrementalSuccess(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, repoPath, client := setupRepositoryService(ctx, t) + _, repo, repoPath, client := setupRepositoryService(t, ctx) packPath := filepath.Join(repoPath, "objects", "pack") @@ -53,7 +53,7 @@ func TestRepackIncrementalCollectLogStatistics(t *testing.T) { ctx := testhelper.Context(t) logger, hook := test.NewNullLogger() - _, repo, _, client := setupRepositoryService(ctx, t, testserver.WithLogger(logger)) + _, repo, _, client := setupRepositoryService(t, ctx, testserver.WithLogger(logger)) //nolint:staticcheck _, err := client.RepackIncremental(ctx, &gitalypb.RepackIncrementalRequest{Repository: repo}) @@ -66,7 +66,7 @@ func TestRepackLocal(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) altObjectsDir := "./alt-objects" alternateCommit := gittest.WriteCommit(t, cfg, repoPath, @@ -166,7 +166,7 @@ func TestRepackFullSuccess(t *testing.T) { for _, test := range tests { t.Run(test.desc, func(t *testing.T) { var repoPath string - test.req.Repository, repoPath = gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + test.req.Repository, repoPath = gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) // Reset mtime to a long while ago since some filesystems don't have sub-second @@ -210,7 +210,7 @@ func TestRepackFullCollectLogStatistics(t *testing.T) { ctx := testhelper.Context(t) logger, hook := test.NewNullLogger() - _, repo, _, client := setupRepositoryService(ctx, t, testserver.WithLogger(logger)) + _, repo, _, client := setupRepositoryService(t, ctx, testserver.WithLogger(logger)) //nolint:staticcheck _, err := client.RepackFull(ctx, &gitalypb.RepackFullRequest{Repository: repo}) @@ -298,7 +298,7 @@ func TestRepackFullDeltaIslands(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) gittest.TestDeltaIslands(t, cfg, repoPath, repoPath, false, func() error { //nolint:staticcheck diff --git a/internal/gitaly/service/repository/replicate_test.go b/internal/gitaly/service/repository/replicate_test.go index 89ca307b8..f0dcad876 100644 --- a/internal/gitaly/service/repository/replicate_test.go +++ b/internal/gitaly/service/repository/replicate_test.go @@ -50,7 +50,7 @@ func TestReplicateRepository(t *testing.T) { client, serverSocketPath := runRepositoryService(t, cfg, nil, testserver.WithDisablePraefect()) cfg.SocketPath = serverSocketPath - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -126,7 +126,7 @@ func TestReplicateRepository_hiddenRefs(t *testing.T) { ctx = testhelper.MergeOutgoingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) t.Run("initial seeding", func(t *testing.T) { - sourceRepo, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg) + sourceRepo, sourceRepoPath := gittest.CreateRepository(t, ctx, cfg) // Create a bunch of internal references, regardless of whether we classify them as hidden // or read-only. We should be able to replicate all of them. @@ -158,8 +158,8 @@ func TestReplicateRepository_hiddenRefs(t *testing.T) { }) t.Run("incremental replication", func(t *testing.T) { - sourceRepo, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg) - targetRepo, targetRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + sourceRepo, sourceRepoPath := gittest.CreateRepository(t, ctx, cfg) + targetRepo, targetRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ RelativePath: sourceRepo.GetRelativePath(), Storage: cfg.Storages[1], }) @@ -206,7 +206,7 @@ func TestReplicateRepositoryTransactional(t *testing.T) { _, serverSocketPath := runRepositoryService(t, cfg, nil, testserver.WithDisablePraefect()) cfg.SocketPath = serverSocketPath - sourceRepo, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + sourceRepo, sourceRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -417,10 +417,10 @@ func TestReplicateRepository_BadRepository(t *testing.T) { client, serverSocketPath := runRepositoryService(t, cfg, nil, testserver.WithDisablePraefect()) cfg.SocketPath = serverSocketPath - sourceRepo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + sourceRepo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) - targetRepo, targetRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + targetRepo, targetRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Storage: cfg.Storages[1], RelativePath: sourceRepo.RelativePath, }) @@ -474,7 +474,7 @@ func TestReplicateRepository_FailedFetchInternalRemote(t *testing.T) { client, socketPath := runRepositoryService(t, cfg, nil, testserver.WithDisablePraefect()) cfg.SocketPath = socketPath - targetRepo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + targetRepo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Storage: cfg.Storages[1], }) diff --git a/internal/gitaly/service/repository/repository_test.go b/internal/gitaly/service/repository/repository_test.go index 74faba1c7..5097af069 100644 --- a/internal/gitaly/service/repository/repository_test.go +++ b/internal/gitaly/service/repository/repository_test.go @@ -28,7 +28,7 @@ func TestRepositoryExists(t *testing.T) { client, socketPath := runRepositoryService(t, cfg, nil, testserver.WithDisablePraefect()) cfg.SocketPath = socketPath - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -117,9 +117,9 @@ func TestSuccessfulHasLocalBranches(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, _, client := setupRepositoryService(ctx, t) + cfg, repo, _, client := setupRepositoryService(t, ctx) - emptyRepo, _ := gittest.CreateRepository(ctx, t, cfg) + emptyRepo, _ := gittest.CreateRepository(t, ctx, cfg) testCases := []struct { desc string diff --git a/internal/gitaly/service/repository/restore_custom_hooks_test.go b/internal/gitaly/service/repository/restore_custom_hooks_test.go index e05e74a2d..fbe44d366 100644 --- a/internal/gitaly/service/repository/restore_custom_hooks_test.go +++ b/internal/gitaly/service/repository/restore_custom_hooks_test.go @@ -45,7 +45,7 @@ func testSuccessfulRestoreCustomHooksRequest(t *testing.T, ctx context.Context) require.NoError(t, err) ctx = metadata.IncomingToOutgoing(ctx) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) // reset the txManager since CreateRepository would have done // voting @@ -118,7 +118,7 @@ func TestFailedRestoreCustomHooksDueToBadTar(t *testing.T) { } func testFailedRestoreCustomHooksDueToBadTar(t *testing.T, ctx context.Context) { - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) stream, err := client.RestoreCustomHooks(ctx) diff --git a/internal/gitaly/service/repository/search_files_test.go b/internal/gitaly/service/repository/search_files_test.go index 48f14dbfb..9f135a595 100644 --- a/internal/gitaly/service/repository/search_files_test.go +++ b/internal/gitaly/service/repository/search_files_test.go @@ -88,7 +88,7 @@ func TestSearchFilesByContentSuccessful(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) testCases := []struct { desc string @@ -154,7 +154,7 @@ func TestSearchFilesByContentLargeFile(t *testing.T) { ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) for _, tc := range []struct { desc string @@ -283,7 +283,7 @@ func TestSearchFilesByNameSuccessful(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) testCases := []struct { desc string @@ -349,7 +349,7 @@ func TestSearchFilesByNameUnusualFileNamesSuccessful(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) ref := []byte("unusual_file_names") gittest.WriteCommit(t, cfg, repoPath, @@ -447,7 +447,7 @@ func TestSearchFilesByNamePaginationSuccessful(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repo, repoPath, client := setupRepositoryService(ctx, t) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx) ref := []byte("pagination") gittest.WriteCommit(t, cfg, repoPath, diff --git a/internal/gitaly/service/repository/size_test.go b/internal/gitaly/service/repository/size_test.go index 0abb67c41..25df5786d 100644 --- a/internal/gitaly/service/repository/size_test.go +++ b/internal/gitaly/service/repository/size_test.go @@ -51,7 +51,7 @@ func testSuccessfulRepositorySizeRequestPoolMember(t *testing.T, ctx context.Con objectPoolClient := newObjectPoolClient(t, cfg, serverSocketPath) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -112,7 +112,7 @@ func testSuccessfulRepositorySizeRequestPoolMember(t *testing.T, ctx context.Con func testSuccessfulRepositorySizeRequest(t *testing.T, ctx context.Context) { logger, hook := test.NewNullLogger() - cfg, repo, repoPath, client := setupRepositoryService(ctx, t, testserver.WithLogger(logger)) + cfg, repo, repoPath, client := setupRepositoryService(t, ctx, testserver.WithLogger(logger)) request := &gitalypb.RepositorySizeRequest{Repository: repo} response, err := client.RepositorySize(ctx, request) @@ -237,7 +237,7 @@ func TestRepositorySize_SuccessfulGetObjectDirectorySizeRequest(t *testing.T) { } func testSuccessfulGetObjectDirectorySizeRequest(t *testing.T, ctx context.Context) { - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) repo.GitObjectDirectory = "objects/" request := &gitalypb.GetObjectDirectorySizeRequest{Repository: repo} @@ -261,11 +261,11 @@ func testGetObjectDirectorySizeQuarantine(t *testing.T, ctx context.Context) { locator := config.NewLocator(cfg) t.Run("quarantined repo", func(t *testing.T) { - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) - quarantine, err := quarantine.New(ctx, gittest.RewrittenRepository(ctx, t, cfg, repo), locator) + quarantine, err := quarantine.New(ctx, gittest.RewrittenRepository(t, ctx, cfg, repo), locator) require.NoError(t, err) // quarantine.New in Gitaly would receive an already rewritten repository. Gitaly would then calculate @@ -289,16 +289,16 @@ func testGetObjectDirectorySizeQuarantine(t *testing.T, ctx context.Context) { }) t.Run("quarantined repo with different relative path", func(t *testing.T) { - repo1, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo1, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) - quarantine1, err := quarantine.New(ctx, gittest.RewrittenRepository(ctx, t, cfg, repo1), locator) + quarantine1, err := quarantine.New(ctx, gittest.RewrittenRepository(t, ctx, cfg, repo1), locator) require.NoError(t, err) - repo2, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo2, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) - quarantine2, err := quarantine.New(ctx, gittest.RewrittenRepository(ctx, t, cfg, repo2), locator) + quarantine2, err := quarantine.New(ctx, gittest.RewrittenRepository(t, ctx, cfg, repo2), locator) require.NoError(t, err) // We swap out the the object directories of both quarantines. So while both are diff --git a/internal/gitaly/service/repository/snapshot_test.go b/internal/gitaly/service/repository/snapshot_test.go index c10b9a7f8..dab52c629 100644 --- a/internal/gitaly/service/repository/snapshot_test.go +++ b/internal/gitaly/service/repository/snapshot_test.go @@ -50,7 +50,7 @@ func touch(t *testing.T, format string, args ...interface{}) { func TestGetSnapshotSuccess(t *testing.T) { t.Parallel() - cfg, repo, repoPath, client := setupRepositoryService(testhelper.Context(t), t) + cfg, repo, repoPath, client := setupRepositoryService(t, testhelper.Context(t)) // Ensure certain files exist in the test repo. // WriteCommit produces a loose object with the given sha @@ -113,7 +113,7 @@ func TestGetSnapshotWithDedupe(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - cfg, repoProto, repoPath, client := setupRepositoryService(ctx, t) + cfg, repoProto, repoPath, client := setupRepositoryService(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) alternateObjDir := tc.alternatePathFunc(t, cfg.Storages[0].Path, filepath.Join(repoPath, "objects")) @@ -150,7 +150,7 @@ func TestGetSnapshotWithDedupe(t *testing.T) { gittest.RequireObjectExists(t, cfg, repoPath, secondCommitID) repoCopy, _ := copyRepoUsingSnapshot(t, ctx, cfg, client, repoProto) - repoCopy.RelativePath = gittest.GetReplicaPath(ctx, t, cfg, repoCopy) + repoCopy.RelativePath = gittest.GetReplicaPath(t, ctx, cfg, repoCopy) repoCopyPath, err := locator.GetRepoPath(repoCopy) require.NoError(t, err) @@ -165,7 +165,7 @@ func TestGetSnapshot_alternateObjectDirectory(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - cfg, repoProto, repoPath, client := setupRepositoryService(ctx, t) + cfg, repoProto, repoPath, client := setupRepositoryService(t, ctx) repo := localrepo.NewTestRepo(t, cfg, repoProto) locator := config.NewLocator(cfg) @@ -229,7 +229,7 @@ func TestGetSnapshot_alternateObjectDirectory(t *testing.T) { }() repoCopy, _ := copyRepoUsingSnapshot(t, ctx, cfg, client, repoProto) - repoCopy.RelativePath = gittest.GetReplicaPath(ctx, t, cfg, repoCopy) + repoCopy.RelativePath = gittest.GetReplicaPath(t, ctx, cfg, repoCopy) repoCopyPath, err := locator.GetRepoPath(repoCopy) require.NoError(t, err) @@ -267,7 +267,7 @@ func copyRepoUsingSnapshot(t *testing.T, ctx context.Context, cfg config.Cfg, cl require.NoError(t, err) testhelper.ProtoEqual(t, rsp, &gitalypb.CreateRepositoryFromSnapshotResponse{}) - return repoCopy, filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(ctx, t, cfg, repoCopy)) + return repoCopy, filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(t, ctx, cfg, repoCopy)) } func TestGetSnapshotFailsIfRepositoryMissing(t *testing.T) { @@ -288,7 +288,7 @@ func TestGetSnapshotFailsIfRepositoryMissing(t *testing.T) { func TestGetSnapshotFailsIfRepositoryContainsSymlink(t *testing.T) { t.Parallel() - _, repo, repoPath, client := setupRepositoryService(testhelper.Context(t), t) + _, repo, repoPath, client := setupRepositoryService(t, testhelper.Context(t)) // Make packed-refs into a symlink to break GetSnapshot() packedRefsFile := filepath.Join(repoPath, "packed-refs") diff --git a/internal/gitaly/service/repository/testhelper_test.go b/internal/gitaly/service/repository/testhelper_test.go index 566ee73a7..2cbd745a0 100644 --- a/internal/gitaly/service/repository/testhelper_test.go +++ b/internal/gitaly/service/repository/testhelper_test.go @@ -163,20 +163,20 @@ func runRepositoryService(tb testing.TB, cfg config.Cfg, rubySrv *rubyserver.Ser return newRepositoryClient(tb, cfg, serverSocketPath), serverSocketPath } -func setupRepositoryService(ctx context.Context, tb testing.TB, opts ...testserver.GitalyServerOpt) (config.Cfg, *gitalypb.Repository, string, gitalypb.RepositoryServiceClient) { +func setupRepositoryService(tb testing.TB, ctx context.Context, opts ...testserver.GitalyServerOpt) (config.Cfg, *gitalypb.Repository, string, gitalypb.RepositoryServiceClient) { cfg, client := setupRepositoryServiceWithoutRepo(tb, opts...) - repo, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) return cfg, repo, repoPath, client } // Sets up a repository that has been cloned using `--mirror` which contains GitLab internal references -func setupRepositoryServiceFromMirror(ctx context.Context, tb testing.TB, opts ...testserver.GitalyServerOpt) (config.Cfg, *gitalypb.Repository, string, gitalypb.RepositoryServiceClient) { +func setupRepositoryServiceFromMirror(tb testing.TB, ctx context.Context, opts ...testserver.GitalyServerOpt) (config.Cfg, *gitalypb.Repository, string, gitalypb.RepositoryServiceClient) { cfg, client := setupRepositoryServiceWithoutRepo(tb, opts...) - repo, repoPath := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTestMirror, }) return cfg, repo, repoPath, client diff --git a/internal/gitaly/service/repository/write_ref_test.go b/internal/gitaly/service/repository/write_ref_test.go index 4434bf0f6..c6b38d713 100644 --- a/internal/gitaly/service/repository/write_ref_test.go +++ b/internal/gitaly/service/repository/write_ref_test.go @@ -25,7 +25,7 @@ func TestWriteRef_successful(t *testing.T) { t.Parallel() txManager := transaction.NewTrackingManager() - cfg, repo, repoPath, client := setupRepositoryService(testhelper.Context(t), t, testserver.WithTransactionManager(txManager)) + cfg, repo, repoPath, client := setupRepositoryService(t, testhelper.Context(t), testserver.WithTransactionManager(txManager)) testCases := []struct { desc string @@ -125,7 +125,7 @@ func TestWriteRef_validation(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - _, repo, _, client := setupRepositoryService(ctx, t) + _, repo, _, client := setupRepositoryService(t, ctx) testCases := []struct { desc string @@ -202,7 +202,7 @@ func TestWriteRef_missingRevisions(t *testing.T) { ctx := testhelper.Context(t) cfg, client := setupRepositoryServiceWithoutRepo(t) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) commitID := gittest.WriteCommit(t, cfg, repoPath) for _, tc := range []struct { diff --git a/internal/gitaly/service/smarthttp/inforefs_test.go b/internal/gitaly/service/smarthttp/inforefs_test.go index cc72902ef..072156fd1 100644 --- a/internal/gitaly/service/smarthttp/inforefs_test.go +++ b/internal/gitaly/service/smarthttp/inforefs_test.go @@ -42,7 +42,7 @@ func TestInfoRefsUploadPack_successful(t *testing.T) { cfg.SocketPath = runSmartHTTPServer(t, cfg) ctx := testhelper.Context(t) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"), gittest.WithParents()) tagID := gittest.WriteTag(t, cfg, repoPath, "v1.0.0", commitID.Revision(), gittest.WriteTagConfig{ @@ -50,7 +50,7 @@ func TestInfoRefsUploadPack_successful(t *testing.T) { }) rpcRequest := &gitalypb.InfoRefsRequest{Repository: repo} - response, err := makeInfoRefsUploadPackRequest(ctx, t, cfg.SocketPath, cfg.Auth.Token, rpcRequest) + response, err := makeInfoRefsUploadPackRequest(t, ctx, cfg.SocketPath, cfg.Auth.Token, rpcRequest) require.NoError(t, err) requireAdvertisedRefs(t, string(response), "git-upload-pack", []string{ commitID.String() + " HEAD", @@ -111,7 +111,7 @@ func TestInfoRefsUploadPack_internalRefs(t *testing.T) { }, } { t.Run(tc.ref, func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"), gittest.WithParents()) gittest.Exec(t, cfg, "-C", repoPath, "update-ref", tc.ref, commitID.String()) @@ -121,7 +121,7 @@ func TestInfoRefsUploadPack_internalRefs(t *testing.T) { expectedAdvertisements = append(expectedAdvertisements, commitID.String()+" "+expectedRef) } - response, err := makeInfoRefsUploadPackRequest(ctx, t, cfg.SocketPath, cfg.Auth.Token, &gitalypb.InfoRefsRequest{ + response, err := makeInfoRefsUploadPackRequest(t, ctx, cfg.SocketPath, cfg.Auth.Token, &gitalypb.InfoRefsRequest{ Repository: repo, }) require.NoError(t, err) @@ -143,7 +143,7 @@ func TestInfoRefsUploadPack_repositoryDoesntExist(t *testing.T) { }} ctx := testhelper.Context(t) - _, err := makeInfoRefsUploadPackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest) + _, err := makeInfoRefsUploadPackRequest(t, ctx, serverSocketPath, cfg.Auth.Token, rpcRequest) expectedErr := helper.ErrNotFoundf(`GetRepoPath: not a git repository: "` + cfg.Storages[0].Path + `/doesnt/exist"`) if testhelper.IsPraefectEnabled() { @@ -161,7 +161,7 @@ func TestInfoRefsUploadPack_partialClone(t *testing.T) { cfg.SocketPath = runSmartHTTPServer(t, cfg) ctx := testhelper.Context(t) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -169,7 +169,7 @@ func TestInfoRefsUploadPack_partialClone(t *testing.T) { Repository: repo, } - partialResponse, err := makeInfoRefsUploadPackRequest(ctx, t, cfg.SocketPath, cfg.Auth.Token, request) + partialResponse, err := makeInfoRefsUploadPackRequest(t, ctx, cfg.SocketPath, cfg.Auth.Token, request) require.NoError(t, err) partialRefs := stats.ReferenceDiscovery{} err = partialRefs.Parse(bytes.NewReader(partialResponse)) @@ -187,7 +187,7 @@ func TestInfoRefsUploadPack_gitConfigOptions(t *testing.T) { cfg.SocketPath = runSmartHTTPServer(t, cfg) ctx := testhelper.Context(t) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"), gittest.WithParents()) @@ -197,7 +197,7 @@ func TestInfoRefsUploadPack_gitConfigOptions(t *testing.T) { Repository: repo, GitConfigOptions: []string{"transfer.hideRefs=refs"}, } - response, err := makeInfoRefsUploadPackRequest(ctx, t, cfg.SocketPath, cfg.Auth.Token, rpcRequest) + response, err := makeInfoRefsUploadPackRequest(t, ctx, cfg.SocketPath, cfg.Auth.Token, rpcRequest) require.NoError(t, err) requireAdvertisedRefs(t, string(response), "git-upload-pack", []string{ commitID.String() + " HEAD", @@ -210,14 +210,14 @@ func TestInfoRefsUploadPack_gitProtocol(t *testing.T) { cfg := testcfg.Build(t) ctx := testhelper.Context(t) - protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(ctx, t, cfg) + protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(t, ctx, cfg) server := startSmartHTTPServerWithOptions(t, cfg, nil, []testserver.GitalyServerOpt{ testserver.WithGitCommandFactory(protocolDetectingFactory), }) cfg.SocketPath = server.Address() - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -243,7 +243,7 @@ func TestInfoRefsUploadPack_gitProtocol(t *testing.T) { require.Contains(t, envData, fmt.Sprintf("GIT_PROTOCOL=%s\n", git.ProtocolV2)) } -func makeInfoRefsUploadPackRequest(ctx context.Context, t *testing.T, serverSocketPath, token string, rpcRequest *gitalypb.InfoRefsRequest) ([]byte, error) { +func makeInfoRefsUploadPackRequest(t *testing.T, ctx context.Context, serverSocketPath, token string, rpcRequest *gitalypb.InfoRefsRequest) ([]byte, error) { t.Helper() client, conn := newSmartHTTPClient(t, serverSocketPath, token) @@ -269,14 +269,14 @@ func TestInfoRefsReceivePack_successful(t *testing.T) { cfg.SocketPath = runSmartHTTPServer(t, cfg) ctx := testhelper.Context(t) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"), gittest.WithParents()) tagID := gittest.WriteTag(t, cfg, repoPath, "v1.0.0", commitID.Revision(), gittest.WriteTagConfig{ Message: "annotated tag", }) - response, err := makeInfoRefsReceivePackRequest(ctx, t, cfg.SocketPath, cfg.Auth.Token, &gitalypb.InfoRefsRequest{ + response, err := makeInfoRefsReceivePackRequest(t, ctx, cfg.SocketPath, cfg.Auth.Token, &gitalypb.InfoRefsRequest{ Repository: repo, }) require.NoError(t, err) @@ -297,7 +297,7 @@ func TestInfoRefsReceivePack_hiddenRefs(t *testing.T) { cfg.SocketPath = runSmartHTTPServer(t, cfg) ctx := testhelper.Context(t) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) @@ -325,7 +325,7 @@ func TestInfoRefsReceivePack_hiddenRefs(t *testing.T) { rpcRequest := &gitalypb.InfoRefsRequest{Repository: repoProto} - response, err := makeInfoRefsReceivePackRequest(ctx, t, cfg.SocketPath, cfg.Auth.Token, rpcRequest) + response, err := makeInfoRefsReceivePackRequest(t, ctx, cfg.SocketPath, cfg.Auth.Token, rpcRequest) require.NoError(t, err) require.NotContains(t, string(response), commitID+" .have") } @@ -340,7 +340,7 @@ func TestInfoRefsReceivePack_repoNotFound(t *testing.T) { repo := &gitalypb.Repository{StorageName: cfg.Storages[0].Name, RelativePath: "testdata/scratch/another_repo"} rpcRequest := &gitalypb.InfoRefsRequest{Repository: repo} ctx := testhelper.Context(t) - _, err := makeInfoRefsReceivePackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest) + _, err := makeInfoRefsReceivePackRequest(t, ctx, serverSocketPath, cfg.Auth.Token, rpcRequest) expectedErr := helper.ErrNotFoundf(`GetRepoPath: not a git repository: "` + cfg.Storages[0].Path + "/" + repo.RelativePath + `"`) if testhelper.IsPraefectEnabled() { @@ -359,11 +359,11 @@ func TestInfoRefsReceivePack_repoNotSet(t *testing.T) { rpcRequest := &gitalypb.InfoRefsRequest{} ctx := testhelper.Context(t) - _, err := makeInfoRefsReceivePackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest) + _, err := makeInfoRefsReceivePackRequest(t, ctx, serverSocketPath, cfg.Auth.Token, rpcRequest) testhelper.RequireGrpcCode(t, err, codes.InvalidArgument) } -func makeInfoRefsReceivePackRequest(ctx context.Context, t *testing.T, serverSocketPath, token string, rpcRequest *gitalypb.InfoRefsRequest) ([]byte, error) { +func makeInfoRefsReceivePackRequest(t *testing.T, ctx context.Context, serverSocketPath, token string, rpcRequest *gitalypb.InfoRefsRequest) ([]byte, error) { t.Helper() client, conn := newSmartHTTPClient(t, serverSocketPath, token) @@ -436,7 +436,7 @@ func TestInfoRefsUploadPack_cache(t *testing.T) { ctx := testhelper.Context(t) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"), gittest.WithParents()) tagID := gittest.WriteTag(t, cfg, repoPath, "v1.0.0", commitID.Revision(), gittest.WriteTagConfig{ @@ -455,7 +455,7 @@ func TestInfoRefsUploadPack_cache(t *testing.T) { } assertNormalResponse := func(addr string) { - response, err := makeInfoRefsUploadPackRequest(ctx, t, addr, cfg.Auth.Token, rpcRequest) + response, err := makeInfoRefsUploadPackRequest(t, ctx, addr, cfg.Auth.Token, rpcRequest) require.NoError(t, err) requireAdvertisedRefs(t, string(response), "git-upload-pack", []string{ @@ -467,7 +467,7 @@ func TestInfoRefsUploadPack_cache(t *testing.T) { } assertNormalResponse(gitalyServer.Address()) - rewrittenRequest := &gitalypb.InfoRefsRequest{Repository: gittest.RewrittenRepository(ctx, t, cfg, repo)} + rewrittenRequest := &gitalypb.InfoRefsRequest{Repository: gittest.RewrittenRepository(t, ctx, cfg, repo)} require.FileExists(t, pathToCachedResponse(t, ctx, cache, rewrittenRequest)) replacedContents := []string{ @@ -479,7 +479,7 @@ func TestInfoRefsUploadPack_cache(t *testing.T) { // replace cached response file to prove the info-ref uses the cache replaceCachedResponse(t, ctx, cache, rewrittenRequest, strings.Join(replacedContents, "\n")) - response, err := makeInfoRefsUploadPackRequest(ctx, t, gitalyServer.Address(), cfg.Auth.Token, rpcRequest) + response, err := makeInfoRefsUploadPackRequest(t, ctx, gitalyServer.Address(), cfg.Auth.Token, rpcRequest) require.NoError(t, err) require.Equal(t, strings.Join(replacedContents, "\n"), string(response)) @@ -504,7 +504,7 @@ func TestInfoRefsUploadPack_cache(t *testing.T) { invalidRepoCleanup := createInvalidRepo(t, filepath.Join(testhelper.GitlabTestStoragePath(), invalidReq.Repository.RelativePath)) defer invalidRepoCleanup() - _, err = makeInfoRefsUploadPackRequest(ctx, t, gitalyServer.Address(), cfg.Auth.Token, invalidReq) + _, err = makeInfoRefsUploadPackRequest(t, ctx, gitalyServer.Address(), cfg.Auth.Token, invalidReq) testhelper.RequireGrpcCode(t, err, codes.NotFound) require.NoFileExists(t, pathToCachedResponse(t, ctx, cache, invalidReq)) diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go index b78ef4467..723c92da7 100644 --- a/internal/gitaly/service/smarthttp/receive_pack_test.go +++ b/internal/gitaly/service/smarthttp/receive_pack_test.go @@ -52,7 +52,7 @@ func TestPostReceivePack_successful(t *testing.T) { }) cfg.SocketPath = server.Address() - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) repo.GlProjectPath = "project/path" @@ -98,7 +98,7 @@ func TestPostReceivePack_successful(t *testing.T) { // Compare the repository up front so that we can use require.Equal for // the remaining values. - testhelper.ProtoEqual(t, gittest.RewrittenRepository(ctx, t, cfg, repo), payload.Repo) + testhelper.ProtoEqual(t, gittest.RewrittenRepository(t, ctx, cfg, repo), payload.Repo) payload.Repo = nil // If running tests with Praefect, then the transaction would be set, but we have no way of @@ -138,7 +138,7 @@ func TestPostReceivePack_hiddenRefs(t *testing.T) { cfg := testcfg.Build(t) cfg.SocketPath = runSmartHTTPServer(t, cfg) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) repoProto.GlProjectPath = "project/path" @@ -194,14 +194,14 @@ func TestPostReceivePack_protocolV2(t *testing.T) { cfg := testcfg.Build(t) testcfg.BuildGitalyHooks(t, cfg) - protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(ctx, t, cfg) + protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(t, ctx, cfg) server := startSmartHTTPServerWithOptions(t, cfg, nil, []testserver.GitalyServerOpt{ testserver.WithGitCommandFactory(protocolDetectingFactory), }) cfg.SocketPath = server.Address() - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -238,7 +238,7 @@ func TestPostReceivePack_packfiles(t *testing.T) { client, conn := newSmartHTTPClient(t, cfg.SocketPath, cfg.Auth.Token) defer conn.Close() - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -291,7 +291,7 @@ func TestPostReceivePack_rejectViaGitConfigOptions(t *testing.T) { cfg := testcfg.Build(t) cfg.SocketPath = runSmartHTTPServer(t, cfg) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -330,7 +330,7 @@ func TestPostReceivePack_rejectViaHooks(t *testing.T) { }) cfg.SocketPath = server.Address() - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -458,12 +458,12 @@ func TestPostReceivePack_invalidObjects(t *testing.T) { }) cfg.SocketPath = server.Address() - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) repo := localrepo.NewTestRepo(t, cfg, repoProto) - _, localRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, localRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -588,7 +588,7 @@ func TestPostReceivePack_fsck(t *testing.T) { cfg := testcfg.Build(t) cfg.SocketPath = runSmartHTTPServer(t, cfg) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -639,7 +639,7 @@ func TestPostReceivePack_hooks(t *testing.T) { testcfg.BuildGitalyHooks(t, cfg) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -700,7 +700,7 @@ func TestPostReceivePack_transactionsViaPraefect(t *testing.T) { cfg := testcfg.Build(t) cfg.SocketPath = runSmartHTTPServer(t, cfg) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -785,7 +785,7 @@ func TestPostReceivePack_referenceTransactionHook(t *testing.T) { stream, err := client.PostReceivePack(ctx) require.NoError(t, err) - repo, _ := gittest.CreateRepository(ctxWithoutTransaction, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctxWithoutTransaction, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -808,7 +808,7 @@ func TestPostReceivePack_referenceTransactionHook(t *testing.T) { stream, err := client.PostReceivePack(ctx) require.NoError(t, err) - repo, repoPath := gittest.CreateRepository(ctxWithoutTransaction, t, cfg, + repo, repoPath := gittest.CreateRepository(t, ctxWithoutTransaction, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -882,7 +882,7 @@ func TestPostReceivePack_notAllowed(t *testing.T) { stream, err := client.PostReceivePack(ctx) require.NoError(t, err) - repo, _ := gittest.CreateRepository(ctxWithoutTransaction, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctxWithoutTransaction, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -896,7 +896,7 @@ func TestPostReceivePack_notAllowed(t *testing.T) { func createPushRequest(t *testing.T, cfg config.Cfg) (git.ObjectID, git.ObjectID, io.Reader) { ctx := testhelper.Context(t) - _, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/smarthttp/upload_pack_test.go b/internal/gitaly/service/smarthttp/upload_pack_test.go index 1da5527da..7c8a2a084 100644 --- a/internal/gitaly/service/smarthttp/upload_pack_test.go +++ b/internal/gitaly/service/smarthttp/upload_pack_test.go @@ -37,7 +37,7 @@ const ( ) type ( - requestMaker func(ctx context.Context, t *testing.T, serverSocketPath, token string, in *gitalypb.PostUploadPackRequest, body io.Reader) (*bytes.Buffer, error) + requestMaker func(t *testing.T, ctx context.Context, serverSocketPath, token string, in *gitalypb.PostUploadPackRequest, body io.Reader) (*bytes.Buffer, error) ) func runTestWithAndWithoutConfigOptions( @@ -75,10 +75,10 @@ func testServerPostUpload(t *testing.T, ctx context.Context, makeRequest request negotiationMetrics := prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"feature"}) cfg.SocketPath = runSmartHTTPServer(t, cfg, WithPackfileNegotiationMetrics(negotiationMetrics)) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) - _, localRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, localRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -97,7 +97,7 @@ func testServerPostUpload(t *testing.T, ctx context.Context, makeRequest request gittest.WritePktlineFlush(t, requestBuffer) req := &gitalypb.PostUploadPackRequest{Repository: repo} - responseBuffer, err := makeRequest(ctx, t, cfg.SocketPath, cfg.Auth.Token, req, requestBuffer) + responseBuffer, err := makeRequest(t, ctx, cfg.SocketPath, cfg.Auth.Token, req, requestBuffer) require.NoError(t, err) pack, version, entries := extractPackDataFromResponse(t, responseBuffer) @@ -132,7 +132,7 @@ func testServerPostUploadPackGitConfigOptions(t *testing.T, ctx context.Context, cfg.SocketPath = runSmartHTTPServer(t, cfg) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) // We write two commits: the first commit is a common base commit that is available via // normal refs. And the second commit is a child of the base commit, but its reference is @@ -157,7 +157,7 @@ func testServerPostUploadPackGitConfigOptions(t *testing.T, ctx context.Context, t.Run("sanity check: ref exists and can be fetched", func(t *testing.T) { rpcRequest := &gitalypb.PostUploadPackRequest{Repository: repo} - response, err := makeRequest(ctx, t, cfg.SocketPath, cfg.Auth.Token, rpcRequest, bytes.NewReader(requestBody.Bytes())) + response, err := makeRequest(t, ctx, cfg.SocketPath, cfg.Auth.Token, rpcRequest, bytes.NewReader(requestBody.Bytes())) require.NoError(t, err) _, _, count := extractPackDataFromResponse(t, response) require.Equal(t, 1, count, "pack should have the hidden ID as single object") @@ -171,7 +171,7 @@ func testServerPostUploadPackGitConfigOptions(t *testing.T, ctx context.Context, "uploadpack.allowAnySHA1InWant=false", }, } - response, err := makeRequest(ctx, t, cfg.SocketPath, cfg.Auth.Token, rpcRequest, bytes.NewReader(requestBody.Bytes())) + response, err := makeRequest(t, ctx, cfg.SocketPath, cfg.Auth.Token, rpcRequest, bytes.NewReader(requestBody.Bytes())) testhelper.RequireGrpcCode(t, err, codes.Unavailable) // The failure message proves that upload-pack failed because of @@ -195,13 +195,13 @@ func TestServer_PostUploadPackWithSidechannel_gitProtocol(t *testing.T) { func testServerPostUploadPackGitProtocol(t *testing.T, ctx context.Context, makeRequest requestMaker, opts ...testcfg.Option) { cfg := testcfg.Build(t, opts...) - protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(ctx, t, cfg) + protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(t, ctx, cfg) server := startSmartHTTPServerWithOptions(t, cfg, nil, []testserver.GitalyServerOpt{ testserver.WithGitCommandFactory(protocolDetectingFactory), }) cfg.SocketPath = server.Address() - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -218,7 +218,7 @@ func testServerPostUploadPackGitProtocol(t *testing.T, ctx context.Context, make GitProtocol: git.ProtocolV2, } - _, err := makeRequest(ctx, t, server.Address(), cfg.Auth.Token, rpcRequest, requestBody) + _, err := makeRequest(t, ctx, server.Address(), cfg.Auth.Token, rpcRequest, requestBody) require.NoError(t, err) envData := protocolDetectingFactory.ReadProtocol(t) @@ -244,7 +244,7 @@ func testServerPostUploadPackSuppressDeepenExitError(t *testing.T, ctx context.C cfg := testcfg.Build(t, opts...) cfg.SocketPath = runSmartHTTPServer(t, cfg) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -254,7 +254,7 @@ func testServerPostUploadPackSuppressDeepenExitError(t *testing.T, ctx context.C gittest.WritePktlineFlush(t, requestBody) rpcRequest := &gitalypb.PostUploadPackRequest{Repository: repo} - response, err := makeRequest(ctx, t, cfg.SocketPath, cfg.Auth.Token, rpcRequest, requestBody) + response, err := makeRequest(t, ctx, cfg.SocketPath, cfg.Auth.Token, rpcRequest, requestBody) // This assertion is the main reason this test exists. assert.NoError(t, err) @@ -293,7 +293,7 @@ func testServerPostUploadPackUsesPackObjectsHook(t *testing.T, ctx context.Conte cfg.SocketPath = runSmartHTTPServer(t, cfg) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -306,7 +306,7 @@ func testServerPostUploadPackUsesPackObjectsHook(t *testing.T, ctx context.Conte gittest.WritePktlineString(t, requestBuffer, fmt.Sprintf("have %s\n", oldHead)) gittest.WritePktlineFlush(t, requestBuffer) - _, err := makeRequest(ctx, t, cfg.SocketPath, cfg.Auth.Token, &gitalypb.PostUploadPackRequest{ + _, err := makeRequest(t, ctx, cfg.SocketPath, cfg.Auth.Token, &gitalypb.PostUploadPackRequest{ Repository: repo, }, requestBuffer) require.NoError(t, err) @@ -361,7 +361,7 @@ func testServerPostUploadPackValidation(t *testing.T, ctx context.Context, makeR }, } { t.Run(tc.desc, func(t *testing.T) { - _, err := makeRequest(ctx, t, serverSocketPath, cfg.Auth.Token, tc.request, bytes.NewBuffer(nil)) + _, err := makeRequest(t, ctx, serverSocketPath, cfg.Auth.Token, tc.request, bytes.NewBuffer(nil)) testhelper.RequireGrpcCode(t, err, tc.code) }) } @@ -384,7 +384,7 @@ func testServerPostUploadPackWithSideChannelValidation(t *testing.T, ctx context for _, rpcRequest := range rpcRequests { t.Run(fmt.Sprintf("%v", rpcRequest), func(t *testing.T) { - _, err := makeRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest, bytes.NewBuffer(nil)) + _, err := makeRequest(t, ctx, serverSocketPath, cfg.Auth.Token, rpcRequest, bytes.NewBuffer(nil)) testhelper.RequireGrpcCode(t, err, codes.InvalidArgument) }) } @@ -447,10 +447,10 @@ func testServerPostUploadPackPartialClone(t *testing.T, ctx context.Context, mak negotiationMetrics := prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"feature"}) cfg.SocketPath = runSmartHTTPServer(t, cfg, WithPackfileNegotiationMetrics(negotiationMetrics)) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) - _, localRepoPath := gittest.CreateRepository(ctx, t, cfg) + _, localRepoPath := gittest.CreateRepository(t, ctx, cfg) testcfg.BuildGitalyHooks(t, cfg) @@ -466,7 +466,7 @@ func testServerPostUploadPackPartialClone(t *testing.T, ctx context.Context, mak gittest.WritePktlineFlush(t, &requestBuffer) req := &gitalypb.PostUploadPackRequest{Repository: repo} - responseBuffer, err := makeRequest(ctx, t, cfg.SocketPath, cfg.Auth.Token, req, &requestBuffer) + responseBuffer, err := makeRequest(t, ctx, cfg.SocketPath, cfg.Auth.Token, req, &requestBuffer) require.NoError(t, err) pack, version, entries := extractPackDataFromResponse(t, responseBuffer) @@ -509,10 +509,10 @@ func testServerPostUploadPackAllowAnySHA1InWant(t *testing.T, ctx context.Contex cfg := testcfg.Build(t, opts...) cfg.SocketPath = runSmartHTTPServer(t, cfg) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) - _, localRepoPath := gittest.CreateRepository(ctx, t, cfg) + _, localRepoPath := gittest.CreateRepository(t, ctx, cfg) testcfg.BuildGitalyHooks(t, cfg) newCommit := gittest.WriteCommit(t, cfg, repoPath) @@ -524,7 +524,7 @@ func testServerPostUploadPackAllowAnySHA1InWant(t *testing.T, ctx context.Contex gittest.WritePktlineFlush(t, &requestBuffer) req := &gitalypb.PostUploadPackRequest{Repository: repo} - responseBuffer, err := makeRequest(ctx, t, cfg.SocketPath, cfg.Auth.Token, req, &requestBuffer) + responseBuffer, err := makeRequest(t, ctx, cfg.SocketPath, cfg.Auth.Token, req, &requestBuffer) require.NoError(t, err) pack, version, entries := extractPackDataFromResponse(t, responseBuffer) @@ -537,7 +537,7 @@ func testServerPostUploadPackAllowAnySHA1InWant(t *testing.T, ctx context.Contex gittest.RequireObjectExists(t, cfg, localRepoPath, newCommit) } -func makePostUploadPackRequest(ctx context.Context, t *testing.T, serverSocketPath, token string, in *gitalypb.PostUploadPackRequest, body io.Reader) (*bytes.Buffer, error) { +func makePostUploadPackRequest(t *testing.T, ctx context.Context, serverSocketPath, token string, in *gitalypb.PostUploadPackRequest, body io.Reader) (*bytes.Buffer, error) { client, conn := newSmartHTTPClient(t, serverSocketPath, token) defer conn.Close() @@ -581,7 +581,7 @@ func dialSmartHTTPServerWithSidechannel(t *testing.T, serverSocketPath, token st return conn } -func makePostUploadPackWithSidechannelRequest(ctx context.Context, t *testing.T, serverSocketPath, token string, in *gitalypb.PostUploadPackRequest, body io.Reader) (*bytes.Buffer, error) { +func makePostUploadPackWithSidechannelRequest(t *testing.T, ctx context.Context, serverSocketPath, token string, in *gitalypb.PostUploadPackRequest, body io.Reader) (*bytes.Buffer, error) { t.Helper() registry := sidechannel.NewRegistry() diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go index 0f9317696..ef67dbbcc 100644 --- a/internal/gitaly/service/ssh/receive_pack_test.go +++ b/internal/gitaly/service/ssh/receive_pack_test.go @@ -44,7 +44,7 @@ func TestReceivePack_validation(t *testing.T) { cfg := testcfg.Build(t) cfg.SocketPath = runSSHServer(t, cfg) - repo, _ := gittest.CreateRepository(ctx, t, cfg) + repo, _ := gittest.CreateRepository(t, ctx, cfg) client := newSSHClient(t, cfg.SocketPath) @@ -132,7 +132,7 @@ func TestReceivePack_success(t *testing.T) { cfg.SocketPath = runSSHServer(t, cfg, testserver.WithGitCommandFactory(gitCmdFactory)) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) glRepository := "project-456" @@ -148,7 +148,7 @@ func TestReceivePack_success(t *testing.T) { ctx = featureflag.ContextWithFeatureFlag(ctx, featureFlag, true) } - lHead, rHead, err := testCloneAndPush(ctx, t, cfg, cfg.SocketPath, repo, repoPath, pushParams{ + lHead, rHead, err := testCloneAndPush(t, ctx, cfg, cfg.SocketPath, repo, repoPath, pushParams{ storageName: cfg.Storages[0].Name, glID: "123", glUsername: "user", @@ -166,7 +166,7 @@ func TestReceivePack_success(t *testing.T) { // the remaining values. testhelper.ProtoEqual(t, &gitalypb.Repository{ StorageName: cfg.Storages[0].Name, - RelativePath: gittest.GetReplicaPath(ctx, t, cfg, repo), + RelativePath: gittest.GetReplicaPath(t, ctx, cfg, repo), GlProjectPath: glProjectPath, GlRepository: glRepository, }, payload.Repo) @@ -241,7 +241,7 @@ func TestReceivePack_client(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) stream, err := newSSHClient(t, cfg.SocketPath).SSHReceivePack(ctx) require.NoError(t, err) @@ -293,14 +293,14 @@ func TestReceive_gitProtocol(t *testing.T) { testcfg.BuildGitalyHooks(t, cfg) ctx := testhelper.Context(t) - protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(ctx, t, cfg) + protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(t, ctx, cfg) cfg.SocketPath = runSSHServer(t, cfg, testserver.WithGitCommandFactory(protocolDetectingFactory)) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) - lHead, rHead, err := testCloneAndPush(ctx, t, cfg, cfg.SocketPath, repo, repoPath, pushParams{ + lHead, rHead, err := testCloneAndPush(t, ctx, cfg, cfg.SocketPath, repo, repoPath, pushParams{ storageName: testhelper.DefaultStorageName, glRepository: "project-123", glID: "1", @@ -322,10 +322,10 @@ func TestReceivePack_failure(t *testing.T) { testcfg.BuildGitalySSH(t, cfg) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) t.Run("clone with invalid storage name", func(t *testing.T) { - _, _, err := testCloneAndPush(ctx, t, cfg, cfg.SocketPath, repo, repoPath, pushParams{ + _, _, err := testCloneAndPush(t, ctx, cfg, cfg.SocketPath, repo, repoPath, pushParams{ storageName: "foobar", glID: "1", }) @@ -339,7 +339,7 @@ func TestReceivePack_failure(t *testing.T) { }) t.Run("clone with invalid GlId", func(t *testing.T) { - _, _, err := testCloneAndPush(ctx, t, cfg, cfg.SocketPath, repo, repoPath, pushParams{storageName: cfg.Storages[0].Name, glID: ""}) + _, _, err := testCloneAndPush(t, ctx, cfg, cfg.SocketPath, repo, repoPath, pushParams{storageName: cfg.Storages[0].Name, glID: ""}) require.Error(t, err) require.Contains(t, err.Error(), helper.ErrInvalidArgumentf("empty GlId").Error()) }) @@ -356,12 +356,12 @@ func TestReceivePack_hookFailure(t *testing.T) { cfg.SocketPath = runSSHServer(t, cfg, testserver.WithGitCommandFactory(gitCmdFactory)) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) hookContent := []byte("#!/bin/sh\nexit 1") require.NoError(t, os.WriteFile(filepath.Join(gitCmdFactory.HooksPath(ctx), "pre-receive"), hookContent, 0o755)) - _, _, err := testCloneAndPush(ctx, t, cfg, cfg.SocketPath, repo, repoPath, pushParams{storageName: cfg.Storages[0].Name, glID: "1"}) + _, _, err := testCloneAndPush(t, ctx, cfg, cfg.SocketPath, repo, repoPath, pushParams{storageName: cfg.Storages[0].Name, glID: "1"}) require.Error(t, err) require.Contains(t, err.Error(), "(pre-receive hook declined)") } @@ -376,7 +376,7 @@ func TestReceivePack_customHookFailure(t *testing.T) { testcfg.BuildGitalySSH(t, cfg) testcfg.BuildGitalyHooks(t, cfg) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) cloneDetails, cleanup := setupSSHClone(t, cfg, repo, repoPath) defer cleanup() @@ -384,7 +384,7 @@ func TestReceivePack_customHookFailure(t *testing.T) { hookContent := []byte("#!/bin/sh\necho 'this is wrong' >&2;exit 1") gittest.WriteCustomHook(t, cloneDetails.RemoteRepoPath, "pre-receive", hookContent) - cmd := sshPushCommand(ctx, t, cfg, cloneDetails, cfg.SocketPath, + cmd := sshPushCommand(t, ctx, cfg, cloneDetails, cfg.SocketPath, pushParams{ storageName: cfg.Storages[0].Name, glID: "1", @@ -420,7 +420,7 @@ func TestReceivePack_hidesObjectPoolReferences(t *testing.T) { testcfg.BuildGitalyHooks(t, cfg) - repoProto, _ := gittest.CreateRepository(ctx, t, cfg) + repoProto, _ := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) txManager := transaction.NewManager(cfg, backchannel.NewRegistry()) @@ -478,7 +478,7 @@ func TestReceivePack_transactional(t *testing.T) { require.NoError(t, err) ctx = metadata.IncomingToOutgoing(ctx) - repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) parentCommitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"), gittest.WithParents(parentCommitID)) @@ -678,10 +678,10 @@ func TestReceivePack_objectExistsHook(t *testing.T) { ) ctx := testhelper.Context(t) - protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(ctx, t, cfg) + protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(t, ctx, cfg) cfg.SocketPath = runSSHServer(t, cfg, testserver.WithGitCommandFactory(protocolDetectingFactory)) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) tempGitlabShellDir := testhelper.TempDir(t) @@ -709,7 +709,7 @@ func TestReceivePack_objectExistsHook(t *testing.T) { gittest.WriteCheckNewObjectExistsHook(t, cloneDetails.RemoteRepoPath) - lHead, rHead, err := sshPush(ctx, t, cfg, cloneDetails, cfg.SocketPath, pushParams{ + lHead, rHead, err := sshPush(t, ctx, cfg, cloneDetails, cfg.SocketPath, pushParams{ storageName: cfg.Storages[0].Name, glID: glID, glRepository: glRepository, @@ -733,7 +733,7 @@ type SSHCloneDetails struct { func setupSSHClone(t *testing.T, cfg config.Cfg, remoteRepo *gitalypb.Repository, remoteRepoPath string) (SSHCloneDetails, func()) { ctx := testhelper.Context(t) - _, localRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + _, localRepoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -761,7 +761,7 @@ func setupSSHClone(t *testing.T, cfg config.Cfg, remoteRepo *gitalypb.Repository } } -func sshPushCommand(ctx context.Context, t *testing.T, cfg config.Cfg, cloneDetails SSHCloneDetails, serverSocketPath string, params pushParams) *exec.Cmd { +func sshPushCommand(t *testing.T, ctx context.Context, cfg config.Cfg, cloneDetails SSHCloneDetails, serverSocketPath string, params pushParams) *exec.Cmd { pbTempRepo := &gitalypb.Repository{ StorageName: params.storageName, RelativePath: cloneDetails.TempRepo, @@ -794,8 +794,8 @@ func sshPushCommand(ctx context.Context, t *testing.T, cfg config.Cfg, cloneDeta return cmd } -func sshPush(ctx context.Context, t *testing.T, cfg config.Cfg, cloneDetails SSHCloneDetails, serverSocketPath string, params pushParams) (string, string, error) { - cmd := sshPushCommand(ctx, t, cfg, cloneDetails, serverSocketPath, params) +func sshPush(t *testing.T, ctx context.Context, cfg config.Cfg, cloneDetails SSHCloneDetails, serverSocketPath string, params pushParams) (string, string, error) { + cmd := sshPushCommand(t, ctx, cfg, cloneDetails, serverSocketPath, params) out, err := cmd.CombinedOutput() if err != nil { @@ -812,11 +812,11 @@ func sshPush(ctx context.Context, t *testing.T, cfg config.Cfg, cloneDetails SSH return string(localHead), string(remoteHead), nil } -func testCloneAndPush(ctx context.Context, t *testing.T, cfg config.Cfg, serverSocketPath string, remoteRepo *gitalypb.Repository, remoteRepoPath string, params pushParams) (string, string, error) { +func testCloneAndPush(t *testing.T, ctx context.Context, cfg config.Cfg, serverSocketPath string, remoteRepo *gitalypb.Repository, remoteRepoPath string, params pushParams) (string, string, error) { cloneDetails, cleanup := setupSSHClone(t, cfg, remoteRepo, remoteRepoPath) defer cleanup() - return sshPush(ctx, t, cfg, cloneDetails, serverSocketPath, params) + return sshPush(t, ctx, cfg, cloneDetails, serverSocketPath, params) } func drainPostReceivePackResponse(stream gitalypb.SSHService_SSHReceivePackClient) error { diff --git a/internal/gitaly/service/ssh/upload_archive_test.go b/internal/gitaly/service/ssh/upload_archive_test.go index ea5fb77b3..0f41c35ca 100644 --- a/internal/gitaly/service/ssh/upload_archive_test.go +++ b/internal/gitaly/service/ssh/upload_archive_test.go @@ -26,7 +26,7 @@ func TestFailedUploadArchiveRequestDueToTimeout(t *testing.T) { cfg.SocketPath = runSSHServerWithOptions(t, cfg, []ServerOpt{WithArchiveRequestTimeout(100 * time.Microsecond)}) ctx := testhelper.Context(t) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -122,7 +122,7 @@ func TestUploadArchiveSuccess(t *testing.T) { cfg.SocketPath = runSSHServer(t, cfg) ctx := testhelper.Context(t) - repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/ssh/upload_pack_test.go b/internal/gitaly/service/ssh/upload_pack_test.go index 4d6e9e46b..31520b8fc 100644 --- a/internal/gitaly/service/ssh/upload_pack_test.go +++ b/internal/gitaly/service/ssh/upload_pack_test.go @@ -47,8 +47,8 @@ func runTestWithAndWithoutConfigOptions(t *testing.T, tf func(t *testing.T, opts // runClone runs the given Git command with gitaly-ssh set up as its SSH command. It will thus // invoke the Gitaly server's SSHUploadPack or SSHUploadPackWithSidechannel endpoint. func runClone( - ctx context.Context, t *testing.T, + ctx context.Context, cfg config.Cfg, withSidechannel bool, cloneCmd git.Cmd, @@ -105,7 +105,7 @@ func testUploadPackTimeout(t *testing.T, opts ...testcfg.Option) { cfg.SocketPath = runSSHServerWithOptions(t, cfg, []ServerOpt{WithUploadPackRequestTimeout(1)}) - repo, repoPath := gittest.CreateRepository(testhelper.Context(t), t, cfg) + repo, repoPath := gittest.CreateRepository(t, testhelper.Context(t), cfg) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main")) client := newSSHClient(t, cfg.SocketPath) @@ -140,7 +140,7 @@ func TestUploadPackWithSidechannel_client(t *testing.T) { cfg := testcfg.Build(t) cfg.SocketPath = runSSHServer(t, cfg) - repo, repoPath := gittest.CreateRepository(testhelper.Context(t), t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, testhelper.Context(t), cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) commitID := gittest.Exec(t, cfg, "-C", repoPath, "rev-parse", "HEAD^{commit}") @@ -512,13 +512,13 @@ func testUploadPackSuccessful(t *testing.T, sidechannel bool, opts ...testcfg.Op testcfg.BuildGitalySSH(t, cfg) negotiationMetrics := prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"feature"}) - protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(ctx, t, cfg) + protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(t, ctx, cfg) cfg.SocketPath = runSSHServerWithOptions(t, cfg, []ServerOpt{ WithPackfileNegotiationMetrics(negotiationMetrics), }, testserver.WithGitCommandFactory(protocolDetectingFactory)) - repo, repoPath := gittest.CreateRepository(ctx, t, cfg) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) smallBlobID := gittest.WriteBlob(t, cfg, repoPath, []byte("foobar")) largeBlobID := gittest.WriteBlob(t, cfg, repoPath, bytes.Repeat([]byte("1"), 2048)) @@ -619,7 +619,7 @@ func testUploadPackSuccessful(t *testing.T, sidechannel bool, opts ...testcfg.Op negotiationMetrics.Reset() protocolDetectingFactory.Reset(t) - require.NoError(t, runClone(ctx, t, cfg, sidechannel, git.SubCmd{ + require.NoError(t, runClone(t, ctx, cfg, sidechannel, git.SubCmd{ Name: "clone", Args: []string{"git@localhost:test/test.git", localRepoPath}, Flags: tc.cloneFlags, @@ -673,13 +673,13 @@ func TestUploadPack_packObjectsHook(t *testing.T) { cfg.SocketPath = runSSHServer(t, cfg) - repo, _ := gittest.CreateRepository(testhelper.Context(t), t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, testhelper.Context(t), cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) localRepoPath := testhelper.TempDir(t) - err := runClone(ctx, t, cfg, false, git.SubCmd{ + err := runClone(t, ctx, cfg, false, git.SubCmd{ Name: "clone", Args: []string{"git@localhost:test/test.git", localRepoPath}, }, &gitalypb.SSHUploadPackRequest{ Repository: repo, @@ -703,7 +703,7 @@ func testUploadPackWithoutSideband(t *testing.T, opts ...testcfg.Option) { cfg.SocketPath = runSSHServer(t, cfg) - repo, _ := gittest.CreateRepository(testhelper.Context(t), t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, testhelper.Context(t), cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) @@ -750,13 +750,13 @@ func TestUploadPack_invalidStorage(t *testing.T) { testcfg.BuildGitalySSH(t, cfg) - repo, _ := gittest.CreateRepository(testhelper.Context(t), t, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(t, testhelper.Context(t), cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) localRepoPath := testhelper.TempDir(t) - err := runClone(ctx, t, cfg, false, git.SubCmd{ + err := runClone(t, ctx, cfg, false, git.SubCmd{ Name: "clone", Args: []string{ "git@localhost:test/test.git", localRepoPath, @@ -783,7 +783,7 @@ func TestUploadPack_gitFailure(t *testing.T) { cfg := testcfg.Build(t) cfg.SocketPath = runSSHServer(t, cfg) - repo, repoPath := gittest.CreateRepository(testhelper.Context(t), t, cfg, gittest.CreateRepositoryConfig{ + repo, repoPath := gittest.CreateRepository(t, testhelper.Context(t), cfg, gittest.CreateRepositoryConfig{ Seed: gittest.SeedGitLabTest, }) diff --git a/internal/gitaly/service/wiki/find_page_test.go b/internal/gitaly/service/wiki/find_page_test.go index b1e59e295..d2222118f 100644 --- a/internal/gitaly/service/wiki/find_page_test.go +++ b/internal/gitaly/service/wiki/find_page_test.go @@ -18,7 +18,7 @@ import ( func testSuccessfulWikiFindPageRequest(t *testing.T, cfg config.Cfg, client gitalypb.WikiServiceClient, rubySrv *rubyserver.Server) { ctx := testhelper.Context(t) - wikiRepo, wikiRepoPath := setupWikiRepo(ctx, t, cfg) + wikiRepo, wikiRepoPath := setupWikiRepo(t, ctx, cfg) page1Name := "Home Pagé" page2Name := "Instálling/Step 133-b" @@ -273,7 +273,7 @@ func testSuccessfulWikiFindPageRequest(t *testing.T, cfg config.Cfg, client gita func testSuccessfulWikiFindPageSameTitleDifferentPathRequest(t *testing.T, cfg config.Cfg, client gitalypb.WikiServiceClient, rubySrv *rubyserver.Server) { ctx := testhelper.Context(t) - wikiRepo, wikiRepoPath := setupWikiRepo(ctx, t, cfg) + wikiRepo, wikiRepoPath := setupWikiRepo(t, ctx, cfg) page1Name := "page1" page1Content := []byte("content " + page1Name) @@ -385,7 +385,7 @@ func TestFailedWikiFindPageDueToValidation(t *testing.T) { cfg.SocketPath = socketPath ctx := testhelper.Context(t) - wikiRepo, _ := setupWikiRepo(ctx, t, cfg) + wikiRepo, _ := setupWikiRepo(t, ctx, cfg) testCases := []struct { desc string @@ -450,7 +450,7 @@ func TestInvalidWikiFindPageRequestRevision(t *testing.T) { cfg.SocketPath = socketPath ctx := testhelper.Context(t) - wikiRepo, _ := setupWikiRepo(ctx, t, cfg) + wikiRepo, _ := setupWikiRepo(t, ctx, cfg) stream, err := client.WikiFindPage(ctx, &gitalypb.WikiFindPageRequest{ Repository: wikiRepo, @@ -465,7 +465,7 @@ func TestInvalidWikiFindPageRequestRevision(t *testing.T) { func testSuccessfulWikiFindPageRequestWithTrailers(t *testing.T, cfg config.Cfg, client gitalypb.WikiServiceClient, rubySrv *rubyserver.Server) { ctx := testhelper.Context(t) - wikiRepo, repoPath := gittest.CreateRepository(ctx, t, cfg) + wikiRepo, repoPath := gittest.CreateRepository(t, ctx, cfg) gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"), diff --git a/internal/gitaly/service/wiki/get_all_pages_test.go b/internal/gitaly/service/wiki/get_all_pages_test.go index d2a376c41..c4ce432cf 100644 --- a/internal/gitaly/service/wiki/get_all_pages_test.go +++ b/internal/gitaly/service/wiki/get_all_pages_test.go @@ -17,7 +17,7 @@ import ( func testSuccessfulWikiGetAllPagesRequest(t *testing.T, cfg config.Cfg, client gitalypb.WikiServiceClient, rubySrv *rubyserver.Server) { ctx := testhelper.Context(t) - wikiRepo, wikiRepoPath := setupWikiRepo(ctx, t, cfg) + wikiRepo, wikiRepoPath := setupWikiRepo(t, ctx, cfg) expectedPages := createTestWikiPages(t, cfg, client, wikiRepo, wikiRepoPath) @@ -64,7 +64,7 @@ func testSuccessfulWikiGetAllPagesRequest(t *testing.T, cfg config.Cfg, client g func testWikiGetAllPagesSorting(t *testing.T, cfg config.Cfg, client gitalypb.WikiServiceClient, rubySrv *rubyserver.Server) { ctx := testhelper.Context(t) - wikiRepo, wikiRepoPath := setupWikiRepo(ctx, t, cfg) + wikiRepo, wikiRepoPath := setupWikiRepo(t, ctx, cfg) expectedPages := createTestWikiPages(t, cfg, client, wikiRepo, wikiRepoPath) diff --git a/internal/gitaly/service/wiki/list_pages_test.go b/internal/gitaly/service/wiki/list_pages_test.go index cbe827772..74643dc8d 100644 --- a/internal/gitaly/service/wiki/list_pages_test.go +++ b/internal/gitaly/service/wiki/list_pages_test.go @@ -16,7 +16,7 @@ import ( func testSuccessfulWikiListPagesRequest(t *testing.T, cfg config.Cfg, client gitalypb.WikiServiceClient, rubySrv *rubyserver.Server) { ctx := testhelper.Context(t) - wikiRepo, wikiRepoPath := setupWikiRepo(ctx, t, cfg) + wikiRepo, wikiRepoPath := setupWikiRepo(t, ctx, cfg) expectedPages := createTestWikiPages(t, cfg, client, wikiRepo, wikiRepoPath) @@ -65,7 +65,7 @@ func testSuccessfulWikiListPagesRequest(t *testing.T, cfg config.Cfg, client git func testWikiListPagesSorting(t *testing.T, cfg config.Cfg, client gitalypb.WikiServiceClient, rubySrv *rubyserver.Server) { ctx := testhelper.Context(t) - wikiRepo, wikiRepoPath := setupWikiRepo(ctx, t, cfg) + wikiRepo, wikiRepoPath := setupWikiRepo(t, ctx, cfg) expectedPages := createTestWikiPages(t, cfg, client, wikiRepo, wikiRepoPath) diff --git a/internal/gitaly/service/wiki/testhelper_test.go b/internal/gitaly/service/wiki/testhelper_test.go index 0dda852a7..4b46a274c 100644 --- a/internal/gitaly/service/wiki/testhelper_test.go +++ b/internal/gitaly/service/wiki/testhelper_test.go @@ -154,8 +154,8 @@ func writeWikiPage(t *testing.T, client gitalypb.WikiServiceClient, wikiRepo *gi require.NoError(t, err) } -func setupWikiRepo(ctx context.Context, t *testing.T, cfg config.Cfg) (*gitalypb.Repository, string) { - return gittest.CreateRepository(ctx, t, cfg) +func setupWikiRepo(t *testing.T, ctx context.Context, cfg config.Cfg) (*gitalypb.Repository, string) { + return gittest.CreateRepository(t, ctx, cfg) } func sendBytes(data []byte, chunkSize int, sender func([]byte) error) (int, error) { diff --git a/internal/gitaly/service/wiki/update_page_test.go b/internal/gitaly/service/wiki/update_page_test.go index d3a64350f..6fae444b5 100644 --- a/internal/gitaly/service/wiki/update_page_test.go +++ b/internal/gitaly/service/wiki/update_page_test.go @@ -19,7 +19,7 @@ import ( func testSuccessfulWikiUpdatePageRequest(t *testing.T, cfg config.Cfg, client gitalypb.WikiServiceClient, rubySrv *rubyserver.Server) { ctx := testhelper.Context(t) - wikiRepoProto, wikiRepoPath := setupWikiRepo(ctx, t, cfg) + wikiRepoProto, wikiRepoPath := setupWikiRepo(t, ctx, cfg) wikiRepo := localrepo.NewTestRepo(t, cfg, wikiRepoProto) writeWikiPage(t, client, wikiRepoProto, createWikiPageOpts{title: "Instálling Gitaly", content: []byte("foobar")}) @@ -110,7 +110,7 @@ func testSuccessfulWikiUpdatePageRequest(t *testing.T, cfg config.Cfg, client gi func testFailedWikiUpdatePageDueToValidations(t *testing.T, cfg config.Cfg, client gitalypb.WikiServiceClient, rubySrv *rubyserver.Server) { ctx := testhelper.Context(t) - wikiRepo, _ := setupWikiRepo(ctx, t, cfg) + wikiRepo, _ := setupWikiRepo(t, ctx, cfg) writeWikiPage(t, client, wikiRepo, createWikiPageOpts{title: "Installing Gitaly", content: []byte("foobar")}) @@ -251,7 +251,7 @@ func testFailedWikiUpdatePageDueToValidations(t *testing.T, cfg config.Cfg, clie func testFailedWikiUpdatePageDueToDuplicatePage(t *testing.T, cfg config.Cfg, client gitalypb.WikiServiceClient, rubySrv *rubyserver.Server) { ctx := testhelper.Context(t) - wikiRepo, _ := setupWikiRepo(ctx, t, cfg) + wikiRepo, _ := setupWikiRepo(t, ctx, cfg) page1Name := "Installing Gitaly" page2Name := "Setting up Gitaly" diff --git a/internal/gitaly/service/wiki/write_page_test.go b/internal/gitaly/service/wiki/write_page_test.go index c7ebd049c..55dcafeea 100644 --- a/internal/gitaly/service/wiki/write_page_test.go +++ b/internal/gitaly/service/wiki/write_page_test.go @@ -20,7 +20,7 @@ import ( func testSuccessfulWikiWritePageRequest(t *testing.T, cfg config.Cfg, client gitalypb.WikiServiceClient, rubySrv *rubyserver.Server) { ctx := testhelper.Context(t) - wikiRepoProto, wikiRepoPath := setupWikiRepo(ctx, t, cfg) + wikiRepoProto, wikiRepoPath := setupWikiRepo(t, ctx, cfg) wikiRepo := localrepo.NewTestRepo(t, cfg, wikiRepoProto) authorID := int32(1) @@ -114,7 +114,7 @@ func testSuccessfulWikiWritePageRequest(t *testing.T, cfg config.Cfg, client git func testFailedWikiWritePageDueToDuplicatePage(t *testing.T, cfg config.Cfg, client gitalypb.WikiServiceClient, rubySrv *rubyserver.Server) { ctx := testhelper.Context(t) - wikiRepo, _ := setupWikiRepo(ctx, t, cfg) + wikiRepo, _ := setupWikiRepo(t, ctx, cfg) pageName := "Installing Gitaly" content := []byte("Mock wiki page content") @@ -150,7 +150,7 @@ func testFailedWikiWritePageDueToDuplicatePage(t *testing.T, cfg config.Cfg, cli func testFailedWikiWritePageInPathDueToDuplicatePage(t *testing.T, cfg config.Cfg, client gitalypb.WikiServiceClient, rubySrv *rubyserver.Server) { ctx := testhelper.Context(t) - wikiRepo, _ := setupWikiRepo(ctx, t, cfg) + wikiRepo, _ := setupWikiRepo(t, ctx, cfg) pageName := "foo/Installing Gitaly" content := []byte("Mock wiki page content") diff --git a/internal/praefect/coordinator_test.go b/internal/praefect/coordinator_test.go index 5722e8abc..fb9c9ff99 100644 --- a/internal/praefect/coordinator_test.go +++ b/internal/praefect/coordinator_test.go @@ -319,7 +319,7 @@ func TestStreamDirectorMutator_StopTransaction(t *testing.T) { for _, name := range []string{"primary", "secondary"} { node, err := shard.GetNode(name) require.NoError(t, err) - waitNodeToChangeHealthStatus(ctx, t, node, true) + waitNodeToChangeHealthStatus(t, ctx, node, true) } rs := datastore.MockRepositoryStore{ @@ -1144,10 +1144,10 @@ func TestCoordinatorStreamDirector_distributesReads(t *testing.T) { gitaly1, err := shard.GetNode(secondaryNodeConf.Storage) require.NoError(t, err) - waitNodeToChangeHealthStatus(ctx, t, gitaly1, false) + waitNodeToChangeHealthStatus(t, ctx, gitaly1, false) defer func() { healthSrv.SetServingStatus("", grpc_health_v1.HealthCheckResponse_SERVING) - waitNodeToChangeHealthStatus(ctx, t, gitaly1, true) + waitNodeToChangeHealthStatus(t, ctx, gitaly1, true) }() frame, err := proto.Marshal(&gitalypb.FindAllBranchesRequest{Repository: &targetRepo}) @@ -1180,10 +1180,10 @@ func TestCoordinatorStreamDirector_distributesReads(t *testing.T) { primaryGitaly, err := shard.GetNode(primaryNodeConf.Storage) require.NoError(t, err) - waitNodeToChangeHealthStatus(ctx, t, primaryGitaly, false) + waitNodeToChangeHealthStatus(t, ctx, primaryGitaly, false) defer func() { primaryHealthSrv.SetServingStatus("", grpc_health_v1.HealthCheckResponse_SERVING) - waitNodeToChangeHealthStatus(ctx, t, primaryGitaly, true) + waitNodeToChangeHealthStatus(t, ctx, primaryGitaly, true) }() frame, err := proto.Marshal(&gitalypb.FindAllBranchesRequest{Repository: &targetRepo}) @@ -1416,7 +1416,7 @@ func TestStreamDirector_repo_creation(t *testing.T) { } } -func waitNodeToChangeHealthStatus(ctx context.Context, t *testing.T, node nodes.Node, health bool) { +func waitNodeToChangeHealthStatus(t *testing.T, ctx context.Context, node nodes.Node, health bool) { t.Helper() require.Eventually(t, func() bool { diff --git a/internal/praefect/datastore/repository_store_test.go b/internal/praefect/datastore/repository_store_test.go index e47d2d431..edb9e77b4 100644 --- a/internal/praefect/datastore/repository_store_test.go +++ b/internal/praefect/datastore/repository_store_test.go @@ -1204,7 +1204,7 @@ func TestRepositoryStore_incrementGenerationConcurrently(t *testing.T) { require.NoError(t, err) go func() { - testdb.WaitForBlockedQuery(ctx, t, db, "WITH updated_replicas AS (") + testdb.WaitForBlockedQuery(t, ctx, db, "WITH updated_replicas AS (") firstTx.Commit(t) }() diff --git a/internal/praefect/grpc-proxy/proxy/handler_ext_test.go b/internal/praefect/grpc-proxy/proxy/handler_ext_test.go index a20131ca5..10f46c648 100644 --- a/internal/praefect/grpc-proxy/proxy/handler_ext_test.go +++ b/internal/praefect/grpc-proxy/proxy/handler_ext_test.go @@ -417,7 +417,7 @@ func TestRegisterStreamHandlers(t *testing.T) { for _, tc := range []struct { desc string registeredHandlers map[string]func(*testing.T, interface{}, grpc.ServerStream) - execute func(context.Context, *testing.T, grpc_testing.TestServiceClient) + execute func(*testing.T, context.Context, grpc_testing.TestServiceClient) expectedErr error expectedCalls map[string]int }{ @@ -426,7 +426,7 @@ func TestRegisterStreamHandlers(t *testing.T) { registeredHandlers: map[string]func(*testing.T, interface{}, grpc.ServerStream){ "UnaryCall": unaryCallStreamHandler, }, - execute: func(ctx context.Context, t *testing.T, client grpc_testing.TestServiceClient) { + execute: func(t *testing.T, ctx context.Context, client grpc_testing.TestServiceClient) { _, err := client.UnaryCall(ctx, requestSent) require.NoError(t, err) }, @@ -440,7 +440,7 @@ func TestRegisterStreamHandlers(t *testing.T) { "UnaryCall": unaryCallStreamHandler, "EmptyCall": emptyCallStreamHandler, }, - execute: func(ctx context.Context, t *testing.T, client grpc_testing.TestServiceClient) { + execute: func(t *testing.T, ctx context.Context, client grpc_testing.TestServiceClient) { _, err := client.EmptyCall(ctx, &grpc_testing.Empty{}) require.NoError(t, err) }, @@ -453,7 +453,7 @@ func TestRegisterStreamHandlers(t *testing.T) { registeredHandlers: map[string]func(*testing.T, interface{}, grpc.ServerStream){ "EmptyCall": emptyCallStreamHandler, }, - execute: func(ctx context.Context, t *testing.T, client grpc_testing.TestServiceClient) { + execute: func(t *testing.T, ctx context.Context, client grpc_testing.TestServiceClient) { _, err := client.UnaryCall(ctx, requestSent) testhelper.RequireGrpcError(t, directorCalledError, err) }, @@ -496,7 +496,7 @@ func TestRegisterStreamHandlers(t *testing.T) { defer conn.Close() client := grpc_testing.NewTestServiceClient(conn) - tc.execute(ctx, t, client) + tc.execute(t, ctx, client) require.Equal(t, tc.expectedCalls, calls) }) diff --git a/internal/praefect/info_service_test.go b/internal/praefect/info_service_test.go index 3c9d6c211..c42ba8550 100644 --- a/internal/praefect/info_service_test.go +++ b/internal/praefect/info_service_test.go @@ -122,7 +122,7 @@ func TestInfoService_RepositoryReplicas(t *testing.T) { client := gitalypb.NewPraefectInfoServiceClient(cc) - testRepository, testRepoPath := gittest.CreateRepository(ctx, t, + testRepository, testRepoPath := gittest.CreateRepository(t, ctx, // The helper was implemented with the test server in mind. Here we need use the virtual storage's name // as the storage and the path of the storage we want to modify the replica in. gconfig.Cfg{Storages: []gconfig.Storage{{Name: virtualStorage, Path: cfgs[1].Storages[0].Path}}}, diff --git a/internal/praefect/nodes/health_manager_test.go b/internal/praefect/nodes/health_manager_test.go index 92959e37f..f53297854 100644 --- a/internal/praefect/nodes/health_manager_test.go +++ b/internal/praefect/nodes/health_manager_test.go @@ -26,7 +26,7 @@ func (m mockHealthClient) Check(ctx context.Context, r *grpc_health_v1.HealthChe return m.CheckFunc(ctx, r, opts...) } -func getHealthConsensus(ctx context.Context, t *testing.T, db glsql.Querier) map[string][]string { +func getHealthConsensus(t *testing.T, ctx context.Context, db glsql.Querier) map[string][]string { t.Helper() rows, err := db.QueryContext(ctx, "SELECT virtual_storage, storage FROM healthy_storages") @@ -541,7 +541,7 @@ func TestHealthManager(t *testing.T) { } require.Equal(t, expectedHealthyNodes, actualHealthyNodes, "health check %d", i+1) - require.Equal(t, hc.HealthConsensus, getHealthConsensus(ctx, t, db), "health check %d", i+1) + require.Equal(t, hc.HealthConsensus, getHealthConsensus(t, ctx, db), "health check %d", i+1) select { case <-hm.Updated(): @@ -597,7 +597,7 @@ func TestHealthManager_databaseTimeout(t *testing.T) { }() // Wait until the blocked query is waiting. - testdb.WaitForBlockedQuery(ctx, t, db, "INSERT INTO node_status") + testdb.WaitForBlockedQuery(t, ctx, db, "INSERT INTO node_status") // Simulate a timeout. timeoutQuery() // Query should have been canceled. @@ -647,7 +647,7 @@ func TestHealthManager_orderedWrites(t *testing.T) { }() // Wait for tx2 to be blocked on the gitaly-1 lock acquired by tx1 - testdb.WaitForBlockedQuery(ctx, t, db, "INSERT INTO node_status") + testdb.WaitForBlockedQuery(t, ctx, db, "INSERT INTO node_status") // Ensure tx1 can acquire lock on gitaly-2. require.NoError(t, hm1.updateHealthChecks(ctx, []string{virtualStorage}, []string{"gitaly-2"}, []bool{true})) @@ -658,5 +658,5 @@ func TestHealthManager_orderedWrites(t *testing.T) { require.NoError(t, <-tx2Err) require.NoError(t, tx2.Commit()) - require.Equal(t, map[string][]string{"virtual-storage": {"gitaly-1", "gitaly-2"}}, getHealthConsensus(ctx, t, db)) + require.Equal(t, map[string][]string{"virtual-storage": {"gitaly-1", "gitaly-2"}}, getHealthConsensus(t, ctx, db)) } diff --git a/internal/praefect/nodes/manager_test.go b/internal/praefect/nodes/manager_test.go index d59193d8b..2cc02cb27 100644 --- a/internal/praefect/nodes/manager_test.go +++ b/internal/praefect/nodes/manager_test.go @@ -459,7 +459,7 @@ func TestMgr_GetSyncedNode(t *testing.T) { } func TestNodeStatus_IsHealthy(t *testing.T) { - checkNTimes := func(ctx context.Context, t *testing.T, ns *nodeStatus, n int) { + checkNTimes := func(t *testing.T, ctx context.Context, ns *nodeStatus, n int) { for i := 0; i < n; i++ { _, err := ns.CheckHealth(ctx) require.NoError(t, err) @@ -489,7 +489,7 @@ func TestNodeStatus_IsHealthy(t *testing.T) { t.Run("not enough check to consider it healthy", func(t *testing.T) { ns := newConnectionStatus(node, clientConn, logger, latencyHistMock, nil) healthSrv.SetServingStatus("", grpc_health_v1.HealthCheckResponse_SERVING) - checkNTimes(ctx, t, ns, healthcheckThreshold-1) + checkNTimes(t, ctx, ns, healthcheckThreshold-1) require.False(t, ns.IsHealthy()) }) @@ -497,7 +497,7 @@ func TestNodeStatus_IsHealthy(t *testing.T) { t.Run("healthy", func(t *testing.T) { ns := newConnectionStatus(node, clientConn, logger, latencyHistMock, nil) healthSrv.SetServingStatus("", grpc_health_v1.HealthCheckResponse_SERVING) - checkNTimes(ctx, t, ns, healthcheckThreshold) + checkNTimes(t, ctx, ns, healthcheckThreshold) require.True(t, ns.IsHealthy()) }) @@ -505,12 +505,12 @@ func TestNodeStatus_IsHealthy(t *testing.T) { t.Run("healthy turns into unhealthy after single failed check", func(t *testing.T) { ns := newConnectionStatus(node, clientConn, logger, latencyHistMock, nil) healthSrv.SetServingStatus("", grpc_health_v1.HealthCheckResponse_SERVING) - checkNTimes(ctx, t, ns, healthcheckThreshold) + checkNTimes(t, ctx, ns, healthcheckThreshold) require.True(t, ns.IsHealthy(), "node must be turned into healthy state") healthSrv.SetServingStatus("", grpc_health_v1.HealthCheckResponse_NOT_SERVING) - checkNTimes(ctx, t, ns, 1) + checkNTimes(t, ctx, ns, 1) require.False(t, ns.IsHealthy(), "node must be turned into unhealthy state") }) @@ -518,21 +518,21 @@ func TestNodeStatus_IsHealthy(t *testing.T) { t.Run("unhealthy turns into healthy after pre-define threshold of checks", func(t *testing.T) { ns := newConnectionStatus(node, clientConn, logger, latencyHistMock, nil) healthSrv.SetServingStatus("", grpc_health_v1.HealthCheckResponse_SERVING) - checkNTimes(ctx, t, ns, healthcheckThreshold) + checkNTimes(t, ctx, ns, healthcheckThreshold) require.True(t, ns.IsHealthy(), "node must be turned into healthy state") healthSrv.SetServingStatus("", grpc_health_v1.HealthCheckResponse_NOT_SERVING) - checkNTimes(ctx, t, ns, 1) + checkNTimes(t, ctx, ns, 1) require.False(t, ns.IsHealthy(), "node must be turned into unhealthy state") healthSrv.SetServingStatus("", grpc_health_v1.HealthCheckResponse_SERVING) for i := 1; i < healthcheckThreshold; i++ { - checkNTimes(ctx, t, ns, 1) + checkNTimes(t, ctx, ns, 1) require.False(t, ns.IsHealthy(), "node must be unhealthy until defined threshold of checks complete positively") } - checkNTimes(ctx, t, ns, 1) // the last check that must turn it into healthy state + checkNTimes(t, ctx, ns, 1) // the last check that must turn it into healthy state require.True(t, ns.IsHealthy(), "node should be healthy again") }) @@ -543,7 +543,7 @@ func TestNodeStatus_IsHealthy(t *testing.T) { t.Run("continuously does health checks - 1", func(t *testing.T) { t.Parallel() - checkNTimes(ctx, t, ns, healthcheckThreshold) + checkNTimes(t, ctx, ns, healthcheckThreshold) }) t.Run("continuously checks health - 1", func(t *testing.T) { @@ -553,7 +553,7 @@ func TestNodeStatus_IsHealthy(t *testing.T) { t.Run("continuously does health checks - 2", func(t *testing.T) { t.Parallel() - checkNTimes(ctx, t, ns, healthcheckThreshold) + checkNTimes(t, ctx, ns, healthcheckThreshold) }) t.Run("continuously checks health - 2", func(t *testing.T) { diff --git a/internal/praefect/nodes/per_repository_test.go b/internal/praefect/nodes/per_repository_test.go index 3a75736f8..396e04f1b 100644 --- a/internal/praefect/nodes/per_repository_test.go +++ b/internal/praefect/nodes/per_repository_test.go @@ -599,7 +599,7 @@ func TestPerRepositoryElector(t *testing.T) { // Below we wait for the statement to actually begin executing to ensure the test actually exercises concurrent // execution. if !step.noBlockedQuery { - testdb.WaitForBlockedQuery(ctx, t, db, "WITH reread AS (") + testdb.WaitForBlockedQuery(t, ctx, db, "WITH reread AS (") } txFirst.Commit(t) diff --git a/internal/praefect/replicator_test.go b/internal/praefect/replicator_test.go index b9349a0bc..92edcf849 100644 --- a/internal/praefect/replicator_test.go +++ b/internal/praefect/replicator_test.go @@ -285,7 +285,7 @@ func TestConfirmReplication(t *testing.T) { cfg, testRepoA, testRepoAPath := testcfg.BuildWithRepo(t) srvSocketPath := testserver.RunGitalyServer(t, cfg, nil, setup.RegisterAll, testserver.WithDisablePraefect()) - testRepoB, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + testRepoB, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, }) diff --git a/internal/praefect/repocleaner/repository_test.go b/internal/praefect/repocleaner/repository_test.go index 441540a13..6e8cc892c 100644 --- a/internal/praefect/repocleaner/repository_test.go +++ b/internal/praefect/repocleaner/repository_test.go @@ -77,61 +77,61 @@ func TestRunner_Run(t *testing.T) { ctx, cancel := context.WithCancel(testhelper.Context(t)) // each gitaly has an extra repo-4.git repository - gittest.CreateRepository(ctx, t, g1Cfg, gittest.CreateRepositoryConfig{ + gittest.CreateRepository(t, ctx, g1Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: repo1RelPath, Seed: gittest.SeedGitLabTest, }) - gittest.CreateRepository(ctx, t, g1Cfg, gittest.CreateRepositoryConfig{ + gittest.CreateRepository(t, ctx, g1Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: repo2RelPath, Seed: gittest.SeedGitLabTest, }) - gittest.CreateRepository(ctx, t, g1Cfg, gittest.CreateRepositoryConfig{ + gittest.CreateRepository(t, ctx, g1Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: repo3RelPath, Seed: gittest.SeedGitLabTest, }) - _, repo4Path := gittest.CreateRepository(ctx, t, g1Cfg, gittest.CreateRepositoryConfig{ + _, repo4Path := gittest.CreateRepository(t, ctx, g1Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: "repo-4.git", Seed: gittest.SeedGitLabTest, }) require.NoError(t, os.Chtimes(repo4Path, time.Now().Add(-25*time.Hour), time.Now().Add(-25*time.Hour))) - gittest.CreateRepository(ctx, t, g2Cfg, gittest.CreateRepositoryConfig{ + gittest.CreateRepository(t, ctx, g2Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: repo1RelPath, Seed: gittest.SeedGitLabTest, }) - gittest.CreateRepository(ctx, t, g2Cfg, gittest.CreateRepositoryConfig{ + gittest.CreateRepository(t, ctx, g2Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: repo2RelPath, Seed: gittest.SeedGitLabTest, }) - _, repo4Path = gittest.CreateRepository(ctx, t, g2Cfg, gittest.CreateRepositoryConfig{ + _, repo4Path = gittest.CreateRepository(t, ctx, g2Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: "repo-4.git", Seed: gittest.SeedGitLabTest, }) require.NoError(t, os.Chtimes(repo4Path, time.Now().Add(-25*time.Hour), time.Now().Add(-25*time.Hour))) - gittest.CreateRepository(ctx, t, g3Cfg, gittest.CreateRepositoryConfig{ + gittest.CreateRepository(t, ctx, g3Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: repo1RelPath, Seed: gittest.SeedGitLabTest, }) - gittest.CreateRepository(ctx, t, g3Cfg, gittest.CreateRepositoryConfig{ + gittest.CreateRepository(t, ctx, g3Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: repo2RelPath, Seed: gittest.SeedGitLabTest, }) - gittest.CreateRepository(ctx, t, g3Cfg, gittest.CreateRepositoryConfig{ + gittest.CreateRepository(t, ctx, g3Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: repo3RelPath, Seed: gittest.SeedGitLabTest, }) - _, repo4Path = gittest.CreateRepository(ctx, t, g3Cfg, gittest.CreateRepositoryConfig{ + _, repo4Path = gittest.CreateRepository(t, ctx, g3Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: "repo-4.git", Seed: gittest.SeedGitLabTest, @@ -255,7 +255,7 @@ func TestRunner_Run_noAvailableStorages(t *testing.T) { ctx, cancel := context.WithCancel(testhelper.Context(t)) - _, repoPath := gittest.CreateRepository(ctx, t, g1Cfg, gittest.CreateRepositoryConfig{ + _, repoPath := gittest.CreateRepository(t, ctx, g1Cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, RelativePath: repo1RelPath, Seed: gittest.SeedGitLabTest, diff --git a/internal/praefect/server_factory_test.go b/internal/praefect/server_factory_test.go index bd3147d02..64c842ace 100644 --- a/internal/praefect/server_factory_test.go +++ b/internal/praefect/server_factory_test.go @@ -94,7 +94,7 @@ func TestServerFactory(t *testing.T) { registry, ) - checkOwnRegisteredServices := func(ctx context.Context, t *testing.T, cc *grpc.ClientConn) healthpb.HealthClient { + checkOwnRegisteredServices := func(t *testing.T, ctx context.Context, cc *grpc.ClientConn) healthpb.HealthClient { t.Helper() healthClient := healthpb.NewHealthClient(cc) @@ -104,7 +104,7 @@ func TestServerFactory(t *testing.T) { return healthClient } - checkProxyingOntoGitaly := func(ctx context.Context, t *testing.T, cc *grpc.ClientConn) { + checkProxyingOntoGitaly := func(t *testing.T, ctx context.Context, cc *grpc.ClientConn) { t.Helper() commitClient := gitalypb.NewCommitServiceClient(cc) @@ -116,7 +116,7 @@ func TestServerFactory(t *testing.T) { require.Equal(t, revision, resp.Commit.Id) } - checkSidechannelGitaly := func(ctx context.Context, t *testing.T, addr string, creds credentials.TransportCredentials) { + checkSidechannelGitaly := func(t *testing.T, ctx context.Context, addr string, creds credentials.TransportCredentials) { t.Helper() // Client has its own sidechannel registry, don't reuse the one we plugged into Praefect. @@ -198,15 +198,15 @@ func TestServerFactory(t *testing.T) { ctx := testhelper.Context(t) t.Run("handles registered RPCs", func(t *testing.T) { - checkOwnRegisteredServices(ctx, t, cc) + checkOwnRegisteredServices(t, ctx, cc) }) t.Run("proxies RPCs onto gitaly server", func(t *testing.T) { - checkProxyingOntoGitaly(ctx, t, cc) + checkProxyingOntoGitaly(t, ctx, cc) }) t.Run("proxies sidechannel RPCs onto gitaly server", func(t *testing.T) { - checkSidechannelGitaly(ctx, t, listener.Addr().String(), creds) + checkSidechannelGitaly(t, ctx, listener.Addr().String(), creds) }) }) @@ -237,15 +237,15 @@ func TestServerFactory(t *testing.T) { defer func() { require.NoError(t, cc.Close()) }() t.Run("handles registered RPCs", func(t *testing.T) { - checkOwnRegisteredServices(ctx, t, cc) + checkOwnRegisteredServices(t, ctx, cc) }) t.Run("proxies RPCs onto gitaly server", func(t *testing.T) { - checkProxyingOntoGitaly(ctx, t, cc) + checkProxyingOntoGitaly(t, ctx, cc) }) t.Run("proxies sidechannel RPCs onto gitaly server", func(t *testing.T) { - checkSidechannelGitaly(ctx, t, listener.Addr().String(), creds) + checkSidechannelGitaly(t, ctx, listener.Addr().String(), creds) }) }) @@ -268,7 +268,7 @@ func TestServerFactory(t *testing.T) { require.NoError(t, err) defer func() { require.NoError(t, tcpCC.Close()) }() - tcpHealthClient := checkOwnRegisteredServices(ctx, t, tcpCC) + tcpHealthClient := checkOwnRegisteredServices(t, ctx, tcpCC) // start with tls address tlsListener, err := net.Listen(starter.TCP, "localhost:0") @@ -283,7 +283,7 @@ func TestServerFactory(t *testing.T) { require.NoError(t, err) defer func() { require.NoError(t, tlsCC.Close()) }() - tlsHealthClient := checkOwnRegisteredServices(ctx, t, tlsCC) + tlsHealthClient := checkOwnRegisteredServices(t, ctx, tlsCC) // start with socket address socketPath := testhelper.GetTemporaryGitalySocketFileName(t) @@ -300,7 +300,7 @@ func TestServerFactory(t *testing.T) { require.NoError(t, err) defer func() { require.NoError(t, socketCC.Close()) }() - unixHealthClient := checkOwnRegisteredServices(ctx, t, socketCC) + unixHealthClient := checkOwnRegisteredServices(t, ctx, socketCC) praefectServerFactory.GracefulStop() diff --git a/internal/praefect/server_test.go b/internal/praefect/server_test.go index 15c69e35a..e5e8b6ef6 100644 --- a/internal/praefect/server_test.go +++ b/internal/praefect/server_test.go @@ -629,11 +629,11 @@ func testRenameRepository(t *testing.T, ctx context.Context) { }) t.Cleanup(cleanup) - virtualRepo1, _ := gittest.CreateRepository(ctx, t, gconfig.Cfg{ + virtualRepo1, _ := gittest.CreateRepository(t, ctx, gconfig.Cfg{ Storages: []gconfig.Storage{{Name: "praefect"}}, }, gittest.CreateRepositoryConfig{ClientConn: cc}) - virtualRepo2, _ := gittest.CreateRepository(ctx, t, gconfig.Cfg{ + virtualRepo2, _ := gittest.CreateRepository(t, ctx, gconfig.Cfg{ Storages: []gconfig.Storage{{Name: "praefect"}}, }, gittest.CreateRepositoryConfig{ClientConn: cc}) @@ -859,7 +859,7 @@ func TestProxyWrites(t *testing.T) { for _, storage := range conf.VirtualStorages[0].Nodes { node, err := shard.GetNode(storage.Storage) require.NoError(t, err) - waitNodeToChangeHealthStatus(ctx, t, node, true) + waitNodeToChangeHealthStatus(t, ctx, node, true) } stream, err := client.PostReceivePack(ctx) diff --git a/internal/praefect/verifier_test.go b/internal/praefect/verifier_test.go index f2252e0ad..84331e1e1 100644 --- a/internal/praefect/verifier_test.go +++ b/internal/praefect/verifier_test.go @@ -548,12 +548,12 @@ func TestVerifier(t *testing.T) { for virtualStorage, relativePaths := range tc.replicas { for relativePath, storages := range relativePaths { // Create the expected repository. This creates all of the replicas transactionally. - repo, _ := gittest.CreateRepository(ctx, t, + repo, _ := gittest.CreateRepository(t, ctx, gitalyconfig.Cfg{Storages: []gitalyconfig.Storage{{Name: virtualStorage}}}, gittest.CreateRepositoryConfig{ClientConn: conn, RelativePath: relativePath}, ) - replicaPath := gittest.GetReplicaPath(ctx, t, gitalyconfig.Cfg{}, repo, gittest.GetReplicaPathConfig{ClientConn: conn}) + replicaPath := gittest.GetReplicaPath(t, ctx, gitalyconfig.Cfg{}, repo, gittest.GetReplicaPathConfig{ClientConn: conn}) // Now remove the replicas that were created in the transaction but the test case // expects not to exist. We remove them directly from the Gitalys so the metadata @@ -605,7 +605,7 @@ func TestVerifier(t *testing.T) { } // Create a repository and lock its records to assert the dequeuer does not wait on row locks. - gittest.CreateRepository(ctx, t, + gittest.CreateRepository(t, ctx, gitalyconfig.Cfg{Storages: []gitalyconfig.Storage{{Name: "virtual-storage"}}}, gittest.CreateRepositoryConfig{ClientConn: conn, RelativePath: "locked-repository"}, ) @@ -701,7 +701,7 @@ func TestVerifier(t *testing.T) { require.True(t, exists.GetExists()) // Ensure all the metadata still contains the expected replicas - require.Equal(t, step.expectedReplicas, getAllReplicas(ctx, t, db)) + require.Equal(t, step.expectedReplicas, getAllReplicas(t, ctx, db)) } require.NoError(t, testutil.CollectAndCompare(verifier, strings.NewReader(fmt.Sprintf(` @@ -744,7 +744,7 @@ gitaly_praefect_verification_jobs_dequeued_total{storage="gitaly-2",virtual_stor // getAllReplicas gets all replicas from the database except for the locked-repository which is created // by the test suite to ensure non-blocking queries. -func getAllReplicas(ctx context.Context, tb testing.TB, db glsql.Querier) map[string]map[string][]string { +func getAllReplicas(tb testing.TB, ctx context.Context, db glsql.Querier) map[string]map[string][]string { rows, err := db.QueryContext(ctx, ` SELECT repositories.virtual_storage, repositories.relative_path, storage FROM repositories diff --git a/internal/tempdir/clean_test.go b/internal/tempdir/clean_test.go index b21368d06..c6899aef8 100644 --- a/internal/tempdir/clean_test.go +++ b/internal/tempdir/clean_test.go @@ -59,7 +59,7 @@ func TestCleanTempDir(t *testing.T) { cfg := testcfg.Build(t, testcfg.WithStorages("first", "second")) locator := config.NewLocator(cfg) - gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{ + gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Seed: gittest.SeedGitLabTest, }) diff --git a/internal/testhelper/testcfg/gitaly_builder.go b/internal/testhelper/testcfg/gitaly_builder.go index fbac1e797..28caf6e01 100644 --- a/internal/testhelper/testcfg/gitaly_builder.go +++ b/internal/testhelper/testcfg/gitaly_builder.go @@ -147,7 +147,7 @@ func (gc *GitalyCfgBuilder) BuildWithRepoAt(tb testing.TB, relativePath string) // clone the test repo to the each storage repos := make([]*gitalypb.Repository, len(cfg.Storages)) for i, gitalyStorage := range cfg.Storages { - repo, _ := gittest.CreateRepository(ctx, tb, cfg, gittest.CreateRepositoryConfig{ + repo, _ := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ SkipCreationViaService: true, Storage: gitalyStorage, RelativePath: relativePath, diff --git a/internal/testhelper/testdb/db.go b/internal/testhelper/testdb/db.go index 0a42e4468..222eb7303 100644 --- a/internal/testhelper/testdb/db.go +++ b/internal/testhelper/testdb/db.go @@ -378,7 +378,7 @@ func getDatabaseEnvironment(tb testing.TB) map[string]string { // WaitForBlockedQuery is a helper that waits until a blocked query matching the prefix is present in the // database. This is useful for ensuring another transaction is blocking a query when testing concurrent // execution of multiple queries. -func WaitForBlockedQuery(ctx context.Context, tb testing.TB, db glsql.Querier, queryPrefix string) { +func WaitForBlockedQuery(tb testing.TB, ctx context.Context, db glsql.Querier, queryPrefix string) { tb.Helper() for { diff --git a/internal/testhelper/testserver/gitaly.go b/internal/testhelper/testserver/gitaly.go index 39fa17097..5561507a3 100644 --- a/internal/testhelper/testserver/gitaly.go +++ b/internal/testhelper/testserver/gitaly.go @@ -124,7 +124,7 @@ func (gs GitalyServer) Address() string { } // waitHealthy waits until the server hosted at address becomes healthy. -func waitHealthy(ctx context.Context, tb testing.TB, addr string, authToken string) { +func waitHealthy(tb testing.TB, ctx context.Context, addr string, authToken string) { grpcOpts := []grpc.DialOption{ grpc.WithBlock(), internalclient.UnaryInterceptor(), @@ -182,7 +182,7 @@ func runGitaly(tb testing.TB, cfg config.Cfg, rubyServer *rubyserver.Server, reg }() ctx := testhelper.Context(tb) - waitHealthy(ctx, tb, "unix://"+internalListener.Addr().String(), cfg.Auth.Token) + waitHealthy(tb, ctx, "unix://"+internalListener.Addr().String(), cfg.Auth.Token) } externalServer, err := serverFactory.CreateExternal(cfg.TLS.CertPath != "" && cfg.TLS.KeyPath != "") @@ -217,7 +217,7 @@ func runGitaly(tb testing.TB, cfg config.Cfg, rubyServer *rubyserver.Server, reg }() ctx := testhelper.Context(tb) - waitHealthy(ctx, tb, addr, cfg.Auth.Token) + waitHealthy(tb, ctx, addr, cfg.Auth.Token) return externalServer, addr, gsd.disablePraefect } diff --git a/internal/testhelper/testserver/praefect.go b/internal/testhelper/testserver/praefect.go index 8f4fc5040..7c77ebf60 100644 --- a/internal/testhelper/testserver/praefect.go +++ b/internal/testhelper/testserver/praefect.go @@ -135,7 +135,7 @@ func StartPraefect(tb testing.TB, cfg config.Config) PraefectServer { } }() - waitHealthy(ctx, tb, praefectServer.Address(), cfg.Auth.Token) + waitHealthy(tb, ctx, praefectServer.Address(), cfg.Auth.Token) return praefectServer } |