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 20:03:27 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2022-02-23 14:22:03 +0300
commita68d116099b67343e83611303644d7e40dce79b3 (patch)
tree9e7046ff4adce717ea1a90b0736ce6eb434b8baa
parent07acdf3940e27fd7727afd512b1681423ed587d1 (diff)
Prepare repository service's tests for replica path
Repository service's test are working on the disk directly and they assume the repositories are stored at the relative path the client sent. This won't be the case anymore with Praefect rewriting relative paths to guarantee atomicity of creations, deletes and renames. This commit updates the tests to access the repositories via the replica path generated by Praefect if Praefect is enabled in the tests.
-rw-r--r--internal/gitaly/service/repository/apply_gitattributes_test.go4
-rw-r--r--internal/gitaly/service/repository/create_fork_test.go4
-rw-r--r--internal/gitaly/service/repository/create_repository_from_bundle_test.go3
-rw-r--r--internal/gitaly/service/repository/fetch_remote_test.go4
-rw-r--r--internal/gitaly/service/repository/gc_test.go4
5 files changed, 10 insertions, 9 deletions
diff --git a/internal/gitaly/service/repository/apply_gitattributes_test.go b/internal/gitaly/service/repository/apply_gitattributes_test.go
index 741a1d8d6..802e3db7d 100644
--- a/internal/gitaly/service/repository/apply_gitattributes_test.go
+++ b/internal/gitaly/service/repository/apply_gitattributes_test.go
@@ -29,9 +29,9 @@ func TestApplyGitattributesSuccess(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, repo, _, client := setupRepositoryService(ctx, t)
+ _, repo, repoPath, client := setupRepositoryService(ctx, t)
- infoPath := filepath.Join(cfg.Storages[0].Path, repo.GetRelativePath(), "info")
+ infoPath := filepath.Join(repoPath, "info")
attributesPath := filepath.Join(infoPath, "attributes")
tests := []struct {
diff --git a/internal/gitaly/service/repository/create_fork_test.go b/internal/gitaly/service/repository/create_fork_test.go
index 2f3592b86..800a9c7ac 100644
--- a/internal/gitaly/service/repository/create_fork_test.go
+++ b/internal/gitaly/service/repository/create_fork_test.go
@@ -224,7 +224,9 @@ func TestCreateFork_targetExists(t *testing.T) {
forkedRepo := &gitalypb.Repository{
// 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.
- RelativePath: praefectutil.DeriveReplicaPath(1),
+ // As the source repository created in the setup is the first one, this would get the repository
+ // ID 2.
+ RelativePath: praefectutil.DeriveReplicaPath(2),
StorageName: repo.StorageName,
}
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 90772615b..8f544432e 100644
--- a/internal/gitaly/service/repository/create_repository_from_bundle_test.go
+++ b/internal/gitaly/service/repository/create_repository_from_bundle_test.go
@@ -74,9 +74,8 @@ func TestCreateRepositoryFromBundle_successful(t *testing.T) {
_, err = stream.CloseAndRecv()
require.NoError(t, err)
- importedRepoProto.RelativePath = getReplicaPath(ctx, t, client, importedRepoProto)
importedRepo := localrepo.NewTestRepo(t, cfg, importedRepoProto)
- importedRepoPath, err := locator.GetPath(importedRepoProto)
+ importedRepoPath, err := locator.GetPath(gittest.RewrittenRepository(ctx, t, cfg, importedRepoProto))
require.NoError(t, err)
defer func() { require.NoError(t, os.RemoveAll(importedRepoPath)) }()
diff --git a/internal/gitaly/service/repository/fetch_remote_test.go b/internal/gitaly/service/repository/fetch_remote_test.go
index 76e845217..998ba2be6 100644
--- a/internal/gitaly/service/repository/fetch_remote_test.go
+++ b/internal/gitaly/service/repository/fetch_remote_test.go
@@ -191,7 +191,7 @@ func TestFetchRemote_transaction(t *testing.T) {
client := newRepositoryClient(t, sourceCfg, addr)
ctx := testhelper.Context(t)
- _, sourceRepoPath := gittest.CreateRepository(ctx, t, sourceCfg, gittest.CreateRepositoryConfig{
+ repo, _ := gittest.CreateRepository(ctx, t, sourceCfg, gittest.CreateRepositoryConfig{
RelativePath: t.Name(),
Seed: gittest.SeedGitLabTest,
})
@@ -213,7 +213,7 @@ func TestFetchRemote_transaction(t *testing.T) {
_, err = client.FetchRemote(ctx, &gitalypb.FetchRemoteRequest{
Repository: targetRepoProto,
RemoteParams: &gitalypb.Remote{
- Url: fmt.Sprintf("http://127.0.0.1:%d/%s", port, filepath.Base(sourceRepoPath)),
+ Url: fmt.Sprintf("http://127.0.0.1:%d/%s", port, repo.GetRelativePath()),
},
})
require.NoError(t, err)
diff --git a/internal/gitaly/service/repository/gc_test.go b/internal/gitaly/service/repository/gc_test.go
index d3c42e2c5..2849a12fb 100644
--- a/internal/gitaly/service/repository/gc_test.go
+++ b/internal/gitaly/service/repository/gc_test.go
@@ -47,7 +47,7 @@ func TestGarbageCollectSuccess(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, repo, _, client := setupRepositoryService(ctx, t)
+ _, repo, repoPath, client := setupRepositoryService(ctx, t)
tests := []struct {
req *gitalypb.GarbageCollectRequest
@@ -63,7 +63,7 @@ func TestGarbageCollectSuccess(t *testing.T) {
},
}
- packPath := filepath.Join(cfg.Storages[0].Path, repo.GetRelativePath(), "objects", "pack")
+ packPath := filepath.Join(repoPath, "objects", "pack")
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {