diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-12-13 21:35:11 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-12-15 09:50:22 +0300 |
commit | 0a4043b8a5069a1ee1059f586f69afccd730e471 (patch) | |
tree | 72c6e16cbb26f060e32db3040e8a078b44123aa3 | |
parent | 2bf28a8f16fc5eea123fc056f34f544bfe880cd3 (diff) |
operations: Parallelize UserCommitFiles tests
The tests for UserCommitFiles are quite expensive, mostly because there
is so many of them. Refactor the tests a bit so that we can parallelize
them.
-rw-r--r-- | internal/gitaly/service/operations/commit_files_test.go | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/internal/gitaly/service/operations/commit_files_test.go b/internal/gitaly/service/operations/commit_files_test.go index ccd85753a..e237171cd 100644 --- a/internal/gitaly/service/operations/commit_files_test.go +++ b/internal/gitaly/service/operations/commit_files_test.go @@ -40,16 +40,15 @@ func TestUserCommitFiles(t *testing.T) { func testUserCommitFiles(t *testing.T, ctx context.Context) { t.Parallel() - ctx, cfg, _, _, client := setupOperationsService(t, ctx) + ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) const ( DefaultMode = "100644" ExecutableMode = "100755" - - targetRelativePath = "target-repository" ) startRepo, _ := gittest.CreateRepository(t, ctx, cfg) + targetRepoSentinel := &gitalypb.Repository{} type step struct { actions []*gitalypb.UserCommitFilesRequest @@ -851,12 +850,9 @@ func testUserCommitFiles(t *testing.T, ctx context.Context) { createFileHeaderRequest("file-1"), actionContentRequest("content-1"), }, - startRepository: &gitalypb.Repository{ - StorageName: startRepo.GetStorageName(), - RelativePath: targetRelativePath, - }, - branchCreated: true, - repoCreated: true, + startRepository: targetRepoSentinel, + branchCreated: true, + repoCreated: true, treeEntries: []gittest.TreeEntry{ {Mode: DefaultMode, Path: "file-1", Content: "content-1"}, }, @@ -899,14 +895,20 @@ func testUserCommitFiles(t *testing.T, ctx context.Context) { }, }, } { + tc := tc + t.Run(tc.desc, func(t *testing.T) { + t.Parallel() + const branch = "main" - repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ - RelativePath: targetRelativePath, - }) + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) for i, step := range tc.steps { + if step.startRepository == targetRepoSentinel { + step.startRepository = repo + } + headerRequest := headerRequest( repo, gittest.TestUser, |