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-08-08 13:23:05 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-08-10 16:51:05 +0300
commit490079df23d38b65b6182d584cc669243494dea2 (patch)
tree712483e6339cf0103cfedf42d45a74898e21b3a2
parente947c22e7e4eff65bf40c9b736cd36d71c97045d (diff)
services: Don't needlessly skip repo creation via APIpks-gittest-create-repo-consolidation
While it makes sense for tests to skip repository creation via the `CreateRepository()` RPC when they are not testing in a context where they have a gRPC server available, there should in the general case not be a reason to skip this in our service-related tests. There still is a bunch of tests that do this though. Adjust the tests to not skip the RPC calls to create the repository and refactor some that didn't make the server address available via the Gitaly configuration. Note that we need to some touch up some tests which erroneously created the repository multiple times, which would now fail with Praefect.
-rw-r--r--internal/gitaly/service/commit/tree_entries_test.go3
-rw-r--r--internal/gitaly/service/operations/commit_files_test.go4
-rw-r--r--internal/gitaly/service/operations/rebase_test.go3
-rw-r--r--internal/gitaly/service/ref/find_all_tags_test.go3
-rw-r--r--internal/gitaly/service/remote/find_remote_root_ref_test.go4
-rw-r--r--internal/gitaly/service/repository/archive_test.go3
-rw-r--r--internal/gitaly/service/repository/create_repository_from_bundle_test.go11
-rw-r--r--internal/gitaly/service/repository/create_repository_from_snapshot_test.go83
-rw-r--r--internal/gitaly/service/repository/create_repository_test.go18
-rw-r--r--internal/gitaly/service/repository/fetch_test.go3
-rw-r--r--internal/gitaly/service/repository/license_test.go8
-rw-r--r--internal/gitaly/service/repository/replicate_test.go31
-rw-r--r--internal/gitaly/service/repository/repository_test.go6
-rw-r--r--internal/gitaly/service/repository/snapshot_test.go14
-rw-r--r--internal/gitaly/service/smarthttp/receive_pack_test.go62
-rw-r--r--internal/gitaly/service/ssh/receive_pack_test.go3
16 files changed, 110 insertions, 149 deletions
diff --git a/internal/gitaly/service/commit/tree_entries_test.go b/internal/gitaly/service/commit/tree_entries_test.go
index ca079ee09..e763619a4 100644
--- a/internal/gitaly/service/commit/tree_entries_test.go
+++ b/internal/gitaly/service/commit/tree_entries_test.go
@@ -720,8 +720,7 @@ func BenchmarkGetTreeEntries(b *testing.B) {
cfg, client := setupCommitService(ctx, b)
repo, _ := gittest.CreateRepository(ctx, b, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: "benchmark.git",
+ Seed: "benchmark.git",
})
for _, tc := range []struct {
diff --git a/internal/gitaly/service/operations/commit_files_test.go b/internal/gitaly/service/operations/commit_files_test.go
index 3eb876c00..1c23a7646 100644
--- a/internal/gitaly/service/operations/commit_files_test.go
+++ b/internal/gitaly/service/operations/commit_files_test.go
@@ -1293,9 +1293,7 @@ func testSuccessfulUserCommitFilesRemoteRepositoryRequest(setHeader func(header
repo := localrepo.NewTestRepo(t, cfg, repoProto)
- newRepoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- })
+ newRepoProto, _ := gittest.CreateRepository(ctx, t, cfg)
newRepo := localrepo.NewTestRepo(t, cfg, newRepoProto)
targetBranchName := "new"
diff --git a/internal/gitaly/service/operations/rebase_test.go b/internal/gitaly/service/operations/rebase_test.go
index 80a5de039..d8e216d94 100644
--- a/internal/gitaly/service/operations/rebase_test.go
+++ b/internal/gitaly/service/operations/rebase_test.go
@@ -348,8 +348,7 @@ func TestUserRebaseConfirmable_inputValidation(t *testing.T) {
ctx, cfg, repo, repoPath, client := setupOperationsService(t, ctx)
repoCopy, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ Seed: gittest.SeedGitLabTest,
})
branchCommitID := gittest.ResolveRevision(t, cfg, repoPath, rebaseBranchName)
diff --git a/internal/gitaly/service/ref/find_all_tags_test.go b/internal/gitaly/service/ref/find_all_tags_test.go
index 5a34e683a..eba8e28e1 100644
--- a/internal/gitaly/service/ref/find_all_tags_test.go
+++ b/internal/gitaly/service/ref/find_all_tags_test.go
@@ -691,8 +691,7 @@ func BenchmarkFindAllTags(b *testing.B) {
cfg, client := setupRefServiceWithoutRepo(b)
repoProto, repoPath := gittest.CreateRepository(ctx, b, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ Seed: gittest.SeedGitLabTest,
})
for i := 0; i < 1000; i++ {
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 c97b26d4f..193946176 100644
--- a/internal/gitaly/service/remote/find_remote_root_ref_test.go
+++ b/internal/gitaly/service/remote/find_remote_root_ref_test.go
@@ -65,9 +65,7 @@ func TestFindRemoteRootRefWithUnbornRemoteHead(t *testing.T) {
// 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, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- })
+ _, clientRepoPath := gittest.CreateRepository(ctx, t, cfg)
gittest.Exec(t, cfg, "-C", remoteRepoPath, "remote", "add", "foo", "file://"+clientRepoPath)
response, err := client.FindRemoteRootRef(ctx, &gitalypb.FindRemoteRootRefRequest{
Repository: remoteRepo,
diff --git a/internal/gitaly/service/repository/archive_test.go b/internal/gitaly/service/repository/archive_test.go
index fbf8efe60..b5ac1f0d2 100644
--- a/internal/gitaly/service/repository/archive_test.go
+++ b/internal/gitaly/service/repository/archive_test.go
@@ -483,8 +483,7 @@ func TestGetArchive_environment(t *testing.T) {
cfg.SocketPath = serverSocketPath
repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ Seed: gittest.SeedGitLabTest,
})
commitID := "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863"
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 b5c7a03cd..015b0d9e6 100644
--- a/internal/gitaly/service/repository/create_repository_from_bundle_test.go
+++ b/internal/gitaly/service/repository/create_repository_from_bundle_test.go
@@ -266,9 +266,8 @@ func TestCreateRepositoryFromBundle_existingRepository(t *testing.T) {
// 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{
- SkipCreationViaService: true,
- RelativePath: praefectutil.DeriveReplicaPath(1),
- Seed: gittest.SeedGitLabTest,
+ RelativePath: praefectutil.DeriveReplicaPath(1),
+ Seed: gittest.SeedGitLabTest,
})
stream, err := client.CreateRepositoryFromBundle(ctx)
@@ -279,7 +278,11 @@ func TestCreateRepositoryFromBundle_existingRepository(t *testing.T) {
}))
_, err = stream.CloseAndRecv()
- testhelper.RequireGrpcError(t, status.Error(codes.AlreadyExists, "creating repository: repository exists already"), err)
+ if testhelper.IsPraefectEnabled() {
+ testhelper.ProtoEqual(t, status.Error(codes.AlreadyExists, "route repository creation: reserve repository id: repository already exists"), err)
+ } else {
+ testhelper.ProtoEqual(t, status.Error(codes.AlreadyExists, "creating repository: repository exists already"), err)
+ }
}
func TestSanitizedError(t *testing.T) {
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 7dbe42ff8..a5983eb68 100644
--- a/internal/gitaly/service/repository/create_repository_from_snapshot_test.go
+++ b/internal/gitaly/service/repository/create_repository_from_snapshot_test.go
@@ -4,7 +4,6 @@ package repository
import (
"bytes"
- "context"
"io"
"net/http"
"net/http/httptest"
@@ -16,7 +15,6 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/archive"
- "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v15/internal/praefect/praefectutil"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper/testcfg"
@@ -69,22 +67,17 @@ func generateTarFile(t *testing.T, path string) ([]byte, []string) {
return data, entries
}
-func createFromSnapshot(t *testing.T, ctx context.Context, req *gitalypb.CreateRepositoryFromSnapshotRequest, cfg config.Cfg) (*gitalypb.CreateRepositoryFromSnapshotResponse, error) {
- t.Helper()
-
- client, _ := runRepositoryService(t, cfg, nil)
-
- return client.CreateRepositoryFromSnapshot(ctx, req)
-}
-
func TestCreateRepositoryFromSnapshot_success(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
cfg := testcfg.Build(t)
+
+ client, socketPath := runRepositoryService(t, cfg, nil)
+ cfg.SocketPath = socketPath
+
_, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ Seed: gittest.SeedGitLabTest,
})
// Ensure these won't be in the archive
@@ -110,9 +103,6 @@ func TestCreateRepositoryFromSnapshot_success(t *testing.T) {
HttpHost: host,
}
- client, socketPath := runRepositoryService(t, cfg, nil)
- cfg.SocketPath = socketPath
-
rsp, err := client.CreateRepositoryFromSnapshot(ctx, req)
require.NoError(t, err)
testhelper.ProtoEqual(t, rsp, &gitalypb.CreateRepositoryFromSnapshotResponse{})
@@ -136,40 +126,45 @@ func TestCreateRepositoryFromSnapshot_repositoryExists(t *testing.T) {
ctx := testhelper.Context(t)
cfg := testcfg.Build(t)
+ client, socketPath := runRepositoryService(t, cfg, nil)
+ cfg.SocketPath = socketPath
// 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{
- SkipCreationViaService: true,
- RelativePath: praefectutil.DeriveReplicaPath(1),
- Seed: gittest.SeedGitLabTest,
+ RelativePath: praefectutil.DeriveReplicaPath(1),
+ Seed: gittest.SeedGitLabTest,
})
req := &gitalypb.CreateRepositoryFromSnapshotRequest{Repository: repo}
- rsp, err := createFromSnapshot(t, ctx, req, cfg)
+ rsp, err := client.CreateRepositoryFromSnapshot(ctx, req)
testhelper.RequireGrpcCode(t, err, codes.AlreadyExists)
- require.Contains(t, err.Error(), "creating repository: repository exists already")
+ if testhelper.IsPraefectEnabled() {
+ require.Contains(t, err.Error(), "route repository creation: reserve repository id: repository already exists")
+ } else {
+ require.Contains(t, err.Error(), "creating repository: repository exists already")
+ }
require.Nil(t, rsp)
}
func TestCreateRepositoryFromSnapshot_badURL(t *testing.T) {
t.Parallel()
- ctx := testhelper.Context(t)
+ ctx := testhelper.Context(t)
cfg := testcfg.Build(t)
- repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
- })
- require.NoError(t, os.RemoveAll(repoPath))
+ client, socketPath := runRepositoryService(t, cfg, nil)
+ cfg.SocketPath = socketPath
req := &gitalypb.CreateRepositoryFromSnapshotRequest{
- Repository: repo,
- HttpUrl: "invalid!scheme://invalid.invalid",
+ Repository: &gitalypb.Repository{
+ StorageName: cfg.Storages[0].Name,
+ RelativePath: gittest.NewRepositoryName(t, true),
+ },
+ HttpUrl: "invalid!scheme://invalid.invalid",
}
- rsp, err := createFromSnapshot(t, ctx, req, cfg)
+ rsp, err := client.CreateRepositoryFromSnapshot(ctx, req)
testhelper.RequireGrpcCode(t, err, codes.InvalidArgument)
require.Contains(t, err.Error(), "Bad HTTP URL")
require.Nil(t, rsp)
@@ -215,23 +210,22 @@ func TestCreateRepositoryFromSnapshot_invalidArguments(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
cfg := testcfg.Build(t)
- repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
- })
- require.NoError(t, os.RemoveAll(repoPath))
+ client, socketPath := runRepositoryService(t, cfg, nil)
+ cfg.SocketPath = socketPath
req := &gitalypb.CreateRepositoryFromSnapshotRequest{
- Repository: repo,
- HttpUrl: srv.URL + tc.url,
- HttpAuth: tc.auth,
- HttpHost: host,
+ Repository: &gitalypb.Repository{
+ StorageName: cfg.Storages[0].Name,
+ RelativePath: gittest.NewRepositoryName(t, true),
+ },
+ HttpUrl: srv.URL + tc.url,
+ HttpAuth: tc.auth,
+ HttpHost: host,
}
- rsp, err := createFromSnapshot(t, ctx, req, cfg)
+ rsp, err := client.CreateRepositoryFromSnapshot(ctx, req)
testhelper.RequireGrpcCode(t, err, tc.code)
require.Nil(t, rsp)
-
require.Contains(t, err.Error(), tc.errContains)
})
}
@@ -242,9 +236,11 @@ func TestCreateRepositoryFromSnapshot_malformedResponse(t *testing.T) {
ctx := testhelper.Context(t)
cfg := testcfg.Build(t)
+ client, socketPath := runRepositoryService(t, cfg, nil)
+ cfg.SocketPath = socketPath
+
repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ Seed: gittest.SeedGitLabTest,
})
require.NoError(t, os.Remove(filepath.Join(repoPath, "config")))
@@ -267,8 +263,7 @@ func TestCreateRepositoryFromSnapshot_malformedResponse(t *testing.T) {
HttpHost: host,
}
- rsp, err := createFromSnapshot(t, ctx, req, cfg)
-
+ rsp, err := client.CreateRepositoryFromSnapshot(ctx, req)
require.Error(t, err)
require.Nil(t, rsp)
diff --git a/internal/gitaly/service/repository/create_repository_test.go b/internal/gitaly/service/repository/create_repository_test.go
index 0c956e9b3..d1976715e 100644
--- a/internal/gitaly/service/repository/create_repository_test.go
+++ b/internal/gitaly/service/repository/create_repository_test.go
@@ -208,14 +208,17 @@ func TestCreateRepository_transactional(t *testing.T) {
// 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{
- SkipCreationViaService: true,
- RelativePath: praefectutil.DeriveReplicaPath(2),
+ RelativePath: praefectutil.DeriveReplicaPath(2),
})
_, err = client.CreateRepository(ctx, &gitalypb.CreateRepositoryRequest{
Repository: repo,
})
- testhelper.ProtoEqual(t, status.Error(codes.AlreadyExists, "creating repository: repository exists already"), err)
+ if testhelper.IsPraefectEnabled() {
+ testhelper.ProtoEqual(t, status.Error(codes.AlreadyExists, "route repository creation: reserve repository id: repository already exists"), err)
+ } else {
+ testhelper.ProtoEqual(t, status.Error(codes.AlreadyExists, "creating repository: repository exists already"), err)
+ }
})
}
@@ -233,11 +236,14 @@ func TestCreateRepository_idempotent(t *testing.T) {
RelativePath: praefectutil.DeriveReplicaPath(1),
}
gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- RelativePath: repo.RelativePath,
+ RelativePath: repo.RelativePath,
})
req := &gitalypb.CreateRepositoryRequest{Repository: repo}
_, err := client.CreateRepository(ctx, req)
- testhelper.ProtoEqual(t, status.Error(codes.AlreadyExists, "creating repository: repository exists already"), err)
+ if testhelper.IsPraefectEnabled() {
+ testhelper.ProtoEqual(t, status.Error(codes.AlreadyExists, "route repository creation: reserve repository id: repository already exists"), err)
+ } else {
+ testhelper.ProtoEqual(t, status.Error(codes.AlreadyExists, "creating repository: repository exists already"), err)
+ }
}
diff --git a/internal/gitaly/service/repository/fetch_test.go b/internal/gitaly/service/repository/fetch_test.go
index b60b6c52d..7a3a281fd 100644
--- a/internal/gitaly/service/repository/fetch_test.go
+++ b/internal/gitaly/service/repository/fetch_test.go
@@ -139,8 +139,7 @@ func TestFetchSourceBranchWrongRef(t *testing.T) {
ctx = testhelper.MergeOutgoingMetadata(ctx, md)
sourceRepo, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ Seed: gittest.SeedGitLabTest,
})
sourceBranch := "fetch-source-branch-testmas-branch"
diff --git a/internal/gitaly/service/repository/license_test.go b/internal/gitaly/service/repository/license_test.go
index bfc18d3fa..a32171779 100644
--- a/internal/gitaly/service/repository/license_test.go
+++ b/internal/gitaly/service/repository/license_test.go
@@ -108,13 +108,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, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- })
- require.NoError(t, os.RemoveAll(repoPath))
-
- _, err := client.CreateRepository(ctx, &gitalypb.CreateRepositoryRequest{Repository: repo})
- require.NoError(t, err)
+ repo, _ := gittest.CreateRepository(ctx, t, cfg)
resp, err := client.FindLicense(ctx, &gitalypb.FindLicenseRequest{Repository: repo})
require.NoError(t, err)
diff --git a/internal/gitaly/service/repository/replicate_test.go b/internal/gitaly/service/repository/replicate_test.go
index 9f8bf64f5..b35123e7a 100644
--- a/internal/gitaly/service/repository/replicate_test.go
+++ b/internal/gitaly/service/repository/replicate_test.go
@@ -51,8 +51,7 @@ func TestReplicateRepository(t *testing.T) {
cfg.SocketPath = serverSocketPath
repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ Seed: gittest.SeedGitLabTest,
})
// create a loose object to ensure snapshot replication is used
@@ -127,10 +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,
- gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- })
+ sourceRepo, sourceRepoPath := gittest.CreateRepository(ctx, t, 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.
@@ -162,13 +158,10 @@ func TestReplicateRepository_hiddenRefs(t *testing.T) {
})
t.Run("incremental replication", func(t *testing.T) {
- sourceRepo, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- })
+ sourceRepo, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg)
targetRepo, targetRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- RelativePath: sourceRepo.GetRelativePath(),
- Storage: cfg.Storages[1],
+ RelativePath: sourceRepo.GetRelativePath(),
+ Storage: cfg.Storages[1],
})
// Create the same commit in both repositories so that they're in a known-good
@@ -214,8 +207,7 @@ func TestReplicateRepositoryTransactional(t *testing.T) {
cfg.SocketPath = serverSocketPath
sourceRepo, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ Seed: gittest.SeedGitLabTest,
})
targetRepo := proto.Clone(sourceRepo).(*gitalypb.Repository)
@@ -426,13 +418,11 @@ func TestReplicateRepository_BadRepository(t *testing.T) {
cfg.SocketPath = serverSocketPath
sourceRepo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ Seed: gittest.SeedGitLabTest,
})
targetRepo, targetRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Storage: cfg.Storages[1],
- RelativePath: sourceRepo.RelativePath,
+ Storage: cfg.Storages[1],
+ RelativePath: sourceRepo.RelativePath,
})
var invalidRepos []*gitalypb.Repository
@@ -485,8 +475,7 @@ func TestReplicateRepository_FailedFetchInternalRemote(t *testing.T) {
cfg.SocketPath = socketPath
targetRepo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Storage: cfg.Storages[1],
+ Storage: cfg.Storages[1],
})
// The source repository must be at the same path as the target repository, and it must be a
diff --git a/internal/gitaly/service/repository/repository_test.go b/internal/gitaly/service/repository/repository_test.go
index ce650b336..74faba1c7 100644
--- a/internal/gitaly/service/repository/repository_test.go
+++ b/internal/gitaly/service/repository/repository_test.go
@@ -25,11 +25,11 @@ func TestRepositoryExists(t *testing.T) {
require.NoError(t, os.RemoveAll(cfg.Storages[2].Path), "third storage needs to be invalid")
- client, _ := runRepositoryService(t, cfg, nil, testserver.WithDisablePraefect())
+ client, socketPath := runRepositoryService(t, cfg, nil, testserver.WithDisablePraefect())
+ cfg.SocketPath = socketPath
repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ Seed: gittest.SeedGitLabTest,
})
queries := []struct {
diff --git a/internal/gitaly/service/repository/snapshot_test.go b/internal/gitaly/service/repository/snapshot_test.go
index 49d1e93d7..ecc32563c 100644
--- a/internal/gitaly/service/repository/snapshot_test.go
+++ b/internal/gitaly/service/repository/snapshot_test.go
@@ -252,13 +252,10 @@ func copyRepoUsingSnapshot(t *testing.T, ctx context.Context, cfg config.Cfg, cl
srv := httptest.NewServer(&tarTesthandler{tarData: bytes.NewBuffer(data), secret: secret})
defer srv.Close()
- repoCopy, repoCopyPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
- })
-
- // Delete the repository so we can re-use the path
- require.NoError(t, os.RemoveAll(repoCopyPath))
+ repoCopy := &gitalypb.Repository{
+ StorageName: cfg.Storages[0].Name,
+ RelativePath: gittest.NewRepositoryName(t, true),
+ }
createRepoReq := &gitalypb.CreateRepositoryFromSnapshotRequest{
Repository: repoCopy,
@@ -269,7 +266,8 @@ func copyRepoUsingSnapshot(t *testing.T, ctx context.Context, cfg config.Cfg, cl
rsp, err := client.CreateRepositoryFromSnapshot(ctx, createRepoReq)
require.NoError(t, err)
testhelper.ProtoEqual(t, rsp, &gitalypb.CreateRepositoryFromSnapshotResponse{})
- return repoCopy, repoCopyPath
+
+ return repoCopy, filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(ctx, t, cfg, repoCopy))
}
func TestGetSnapshotFailsIfRepositoryMissing(t *testing.T) {
diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go
index 1d50d2ea6..df6e855ed 100644
--- a/internal/gitaly/service/smarthttp/receive_pack_test.go
+++ b/internal/gitaly/service/smarthttp/receive_pack_test.go
@@ -20,8 +20,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/internal/git/pktline"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config"
gitalyhook "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/hook"
- "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/service"
- "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/service/hook"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitlab"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper/text"
@@ -761,28 +759,23 @@ func (t *testTransactionServer) VoteTransaction(ctx context.Context, in *gitalyp
func TestPostReceivePack_referenceTransactionHook(t *testing.T) {
t.Parallel()
- ctx := testhelper.Context(t)
+ ctxWithoutTransaction := testhelper.Context(t)
cfg := testcfg.Build(t)
testcfg.BuildGitalyHooks(t, cfg)
refTransactionServer := &testTransactionServer{}
- addr := testserver.RunGitalyServer(t, cfg, nil, func(srv *grpc.Server, deps *service.Dependencies) {
- gitalypb.RegisterSmartHTTPServiceServer(srv, NewServer(
- deps.GetLocator(),
- deps.GetGitCmdFactory(),
- deps.GetTxManager(),
- deps.GetDiskCache(),
- ))
- gitalypb.RegisterHookServiceServer(srv, hook.NewServer(deps.GetHookManager(), deps.GetGitCmdFactory(), deps.GetPackObjectsCache(), deps.GetPackObjectsConcurrencyTracker()))
- }, testserver.WithDisablePraefect())
-
- ctx, err := txinfo.InjectTransaction(ctx, 1234, "primary", true)
+ server := startSmartHTTPServerWithOptions(t, cfg, nil, []testserver.GitalyServerOpt{
+ testserver.WithDisablePraefect(),
+ })
+ cfg.SocketPath = server.Address()
+
+ ctx, err := txinfo.InjectTransaction(ctxWithoutTransaction, 1234, "primary", true)
require.NoError(t, err)
ctx = metadata.IncomingToOutgoing(ctx)
- client := newMuxedSmartHTTPClient(t, ctx, addr, cfg.Auth.Token, func() backchannel.Server {
+ client := newMuxedSmartHTTPClient(t, ctx, server.Address(), cfg.Auth.Token, func() backchannel.Server {
srv := grpc.NewServer()
gitalypb.RegisterRefTransactionServer(srv, refTransactionServer)
return srv
@@ -792,9 +785,8 @@ func TestPostReceivePack_referenceTransactionHook(t *testing.T) {
stream, err := client.PostReceivePack(ctx)
require.NoError(t, err)
- repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ repo, _ := gittest.CreateRepository(ctxWithoutTransaction, t, cfg, gittest.CreateRepositoryConfig{
+ Seed: gittest.SeedGitLabTest,
})
_, _, pushRequest := createPushRequest(t, cfg)
@@ -816,10 +808,9 @@ func TestPostReceivePack_referenceTransactionHook(t *testing.T) {
stream, err := client.PostReceivePack(ctx)
require.NoError(t, err)
- repo, repoPath := gittest.CreateRepository(ctx, t, cfg,
+ repo, repoPath := gittest.CreateRepository(ctxWithoutTransaction, t, cfg,
gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ Seed: gittest.SeedGitLabTest,
})
// Create a new branch which we're about to delete. We also pack references because
@@ -871,21 +862,18 @@ func TestPostReceivePack_notAllowed(t *testing.T) {
gitalyhook.NopUpdate,
gitalyhook.NopReferenceTransaction,
)
- addr := testserver.RunGitalyServer(t, cfg, nil, func(srv *grpc.Server, deps *service.Dependencies) {
- gitalypb.RegisterSmartHTTPServiceServer(srv, NewServer(
- deps.GetLocator(),
- deps.GetGitCmdFactory(),
- deps.GetTxManager(),
- deps.GetDiskCache(),
- ))
- gitalypb.RegisterHookServiceServer(srv, hook.NewServer(deps.GetHookManager(), deps.GetGitCmdFactory(), deps.GetPackObjectsCache(), deps.GetPackObjectsConcurrencyTracker()))
- }, testserver.WithDisablePraefect(), testserver.WithHookManager(hookManager))
-
- ctx, err := txinfo.InjectTransaction(testhelper.Context(t), 1234, "primary", true)
+
+ server := startSmartHTTPServerWithOptions(t, cfg, nil, []testserver.GitalyServerOpt{
+ testserver.WithDisablePraefect(), testserver.WithHookManager(hookManager),
+ })
+ cfg.SocketPath = server.Address()
+
+ ctxWithoutTransaction := testhelper.Context(t)
+ ctx, err := txinfo.InjectTransaction(ctxWithoutTransaction, 1234, "primary", true)
require.NoError(t, err)
ctx = metadata.IncomingToOutgoing(ctx)
- client := newMuxedSmartHTTPClient(t, ctx, addr, cfg.Auth.Token, func() backchannel.Server {
+ client := newMuxedSmartHTTPClient(t, ctx, server.Address(), cfg.Auth.Token, func() backchannel.Server {
srv := grpc.NewServer()
gitalypb.RegisterRefTransactionServer(srv, refTransactionServer)
return srv
@@ -894,9 +882,8 @@ func TestPostReceivePack_notAllowed(t *testing.T) {
stream, err := client.PostReceivePack(ctx)
require.NoError(t, err)
- repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ repo, _ := gittest.CreateRepository(ctxWithoutTransaction, t, cfg, gittest.CreateRepositoryConfig{
+ Seed: gittest.SeedGitLabTest,
})
_, _, pushRequest := createPushRequest(t, cfg)
@@ -910,8 +897,7 @@ func createPushRequest(t *testing.T, cfg config.Cfg) (git.ObjectID, git.ObjectID
ctx := testhelper.Context(t)
_, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ Seed: gittest.SeedGitLabTest,
})
oldCommitID := git.ObjectID(text.ChompBytes(gittest.Exec(t, cfg, "-C", repoPath, "rev-parse", "HEAD")))
diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go
index 541dfa112..0f9317696 100644
--- a/internal/gitaly/service/ssh/receive_pack_test.go
+++ b/internal/gitaly/service/ssh/receive_pack_test.go
@@ -734,8 +734,7 @@ func setupSSHClone(t *testing.T, cfg config.Cfg, remoteRepo *gitalypb.Repository
ctx := testhelper.Context(t)
_, localRepoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
+ Seed: gittest.SeedGitLabTest,
})
oldHead := text.ChompBytes(gittest.Exec(t, cfg, "-C", localRepoPath, "rev-parse", "HEAD"))