Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-03-31 08:03:59 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-03-31 08:03:59 +0300
commita32498721df03d6a16731f7aa4ef5143f3fb60d7 (patch)
treedc234e526d18ea27665356f15dfdee8742766861 /internal/gitaly/service
parent438801e8fdf288fe1629365c455941467776bab2 (diff)
parenta650f42c86d5a1f9e78afffe200b39bb95a89859 (diff)
Merge branch 'pks-proto-introduce-maintenance-operations' into 'master'
proto: Introduce new "maintenance" RPC type Closes #4079 See merge request gitlab-org/gitaly!4399
Diffstat (limited to 'internal/gitaly/service')
-rw-r--r--internal/gitaly/service/ref/pack_refs_test.go22
-rw-r--r--internal/gitaly/service/repository/cleanup_test.go33
-rw-r--r--internal/gitaly/service/repository/commit_graph_test.go26
-rw-r--r--internal/gitaly/service/repository/gc_test.go77
-rw-r--r--internal/gitaly/service/repository/midx_test.go31
-rw-r--r--internal/gitaly/service/repository/optimize_test.go23
-rw-r--r--internal/gitaly/service/repository/prune_unreachable_objects_test.go9
-rw-r--r--internal/gitaly/service/repository/repack_test.go65
8 files changed, 240 insertions, 46 deletions
diff --git a/internal/gitaly/service/ref/pack_refs_test.go b/internal/gitaly/service/ref/pack_refs_test.go
index f16aa8175..e6da2b733 100644
--- a/internal/gitaly/service/ref/pack_refs_test.go
+++ b/internal/gitaly/service/ref/pack_refs_test.go
@@ -2,6 +2,7 @@ package ref
import (
"bufio"
+ "context"
"fmt"
"os"
"path/filepath"
@@ -13,6 +14,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/git"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/localrepo"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"google.golang.org/grpc/codes"
@@ -20,7 +22,12 @@ import (
)
func TestPackRefsSuccessfulRequest(t *testing.T) {
- ctx := testhelper.Context(t)
+ t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testPackRefsSuccessfulRequest)
+}
+
+func testPackRefsSuccessfulRequest(t *testing.T, ctx context.Context) {
+ t.Parallel()
cfg, repoProto, repoPath, client := setupRefService(ctx, t)
@@ -67,9 +74,19 @@ func linesInPackfile(t *testing.T, repoPath string) int {
func TestPackRefs_invalidRequest(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testPackRefsInvalidRequest)
+}
+
+func testPackRefsInvalidRequest(t *testing.T, ctx context.Context) {
+ t.Parallel()
cfg, client := setupRefServiceWithoutRepo(t)
+ praefectErr := `mutator call: route repository mutator: get repository id: repository "default"/"bar" not found`
+ if featureflag.MaintenanceOperationRouting.IsEnabled(ctx) {
+ praefectErr = `routing repository maintenance: getting repository metadata: repository not found`
+ }
+
tests := []struct {
repo *gitalypb.Repository
err error
@@ -92,7 +109,7 @@ func TestPackRefs_invalidRequest(t *testing.T) {
codes.NotFound,
gitalyOrPraefect(
fmt.Sprintf(`GetRepoPath: not a git repository: "%s/bar"`, cfg.Storages[0].Path),
- `mutator call: route repository mutator: get repository id: repository "default"/"bar" not found`,
+ praefectErr,
),
),
},
@@ -100,7 +117,6 @@ func TestPackRefs_invalidRequest(t *testing.T) {
for _, tc := range tests {
t.Run(tc.desc, func(t *testing.T) {
- ctx := testhelper.Context(t)
//nolint:staticcheck
_, err := client.PackRefs(ctx, &gitalypb.PackRefsRequest{Repository: tc.repo})
testhelper.RequireGrpcError(t, err, tc.err)
diff --git a/internal/gitaly/service/repository/cleanup_test.go b/internal/gitaly/service/repository/cleanup_test.go
index 1802fee12..50fc670ce 100644
--- a/internal/gitaly/service/repository/cleanup_test.go
+++ b/internal/gitaly/service/repository/cleanup_test.go
@@ -1,6 +1,7 @@
package repository
import (
+ "context"
"fmt"
"os"
"path/filepath"
@@ -10,6 +11,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"google.golang.org/grpc/codes"
@@ -24,6 +26,11 @@ const (
// https://gitlab.com/gitlab-org/gitaly/issues/1750
func TestCleanupDeletesStaleWorktrees(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testCleanupDeletesStaleWorktrees)
+}
+
+func testCleanupDeletesStaleWorktrees(t *testing.T, ctx context.Context) {
+ t.Parallel()
cfg, client := setupRepositoryServiceWithoutRepo(t)
testCases := []struct {
@@ -50,7 +57,6 @@ func TestCleanupDeletesStaleWorktrees(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
- ctx := testhelper.Context(t)
repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
Seed: gittest.SeedGitLabTest,
})
@@ -86,8 +92,12 @@ func TestCleanupDeletesStaleWorktrees(t *testing.T) {
func TestCleanupDeletesOrphanedWorktrees(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testCleanupDeletesOrphanedWorktrees)
+}
+
+func testCleanupDeletesOrphanedWorktrees(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
_, repo, repoPath, client := setupRepositoryService(ctx, t)
worktreeCheckoutPath := filepath.Join(repoPath, worktreePrefix, "test-worktree")
@@ -110,12 +120,16 @@ func TestCleanupDeletesOrphanedWorktrees(t *testing.T) {
// https://gitlab.com/gitlab-org/gitaly/issues/1750
func TestCleanupDisconnectedWorktrees(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testCleanupDisconnectedWorktrees)
+}
+
+func testCleanupDisconnectedWorktrees(t *testing.T, ctx context.Context) {
+ t.Parallel()
const (
worktreeName = "test-worktree"
worktreeAdminDir = "worktrees"
)
- ctx := testhelper.Context(t)
cfg, repo, repoPath, client := setupRepositoryService(ctx, t)
worktreePath := filepath.Join(repoPath, worktreePrefix, worktreeName)
@@ -151,10 +165,19 @@ func TestCleanupDisconnectedWorktrees(t *testing.T) {
func TestCleanup_invalidRequest(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testCleanupInvalidRequest)
+}
+
+func testCleanupInvalidRequest(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
cfg, client := setupRepositoryServiceWithoutRepo(t)
+ praefectErr := `mutator call: route repository mutator: get repository id: repository "default"/"so/me/some.git" not found`
+ if featureflag.MaintenanceOperationRouting.IsEnabled(ctx) {
+ praefectErr = `routing repository maintenance: getting repository metadata: repository not found`
+ }
+
for _, tc := range []struct {
desc string
in *gitalypb.Repository
@@ -176,7 +199,7 @@ func TestCleanup_invalidRequest(t *testing.T) {
codes.NotFound,
gitalyOrPraefect(
fmt.Sprintf(`GetRepoPath: not a git repository: %q`, filepath.Join(cfg.Storages[0].Path, "so/me/some.git")),
- `mutator call: route repository mutator: get repository id: repository "default"/"so/me/some.git" not found`,
+ praefectErr,
),
),
},
diff --git a/internal/gitaly/service/repository/commit_graph_test.go b/internal/gitaly/service/repository/commit_graph_test.go
index c55c64665..b50f520dd 100644
--- a/internal/gitaly/service/repository/commit_graph_test.go
+++ b/internal/gitaly/service/repository/commit_graph_test.go
@@ -2,6 +2,7 @@ package repository
import (
"bytes"
+ "context"
"fmt"
"os"
"path/filepath"
@@ -11,6 +12,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/stats"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
@@ -20,8 +22,12 @@ import (
func TestWriteCommitGraph_withExistingCommitGraphCreatedWithDefaults(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testWriteCommitGraphWithExistingCommitGraphCreatedWithDefaults)
+}
+
+func testWriteCommitGraphWithExistingCommitGraphCreatedWithDefaults(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
cfg, repo, repoPath, client := setupRepositoryService(ctx, t)
commitGraphPath := filepath.Join(repoPath, stats.CommitGraphRelPath)
@@ -58,8 +64,12 @@ func TestWriteCommitGraph_withExistingCommitGraphCreatedWithDefaults(t *testing.
func TestWriteCommitGraph_withExistingCommitGraphCreatedWithSplit(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testWriteCommitGraphWithExistingCommitGraphCreatedWithSplit)
+}
+
+func testWriteCommitGraphWithExistingCommitGraphCreatedWithSplit(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
cfg, repo, repoPath, client := setupRepositoryService(ctx, t)
commitGraphPath := filepath.Join(repoPath, stats.CommitGraphRelPath)
@@ -96,8 +106,12 @@ func TestWriteCommitGraph_withExistingCommitGraphCreatedWithSplit(t *testing.T)
func TestWriteCommitGraph(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testWriteCommitGraph)
+}
+
+func testWriteCommitGraph(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
_, repo, repoPath, client := setupRepositoryService(ctx, t)
chainPath := filepath.Join(repoPath, stats.CommitGraphChainRelPath)
@@ -160,8 +174,12 @@ func TestWriteCommitGraph_validationChecks(t *testing.T) {
func TestUpdateCommitGraph(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testUpdateCommitGraph)
+}
+
+func testUpdateCommitGraph(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
cfg, repo, repoPath, client := setupRepositoryService(ctx, t)
chainPath := filepath.Join(repoPath, stats.CommitGraphChainRelPath)
diff --git a/internal/gitaly/service/repository/gc_test.go b/internal/gitaly/service/repository/gc_test.go
index 2849a12fb..3308110bd 100644
--- a/internal/gitaly/service/repository/gc_test.go
+++ b/internal/gitaly/service/repository/gc_test.go
@@ -1,6 +1,7 @@
package repository
import (
+ "context"
"fmt"
"os"
"path/filepath"
@@ -15,6 +16,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/stats"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper/text"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
@@ -30,8 +32,12 @@ var (
func TestGarbageCollectCommitGraph(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testGarbageCollectCommitGraph)
+}
+
+func testGarbageCollectCommitGraph(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
_, repo, repoPath, client := setupRepositoryService(ctx, t)
//nolint:staticcheck
@@ -45,8 +51,12 @@ func TestGarbageCollectCommitGraph(t *testing.T) {
func TestGarbageCollectSuccess(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testGarbageCollectSuccess)
+}
+
+func testGarbageCollectSuccess(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
_, repo, repoPath, client := setupRepositoryService(ctx, t)
tests := []struct {
@@ -98,7 +108,11 @@ func TestGarbageCollectSuccess(t *testing.T) {
func TestGarbageCollectWithPrune(t *testing.T) {
t.Parallel()
- ctx := testhelper.Context(t)
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testGarbageCollectWithPrune)
+}
+
+func testGarbageCollectWithPrune(t *testing.T, ctx context.Context) {
+ t.Parallel()
cfg, repo, repoPath, client := setupRepositoryService(ctx, t)
@@ -110,7 +124,7 @@ func TestGarbageCollectWithPrune(t *testing.T) {
// create a reference to the blob, so it should not be removed by gc
gittest.WriteCommit(t, cfg, repoPath,
gittest.WithTreeEntries(gittest.TreeEntry{
- OID: git.ObjectID(blobHashes[2]), Path: t.Name(), Mode: "100644",
+ OID: git.ObjectID(blobHashes[2]), Path: "blob-name", Mode: "100644",
}),
)
@@ -141,7 +155,11 @@ func TestGarbageCollectWithPrune(t *testing.T) {
func TestGarbageCollectLogStatistics(t *testing.T) {
t.Parallel()
- ctx := testhelper.Context(t)
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testGarbageCollectLogStatistics)
+}
+
+func testGarbageCollectLogStatistics(t *testing.T, ctx context.Context) {
+ t.Parallel()
logger, hook := test.NewNullLogger()
_, repo, _, client := setupRepositoryService(ctx, t, testserver.WithLogger(logger))
@@ -155,8 +173,12 @@ func TestGarbageCollectLogStatistics(t *testing.T) {
func TestGarbageCollectDeletesRefsLocks(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testGarbageCollectDeletesRefsLocks)
+}
+
+func testGarbageCollectDeletesRefsLocks(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
_, repo, repoPath, client := setupRepositoryService(ctx, t)
req := &gitalypb.GarbageCollectRequest{Repository: repo}
@@ -197,6 +219,11 @@ func TestGarbageCollectDeletesRefsLocks(t *testing.T) {
func TestGarbageCollectDeletesPackedRefsLock(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testGarbageCollectDeletesPackedRefsLock)
+}
+
+func testGarbageCollectDeletesPackedRefsLock(t *testing.T, ctx context.Context) {
+ t.Parallel()
cfg, client := setupRepositoryServiceWithoutRepo(t)
testCases := []struct {
@@ -223,7 +250,6 @@ func TestGarbageCollectDeletesPackedRefsLock(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
- ctx := testhelper.Context(t)
repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
Seed: gittest.SeedGitLabTest,
})
@@ -264,8 +290,12 @@ func TestGarbageCollectDeletesPackedRefsLock(t *testing.T) {
func TestGarbageCollectDeletesFileLocks(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testGarbageCollectDeletesFileLocks)
+}
+
+func testGarbageCollectDeletesFileLocks(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
_, repo, repoPath, client := setupRepositoryService(ctx, t)
req := &gitalypb.GarbageCollectRequest{Repository: repo}
@@ -301,6 +331,11 @@ func TestGarbageCollectDeletesFileLocks(t *testing.T) {
func TestGarbageCollectDeletesPackedRefsNew(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testGarbageCollectDeletesPackedRefsNew)
+}
+
+func testGarbageCollectDeletesPackedRefsNew(t *testing.T, ctx context.Context) {
+ t.Parallel()
cfg, client := setupRepositoryServiceWithoutRepo(t)
testCases := []struct {
@@ -326,7 +361,6 @@ func TestGarbageCollectDeletesPackedRefsNew(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
- ctx := testhelper.Context(t)
repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
req := &gitalypb.GarbageCollectRequest{Repository: repo}
@@ -356,11 +390,20 @@ func TestGarbageCollectDeletesPackedRefsNew(t *testing.T) {
func TestGarbageCollectFailure(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testGarbageCollectFailure)
+}
+
+func testGarbageCollectFailure(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
_, repo, repoPath, client := setupRepositoryService(ctx, t)
storagePath := strings.TrimSuffix(repoPath, "/"+repo.RelativePath)
+ praefectErr := `mutator call: route repository mutator: get repository id: repository "default"/"bar" not found`
+ if featureflag.MaintenanceOperationRouting.IsEnabled(ctx) {
+ praefectErr = `routing repository maintenance: getting repository metadata: repository not found`
+ }
+
tests := []struct {
repo *gitalypb.Repository
err error
@@ -379,7 +422,7 @@ func TestGarbageCollectFailure(t *testing.T) {
codes.NotFound,
gitalyOrPraefect(
fmt.Sprintf(`GetRepoPath: not a git repository: "%s/bar"`, storagePath),
- `mutator call: route repository mutator: get repository id: repository "default"/"bar" not found`,
+ praefectErr,
),
),
},
@@ -396,8 +439,12 @@ func TestGarbageCollectFailure(t *testing.T) {
func TestCleanupInvalidKeepAroundRefs(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testCleanupInvalidKeepAroundRefs)
+}
+
+func testCleanupInvalidKeepAroundRefs(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
cfg, repo, repoPath, client := setupRepositoryService(ctx, t)
// Make the directory, so we can create random reflike things in it
@@ -491,8 +538,12 @@ func mustCreateFileWithTimes(t testing.TB, path string, mTime time.Time) {
func TestGarbageCollectDeltaIslands(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testGarbageCollectDeltaIslands)
+}
+
+func testGarbageCollectDeltaIslands(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
cfg, repo, repoPath, client := setupRepositoryService(ctx, t)
gittest.TestDeltaIslands(t, cfg, repoPath, func() error {
diff --git a/internal/gitaly/service/repository/midx_test.go b/internal/gitaly/service/repository/midx_test.go
index 984f4ee44..d0bea2ca0 100644
--- a/internal/gitaly/service/repository/midx_test.go
+++ b/internal/gitaly/service/repository/midx_test.go
@@ -17,6 +17,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
"gitlab.com/gitlab-org/gitaly/v14/internal/transaction/txinfo"
@@ -28,8 +29,12 @@ import (
func TestMidxWrite(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testMidxWrite)
+}
+
+func testMidxWrite(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
cfg, repo, repoPath, client := setupRepositoryService(ctx, t)
//nolint:staticcheck
@@ -47,8 +52,12 @@ func TestMidxWrite(t *testing.T) {
func TestMidxRewrite(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testMidxRewrite)
+}
+
+func testMidxRewrite(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
_, repo, repoPath, client := setupRepositoryService(ctx, t)
midxPath := filepath.Join(repoPath, MidxRelPath)
@@ -75,8 +84,12 @@ func TestMidxRewrite(t *testing.T) {
func TestMidxRepack(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testMidxRepack)
+}
+
+func testMidxRepack(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
cfg, repo, repoPath, client := setupRepositoryService(ctx, t)
// add some pack files with different sizes
@@ -115,7 +128,11 @@ func TestMidxRepack(t *testing.T) {
func TestMidxRepack_transactional(t *testing.T) {
t.Parallel()
- ctx := testhelper.Context(t)
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testMidxRepackTransactional)
+}
+
+func testMidxRepackTransactional(t *testing.T, ctx context.Context) {
+ t.Parallel()
txManager := transaction.NewTrackingManager()
@@ -145,12 +162,16 @@ func TestMidxRepack_transactional(t *testing.T) {
func TestMidxRepackExpire(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testMidxRepackExpire)
+}
+
+func testMidxRepackExpire(t *testing.T, ctx context.Context) {
+ t.Parallel()
cfg, client := setupRepositoryServiceWithoutRepo(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) {
- ctx := testhelper.Context(t)
repo, repoPath := gittest.CreateRepository(ctx, t, 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 a843b5668..4c63c3972 100644
--- a/internal/gitaly/service/repository/optimize_test.go
+++ b/internal/gitaly/service/repository/optimize_test.go
@@ -2,6 +2,7 @@ package repository
import (
"bytes"
+ "context"
"fmt"
"os"
"path/filepath"
@@ -13,6 +14,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/git"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/stats"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"google.golang.org/grpc/codes"
@@ -43,8 +45,12 @@ func getNewestPackfileModtime(t *testing.T, repoPath string) time.Time {
func TestOptimizeRepository(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testOptimizeRepository)
+}
+
+func testOptimizeRepository(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
cfg, repoProto, repoPath, client := setupRepositoryService(ctx, t)
gittest.Exec(t, cfg, "-C", repoPath, "repack", "-A", "-b")
@@ -157,10 +163,19 @@ func TestOptimizeRepository(t *testing.T) {
func TestOptimizeRepositoryValidation(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testOptimizeRepositoryValidation)
+}
+
+func testOptimizeRepositoryValidation(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
cfg, repo, _, client := setupRepositoryService(ctx, t)
+ praefectErr := `mutator call: route repository mutator: get repository id: repository "default"/"path/not/exist" not found`
+ if featureflag.MaintenanceOperationRouting.IsEnabled(ctx) {
+ praefectErr = `routing repository maintenance: getting repository metadata: repository not found`
+ }
+
testCases := []struct {
desc string
repo *gitalypb.Repository
@@ -183,7 +198,7 @@ func TestOptimizeRepositoryValidation(t *testing.T) {
codes.NotFound,
gitalyOrPraefect(
fmt.Sprintf(`GetRepoPath: not a git repository: "%s/path/not/exist"`, cfg.Storages[0].Path),
- `mutator call: route repository mutator: get repository id: repository "default"/"path/not/exist" not found`,
+ praefectErr,
),
),
},
@@ -193,7 +208,7 @@ func TestOptimizeRepositoryValidation(t *testing.T) {
t.Run(tc.desc, func(t *testing.T) {
_, err := client.OptimizeRepository(ctx, &gitalypb.OptimizeRepositoryRequest{Repository: tc.repo})
require.Error(t, err)
- testhelper.RequireGrpcError(t, err, tc.exp)
+ testhelper.RequireGrpcError(t, tc.exp, err)
})
}
diff --git a/internal/gitaly/service/repository/prune_unreachable_objects_test.go b/internal/gitaly/service/repository/prune_unreachable_objects_test.go
index 3d1d6c1f8..b02aa224e 100644
--- a/internal/gitaly/service/repository/prune_unreachable_objects_test.go
+++ b/internal/gitaly/service/repository/prune_unreachable_objects_test.go
@@ -1,6 +1,7 @@
package repository
import (
+ "context"
"os"
"path/filepath"
"testing"
@@ -10,12 +11,18 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/git"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
)
func TestPruneUnreachableObjects(t *testing.T) {
- ctx := testhelper.Context(t)
+ t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testPruneUnreachableObjects)
+}
+
+func testPruneUnreachableObjects(t *testing.T, ctx context.Context) {
+ t.Parallel()
cfg, client := setupRepositoryServiceWithoutRepo(t)
diff --git a/internal/gitaly/service/repository/repack_test.go b/internal/gitaly/service/repository/repack_test.go
index d7efb78dc..244e23077 100644
--- a/internal/gitaly/service/repository/repack_test.go
+++ b/internal/gitaly/service/repository/repack_test.go
@@ -1,6 +1,7 @@
package repository
import (
+ "context"
"fmt"
"path/filepath"
"testing"
@@ -12,6 +13,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/stats"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
@@ -21,8 +23,12 @@ import (
func TestRepackIncrementalSuccess(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testRepackIncrementalSuccess)
+}
+
+func testRepackIncrementalSuccess(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
_, repo, repoPath, client := setupRepositoryService(ctx, t)
packPath := filepath.Join(repoPath, "objects", "pack")
@@ -48,7 +54,11 @@ func TestRepackIncrementalSuccess(t *testing.T) {
func TestRepackIncrementalCollectLogStatistics(t *testing.T) {
t.Parallel()
- ctx := testhelper.Context(t)
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testRepackIncrementalCollectLogStatistics)
+}
+
+func testRepackIncrementalCollectLogStatistics(t *testing.T, ctx context.Context) {
+ t.Parallel()
logger, hook := test.NewNullLogger()
_, repo, _, client := setupRepositoryService(ctx, t, testserver.WithLogger(logger))
@@ -62,8 +72,12 @@ func TestRepackIncrementalCollectLogStatistics(t *testing.T) {
func TestRepackLocal(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testRepackLocal)
+}
+
+func testRepackLocal(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
cfg, repo, repoPath, client := setupRepositoryService(ctx, t)
altObjectsDir := "./alt-objects"
@@ -99,8 +113,18 @@ func TestRepackLocal(t *testing.T) {
func TestRepackIncrementalFailure(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testRepackIncrementalFailure)
+}
+
+func testRepackIncrementalFailure(t *testing.T, ctx context.Context) {
+ t.Parallel()
cfg, client := setupRepositoryServiceWithoutRepo(t)
+ praefectErr := `mutator call: route repository mutator: get repository id: repository "default"/"bar" not found`
+ if featureflag.MaintenanceOperationRouting.IsEnabled(ctx) {
+ praefectErr = `routing repository maintenance: getting repository metadata: repository not found`
+ }
+
tests := []struct {
repo *gitalypb.Repository
err error
@@ -128,7 +152,7 @@ func TestRepackIncrementalFailure(t *testing.T) {
codes.NotFound,
gitalyOrPraefect(
fmt.Sprintf(`GetRepoPath: not a git repository: "%s/bar"`, cfg.Storages[0].Path),
- `mutator call: route repository mutator: get repository id: repository "default"/"bar" not found`,
+ praefectErr,
),
),
},
@@ -136,7 +160,6 @@ func TestRepackIncrementalFailure(t *testing.T) {
for _, tc := range tests {
t.Run(tc.desc, func(t *testing.T) {
- ctx := testhelper.Context(t)
//nolint:staticcheck
_, err := client.RepackIncremental(ctx, &gitalypb.RepackIncrementalRequest{Repository: tc.repo})
testhelper.RequireGrpcError(t, err, tc.err)
@@ -146,6 +169,11 @@ func TestRepackIncrementalFailure(t *testing.T) {
func TestRepackFullSuccess(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testRepackFullSuccess)
+}
+
+func testRepackFullSuccess(t *testing.T, ctx context.Context) {
+ t.Parallel()
cfg, client := setupRepositoryServiceWithoutRepo(t)
tests := []struct {
@@ -158,8 +186,6 @@ func TestRepackFullSuccess(t *testing.T) {
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
- ctx := testhelper.Context(t)
-
var repoPath string
test.req.Repository, repoPath = gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
Seed: gittest.SeedGitLabTest,
@@ -202,7 +228,11 @@ func TestRepackFullSuccess(t *testing.T) {
func TestRepackFullCollectLogStatistics(t *testing.T) {
t.Parallel()
- ctx := testhelper.Context(t)
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testRepackFullCollectLogStatistics)
+}
+
+func testRepackFullCollectLogStatistics(t *testing.T, ctx context.Context) {
+ t.Parallel()
logger, hook := test.NewNullLogger()
_, repo, _, client := setupRepositoryService(ctx, t, testserver.WithLogger(logger))
@@ -243,8 +273,18 @@ func doBitmapsContainHashCache(t *testing.T, bitmapPaths []string) {
func TestRepackFullFailure(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testRepackFullFailure)
+}
+
+func testRepackFullFailure(t *testing.T, ctx context.Context) {
+ t.Parallel()
cfg, client := setupRepositoryServiceWithoutRepo(t)
+ praefectErr := `mutator call: route repository mutator: get repository id: repository "default"/"bar" not found`
+ if featureflag.MaintenanceOperationRouting.IsEnabled(ctx) {
+ praefectErr = `routing repository maintenance: getting repository metadata: repository not found`
+ }
+
tests := []struct {
desc string
repo *gitalypb.Repository
@@ -272,7 +312,7 @@ func TestRepackFullFailure(t *testing.T) {
codes.NotFound,
gitalyOrPraefect(
fmt.Sprintf(`GetRepoPath: not a git repository: "%s/bar"`, cfg.Storages[0].Path),
- `mutator call: route repository mutator: get repository id: repository "default"/"bar" not found`,
+ praefectErr,
),
),
},
@@ -280,7 +320,6 @@ func TestRepackFullFailure(t *testing.T) {
for _, tc := range tests {
t.Run(tc.desc, func(t *testing.T) {
- ctx := testhelper.Context(t)
//nolint:staticcheck
_, err := client.RepackFull(ctx, &gitalypb.RepackFullRequest{Repository: tc.repo})
testhelper.RequireGrpcError(t, err, tc.err)
@@ -290,8 +329,12 @@ func TestRepackFullFailure(t *testing.T) {
func TestRepackFullDeltaIslands(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.MaintenanceOperationRouting).Run(t, testRepackFullDeltaIslands)
+}
+
+func testRepackFullDeltaIslands(t *testing.T, ctx context.Context) {
+ t.Parallel()
- ctx := testhelper.Context(t)
cfg, repo, repoPath, client := setupRepositoryService(ctx, t)
gittest.TestDeltaIslands(t, cfg, repoPath, func() error {