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:
authorSami Hiltunen <shiltunen@gitlab.com>2022-02-16 21:40:33 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2022-02-23 14:22:04 +0300
commit927e12b870949d5269c06744ae4e9d15fbf8c8f7 (patch)
treec841d508f9180260ebe52380eec5f124a8384315
parenta5fbfdb893532bbde430a13c3fa1666318e6c92b (diff)
Update quarantine repository tests for relative path rewriting
Quarantine directories are set in Gitaly to receive objects into a separate directory from the repository's main object database. The tests are not currently account for relative path rewriting that Praefect would do. To do so, this commit changes the tests to set the quarantine directories based on the rewritten relative path. The API still needs to be called with the relative path so Praefect can route the request correctly.
-rw-r--r--internal/gitaly/service/blob/blobs_test.go15
-rw-r--r--internal/gitaly/service/repository/size_test.go24
2 files changed, 32 insertions, 7 deletions
diff --git a/internal/gitaly/service/blob/blobs_test.go b/internal/gitaly/service/blob/blobs_test.go
index f33484944..119254518 100644
--- a/internal/gitaly/service/blob/blobs_test.go
+++ b/internal/gitaly/service/blob/blobs_test.go
@@ -283,10 +283,19 @@ func TestListAllBlobs(t *testing.T) {
ctx := testhelper.Context(t)
cfg, repo, _, client := setup(ctx, t)
- quarantine, err := quarantine.New(ctx, repo, config.NewLocator(cfg))
+ quarantine, err := quarantine.New(ctx, gittest.RewrittenRepository(ctx, t, cfg, repo), config.NewLocator(cfg))
require.NoError(t, err)
- quarantineRepoWithoutAlternates := proto.Clone(quarantine.QuarantinedRepo()).(*gitalypb.Repository)
+ // quarantine.New in Gitaly would receive an already rewritten repository. Gitaly would then calculate
+ // the quarantine directories based on the rewritten relative path. That quarantine would then be looped
+ // through Rails, which would then send a request with the quarantine object directories set based on the
+ // rewritten relative path but with the original relative path of the repository. Since we're using the production
+ // helpers here, we need to manually substitute the rewritten relative path with the original one when sending
+ // it back through the API.
+ quarantinedRepo := quarantine.QuarantinedRepo()
+ quarantinedRepo.RelativePath = repo.RelativePath
+
+ quarantineRepoWithoutAlternates := proto.Clone(quarantinedRepo).(*gitalypb.Repository)
quarantineRepoWithoutAlternates.GitAlternateObjectDirectories = []string{}
emptyRepo, _ := gittest.CreateRepository(ctx, t, cfg)
@@ -377,7 +386,7 @@ func TestListAllBlobs(t *testing.T) {
{
desc: "quarantine repo with alternates",
request: &gitalypb.ListAllBlobsRequest{
- Repository: quarantine.QuarantinedRepo(),
+ Repository: quarantinedRepo,
},
verify: func(t *testing.T, blobs []*gitalypb.ListAllBlobsResponse_Blob) {
require.Greater(t, len(blobs), 300)
diff --git a/internal/gitaly/service/repository/size_test.go b/internal/gitaly/service/repository/size_test.go
index ecb7754f6..5aa51da73 100644
--- a/internal/gitaly/service/repository/size_test.go
+++ b/internal/gitaly/service/repository/size_test.go
@@ -88,11 +88,20 @@ func TestGetObjectDirectorySize_quarantine(t *testing.T) {
Seed: gittest.SeedGitLabTest,
})
- quarantine, err := quarantine.New(ctx, repo, locator)
+ quarantine, err := quarantine.New(ctx, gittest.RewrittenRepository(ctx, t, cfg, repo), locator)
require.NoError(t, err)
+ // quarantine.New in Gitaly would receive an already rewritten repository. Gitaly would then calculate
+ // the quarantine directories based on the rewritten relative path. That quarantine would then be looped
+ // through Rails, which would then send a request with the quarantine object directories set based on the
+ // rewritten relative path but with the original relative path of the repository. Since we're using the production
+ // helpers here, we need to manually substitute the rewritten relative path with the original one when sending
+ // it back through the API.
+ quarantinedRepo := quarantine.QuarantinedRepo()
+ quarantinedRepo.RelativePath = repo.RelativePath
+
response, err := client.GetObjectDirectorySize(ctx, &gitalypb.GetObjectDirectorySizeRequest{
- Repository: quarantine.QuarantinedRepo(),
+ Repository: quarantinedRepo,
})
require.NoError(t, err)
require.NotNil(t, response)
@@ -106,13 +115,13 @@ func TestGetObjectDirectorySize_quarantine(t *testing.T) {
repo1, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
Seed: gittest.SeedGitLabTest,
})
- quarantine1, err := quarantine.New(ctx, repo1, locator)
+ quarantine1, err := quarantine.New(ctx, gittest.RewrittenRepository(ctx, t, cfg, repo1), locator)
require.NoError(t, err)
repo2, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
Seed: gittest.SeedGitLabTest,
})
- quarantine2, err := quarantine.New(ctx, repo2, locator)
+ quarantine2, err := quarantine.New(ctx, gittest.RewrittenRepository(ctx, t, cfg, repo2), locator)
require.NoError(t, err)
// We swap out the the object directories of both quarantines. So while both are
@@ -120,6 +129,13 @@ func TestGetObjectDirectorySize_quarantine(t *testing.T) {
// swapped-in quarantine directory does not belong to our repository.
repo := proto.Clone(quarantine1.QuarantinedRepo()).(*gitalypb.Repository)
repo.GitObjectDirectory = quarantine2.QuarantinedRepo().GetGitObjectDirectory()
+ // quarantine.New in Gitaly would receive an already rewritten repository. Gitaly would then calculate
+ // the quarantine directories based on the rewritten relative path. That quarantine would then be looped
+ // through Rails, which would then send a request with the quarantine object directories set based on the
+ // rewritten relative path but with the original relative path of the repository. Since we're using the production
+ // helpers here, we need to manually substitute the rewritten relative path with the original one when sending
+ // it back through the API.
+ repo.RelativePath = repo1.RelativePath
response, err := client.GetObjectDirectorySize(ctx, &gitalypb.GetObjectDirectorySizeRequest{
Repository: repo,