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>2021-10-20 10:55:32 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-10-26 17:01:42 +0300
commited90d91fa0ae2108b7a3174e1f890fd72749e922 (patch)
tree470174c0018dd6b2c25710db33499685cd0e331a
parent0ca7050be1b342394bce52f6ae63887be7954bf0 (diff)
testhelper: Move build helpers into the testcfg package
Move build helpers from the testhelper into the testcfg package to break the dependency on `internal/gitaly/config`. Note that packages other than the testhelper package have no access to the global temporary test directory, which makes it impossible to create directories shared across tests from other packages. We thus also introduce a new helper function `CreateGlobalDirectory()` which creates a global deterministic directory in the shared temporary directory.
-rw-r--r--cmd/gitaly-backup/restore_test.go2
-rw-r--r--cmd/gitaly-git2go/cherry_pick_test.go4
-rw-r--r--cmd/gitaly-git2go/conflicts/conflicts_test.go2
-rw-r--r--cmd/gitaly-git2go/merge_test.go6
-rw-r--r--cmd/gitaly-git2go/rebase_test.go6
-rw-r--r--cmd/gitaly-git2go/revert_test.go4
-rw-r--r--cmd/gitaly-git2go/submodule_test.go2
-rw-r--r--cmd/gitaly-hooks/hooks_test.go40
-rw-r--r--cmd/gitaly-ssh/auth_test.go4
-rw-r--r--cmd/gitaly-ssh/upload_pack_test.go4
-rw-r--r--internal/backup/backup_test.go6
-rw-r--r--internal/git/localrepo/remote_extra_test.go4
-rw-r--r--internal/git2go/apply_test.go2
-rw-r--r--internal/git2go/commit_test.go2
-rw-r--r--internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go3
-rw-r--r--internal/gitaly/service/conflicts/resolve_conflicts_test.go8
-rw-r--r--internal/gitaly/service/conflicts/testhelper_test.go2
-rw-r--r--internal/gitaly/service/objectpool/fetch_into_object_pool_test.go2
-rw-r--r--internal/gitaly/service/objectpool/testhelper_test.go2
-rw-r--r--internal/gitaly/service/operations/testhelper_test.go6
-rw-r--r--internal/gitaly/service/ref/delete_refs_test.go2
-rw-r--r--internal/gitaly/service/ref/testhelper_test.go2
-rw-r--r--internal/gitaly/service/remote/fetch_internal_remote_test.go6
-rw-r--r--internal/gitaly/service/remote/update_remote_mirror_test.go2
-rw-r--r--internal/gitaly/service/repository/archive_test.go4
-rw-r--r--internal/gitaly/service/repository/fetch_bundle_test.go2
-rw-r--r--internal/gitaly/service/repository/fork_test.go4
-rw-r--r--internal/gitaly/service/repository/replicate_test.go16
-rw-r--r--internal/gitaly/service/repository/testhelper_test.go8
-rw-r--r--internal/gitaly/service/smarthttp/inforefs_test.go2
-rw-r--r--internal/gitaly/service/smarthttp/receive_pack_test.go12
-rw-r--r--internal/gitaly/service/smarthttp/upload_pack_test.go8
-rw-r--r--internal/gitaly/service/ssh/receive_pack_test.go16
-rw-r--r--internal/gitaly/service/ssh/upload_archive_test.go2
-rw-r--r--internal/gitaly/service/ssh/upload_pack_test.go24
-rw-r--r--internal/praefect/replicator_test.go20
-rw-r--r--internal/supervisor/supervisor_test.go3
-rw-r--r--internal/testhelper/testcfg/build.go (renamed from internal/testhelper/build.go)21
-rw-r--r--internal/testhelper/testhelper.go9
-rw-r--r--internal/testhelper/testserver/gitaly.go3
40 files changed, 147 insertions, 130 deletions
diff --git a/cmd/gitaly-backup/restore_test.go b/cmd/gitaly-backup/restore_test.go
index a5a5e33c4..083885e42 100644
--- a/cmd/gitaly-backup/restore_test.go
+++ b/cmd/gitaly-backup/restore_test.go
@@ -21,7 +21,7 @@ import (
func TestRestoreSubcommand(t *testing.T) {
cfg := testcfg.Build(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
gitalyAddr := testserver.RunGitalyServer(t, cfg, nil, setup.RegisterAll)
diff --git a/cmd/gitaly-git2go/cherry_pick_test.go b/cmd/gitaly-git2go/cherry_pick_test.go
index aaeb13355..6889808e8 100644
--- a/cmd/gitaly-git2go/cherry_pick_test.go
+++ b/cmd/gitaly-git2go/cherry_pick_test.go
@@ -21,7 +21,7 @@ import (
func TestCherryPick_validation(t *testing.T) {
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
executor := git2go.NewExecutor(cfg, config.NewLocator(cfg))
testcases := []struct {
@@ -149,7 +149,7 @@ func TestCherryPick(t *testing.T) {
}
for _, tc := range testcases {
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
executor := git2go.NewExecutor(cfg, config.NewLocator(cfg))
base := cmdtesthelper.BuildCommit(t, repoPath, []*git.Oid{nil}, tc.base)
diff --git a/cmd/gitaly-git2go/conflicts/conflicts_test.go b/cmd/gitaly-git2go/conflicts/conflicts_test.go
index 1d2c9dc14..bc35d1a3e 100644
--- a/cmd/gitaly-git2go/conflicts/conflicts_test.go
+++ b/cmd/gitaly-git2go/conflicts/conflicts_test.go
@@ -173,7 +173,7 @@ func TestConflicts(t *testing.T) {
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
executor := git2go.NewExecutor(cfg, config.NewLocator(cfg))
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
base := cmdtesthelper.BuildCommit(t, repoPath, nil, tc.base)
ours := cmdtesthelper.BuildCommit(t, repoPath, []*git.Oid{base}, tc.ours)
diff --git a/cmd/gitaly-git2go/merge_test.go b/cmd/gitaly-git2go/merge_test.go
index c738ad9b6..e7028c880 100644
--- a/cmd/gitaly-git2go/merge_test.go
+++ b/cmd/gitaly-git2go/merge_test.go
@@ -86,7 +86,7 @@ func TestMerge_invalidRepositoryPath(t *testing.T) {
defer cancel()
cfg, repo, _ := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
executor := git2go.NewExecutor(cfg, config.NewLocator(cfg))
_, err := executor.Merge(ctx, repo, git2go.MergeCommand{
@@ -192,7 +192,7 @@ func TestMerge_trees(t *testing.T) {
for _, tc := range testcases {
cfg, repoProto, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
executor := git2go.NewExecutor(cfg, config.NewLocator(cfg))
base := cmdtesthelper.BuildCommit(t, repoPath, []*git.Oid{nil}, tc.base)
@@ -253,7 +253,7 @@ func TestMerge_recursive(t *testing.T) {
defer cancel()
cfg := testcfg.Build(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
executor := git2go.NewExecutor(cfg, config.NewLocator(cfg))
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
diff --git a/cmd/gitaly-git2go/rebase_test.go b/cmd/gitaly-git2go/rebase_test.go
index 8f2f7e011..0098e1302 100644
--- a/cmd/gitaly-git2go/rebase_test.go
+++ b/cmd/gitaly-git2go/rebase_test.go
@@ -24,7 +24,7 @@ var masterRevision = "1e292f8fedd741b75372e19097c76d327140c312"
func TestRebase_validation(t *testing.T) {
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
committer := git2go.NewSignature("Foo", "foo@example.com", time.Now())
executor := git2go.NewExecutor(cfg, config.NewLocator(cfg))
@@ -177,7 +177,7 @@ func TestRebase_rebase(t *testing.T) {
time.Date(2021, 3, 1, 13, 45, 50, 0, time.FixedZone("", +2*60*60)))
cfg, repoProto, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
executor := git2go.NewExecutor(cfg, config.NewLocator(cfg))
repo, err := git2goutil.OpenRepository(repoPath)
@@ -247,7 +247,7 @@ func TestRebase_skipEmptyCommit(t *testing.T) {
defer cancel()
cfg, repoProto, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
// Set up history with two diverging lines of branches, where both sides have implemented
// the same changes. During rebase, the diff will thus become empty.
diff --git a/cmd/gitaly-git2go/revert_test.go b/cmd/gitaly-git2go/revert_test.go
index 498c555be..e59c3fdf5 100644
--- a/cmd/gitaly-git2go/revert_test.go
+++ b/cmd/gitaly-git2go/revert_test.go
@@ -21,7 +21,7 @@ import (
func TestRevert_validation(t *testing.T) {
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
executor := git2go.NewExecutor(cfg, config.NewLocator(cfg))
testcases := []struct {
@@ -173,7 +173,7 @@ func TestRevert_trees(t *testing.T) {
for _, tc := range testcases {
t.Run(tc.desc, func(t *testing.T) {
cfg, repoProto, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
executor := git2go.NewExecutor(cfg, config.NewLocator(cfg))
ours, revert := tc.setupRepo(t, repoPath)
diff --git a/cmd/gitaly-git2go/submodule_test.go b/cmd/gitaly-git2go/submodule_test.go
index 7906e3f95..9adefb0ba 100644
--- a/cmd/gitaly-git2go/submodule_test.go
+++ b/cmd/gitaly-git2go/submodule_test.go
@@ -90,7 +90,7 @@ func TestSubmodule(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
cfg, repoProto, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
repo := localrepo.NewTestRepo(t, cfg, repoProto)
executor := git2go.NewExecutor(cfg, config.NewLocator(cfg))
diff --git a/cmd/gitaly-hooks/hooks_test.go b/cmd/gitaly-hooks/hooks_test.go
index 06ea2e041..3e98d5537 100644
--- a/cmd/gitaly-hooks/hooks_test.go
+++ b/cmd/gitaly-hooks/hooks_test.go
@@ -103,8 +103,8 @@ func TestHooksPrePostWithSymlinkedStoragePath(t *testing.T) {
tempDir := testhelper.TempDir(t)
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
originalStoragePath := cfg.Storages[0].Path
symlinkedStoragePath := filepath.Join(tempDir, "storage")
@@ -116,8 +116,8 @@ func TestHooksPrePostWithSymlinkedStoragePath(t *testing.T) {
func TestHooksPrePostReceive(t *testing.T) {
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
testHooksPrePostReceive(t, cfg, repo, repoPath)
}
@@ -252,8 +252,8 @@ func TestHooksUpdate(t *testing.T) {
Auth: auth.Config{Token: "abc123"},
Hooks: config.Hooks{CustomHooksDir: customHooksDir},
}))
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
require.NoError(t, os.Symlink(filepath.Join(cfg.GitlabShell.Dir, "config.yml"), filepath.Join(cfg.GitlabShell.Dir, "config.yml")))
@@ -326,8 +326,8 @@ func TestHooksPostReceiveFailed(t *testing.T) {
logger, _ := test.NewNullLogger()
cfg, repo, repoPath := testcfg.BuildWithRepo(t, testcfg.WithBase(config.Cfg{Auth: auth.Config{Token: "abc123"}}))
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
// By setting the last parameter to false, the post-receive API call will
// send back {"reference_counter_increased": false}, indicating something went wrong
@@ -438,8 +438,8 @@ func TestHooksNotAllowed(t *testing.T) {
logger, _ := test.NewNullLogger()
cfg, repo, repoPath := testcfg.BuildWithRepo(t, testcfg.WithBase(config.Cfg{Auth: auth.Config{Token: "abc123"}}))
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
c := gitlab.TestServerOptions{
User: "",
@@ -512,8 +512,8 @@ func TestCheckOK(t *testing.T) {
defer cleanup()
cfg := testcfg.Build(t)
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
cmd := exec.Command(filepath.Join(cfg.BinDir, "gitaly-hooks"), "check", configPath)
@@ -556,8 +556,8 @@ func TestCheckBadCreds(t *testing.T) {
defer cleanup()
cfg := testcfg.Build(t)
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
cmd := exec.Command(filepath.Join(cfg.BinDir, "gitaly-hooks"), "check", configPath)
@@ -639,8 +639,8 @@ func TestGitalyHooksPackObjects(t *testing.T) {
logger, hook := test.NewNullLogger()
runHookServiceServer(t, cfg, testserver.WithLogger(logger))
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
baseArgs := []string{
cfg.Git.BinPath,
@@ -688,8 +688,8 @@ func TestRequestedHooks(t *testing.T) {
t.Run(hookName, func(t *testing.T) {
t.Run("unrequested hook is ignored", func(t *testing.T) {
cfg := testcfg.Build(t)
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
payload, err := git.NewHooksPayload(cfg, &gitalypb.Repository{}, nil, nil, git.AllHooks&^hook, nil).Env()
require.NoError(t, err)
@@ -701,8 +701,8 @@ func TestRequestedHooks(t *testing.T) {
t.Run("requested hook runs", func(t *testing.T) {
cfg := testcfg.Build(t)
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
payload, err := git.NewHooksPayload(cfg, &gitalypb.Repository{}, nil, nil, hook, nil).Env()
require.NoError(t, err)
diff --git a/cmd/gitaly-ssh/auth_test.go b/cmd/gitaly-ssh/auth_test.go
index 53926aa7e..310b090d3 100644
--- a/cmd/gitaly-ssh/auth_test.go
+++ b/cmd/gitaly-ssh/auth_test.go
@@ -33,8 +33,8 @@ import (
func TestConnectivity(t *testing.T) {
cfg, repo, _ := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalySSH(t, cfg)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
cwd, err := os.Getwd()
require.NoError(t, err)
diff --git a/cmd/gitaly-ssh/upload_pack_test.go b/cmd/gitaly-ssh/upload_pack_test.go
index f5191285e..504f5c2e9 100644
--- a/cmd/gitaly-ssh/upload_pack_test.go
+++ b/cmd/gitaly-ssh/upload_pack_test.go
@@ -25,8 +25,8 @@ func TestVisibilityOfHiddenRefs(t *testing.T) {
defer cancel()
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalySSH(t, cfg)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
socketPath := testhelper.GetTemporaryGitalySocketFileName(t)
diff --git a/internal/backup/backup_test.go b/internal/backup/backup_test.go
index c47951402..dbef8de9b 100644
--- a/internal/backup/backup_test.go
+++ b/internal/backup/backup_test.go
@@ -261,7 +261,7 @@ func TestManager_Create_incremental(t *testing.T) {
func TestManager_Restore(t *testing.T) {
cfg := testcfg.Build(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
gitalyAddr := testserver.RunGitalyServer(t, cfg, nil, setup.RegisterAll)
@@ -271,8 +271,8 @@ func TestManager_Restore(t *testing.T) {
func TestManager_Restore_praefect(t *testing.T) {
gitalyCfg := testcfg.Build(t, testcfg.WithStorages("gitaly-1"))
- testhelper.BuildPraefect(t, gitalyCfg)
- testhelper.BuildGitalyHooks(t, gitalyCfg)
+ testcfg.BuildPraefect(t, gitalyCfg)
+ testcfg.BuildGitalyHooks(t, gitalyCfg)
gitalyAddr := testserver.RunGitalyServer(t, gitalyCfg, nil, setup.RegisterAll, testserver.WithDisablePraefect())
diff --git a/internal/git/localrepo/remote_extra_test.go b/internal/git/localrepo/remote_extra_test.go
index 6e9e523a2..2cfa720a0 100644
--- a/internal/git/localrepo/remote_extra_test.go
+++ b/internal/git/localrepo/remote_extra_test.go
@@ -42,8 +42,8 @@ func TestRepo_FetchInternal(t *testing.T) {
})
remoteRepo := localrepo.NewTestRepo(t, cfg, remoteRepoProto)
- testhelper.BuildGitalySSH(t, cfg)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
remoteOID, err := remoteRepo.ResolveRevision(ctx, git.Revision("refs/heads/master"))
require.NoError(t, err)
diff --git a/internal/git2go/apply_test.go b/internal/git2go/apply_test.go
index c455a4a88..0d99cdd04 100644
--- a/internal/git2go/apply_test.go
+++ b/internal/git2go/apply_test.go
@@ -17,7 +17,7 @@ import (
func TestExecutor_Apply(t *testing.T) {
cfg := testcfg.Build(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
diff --git a/internal/git2go/commit_test.go b/internal/git2go/commit_test.go
index 0f45235e2..2e45ea4a4 100644
--- a/internal/git2go/commit_test.go
+++ b/internal/git2go/commit_test.go
@@ -46,7 +46,7 @@ func TestExecutor_Commit(t *testing.T) {
defer cancel()
cfg := testcfg.Build(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
diff --git a/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go b/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go
index dfb4e5ca7..05592cd3b 100644
--- a/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go
+++ b/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go
@@ -13,6 +13,7 @@ import (
"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/testhelper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"google.golang.org/grpc/codes"
)
@@ -20,7 +21,7 @@ import (
func TestApplyBfgObjectMapStreamSuccess(t *testing.T) {
cfg, protoRepo, repoPath, client := setupCleanupService(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
repo := localrepo.NewTestRepo(t, cfg, protoRepo)
diff --git a/internal/gitaly/service/conflicts/resolve_conflicts_test.go b/internal/gitaly/service/conflicts/resolve_conflicts_test.go
index 3b15de756..bc752eed4 100644
--- a/internal/gitaly/service/conflicts/resolve_conflicts_test.go
+++ b/internal/gitaly/service/conflicts/resolve_conflicts_test.go
@@ -199,8 +199,8 @@ func TestResolveConflictsWithRemoteRepo(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- testhelper.BuildGitalySSH(t, cfg)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
sourceRepo, sourceRepoPath := gittest.CloneRepo(t, cfg, cfg.Storages[0])
sourceBlobOID := gittest.WriteBlob(t, cfg, sourceRepoPath, []byte("contents-1\n"))
@@ -819,8 +819,8 @@ func TestResolveConflictsQuarantine(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- testhelper.BuildGitalySSH(t, cfg)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
sourceRepoProto, sourceRepoPath := gittest.CloneRepo(t, cfg, cfg.Storages[0])
sourceBlobOID := gittest.WriteBlob(t, cfg, sourceRepoPath, []byte("contents-1\n"))
diff --git a/internal/gitaly/service/conflicts/testhelper_test.go b/internal/gitaly/service/conflicts/testhelper_test.go
index 31792b01c..dac125855 100644
--- a/internal/gitaly/service/conflicts/testhelper_test.go
+++ b/internal/gitaly/service/conflicts/testhelper_test.go
@@ -29,7 +29,7 @@ func TestMain(m *testing.M) {
func SetupConfigAndRepo(t testing.TB, bare bool) (config.Cfg, *gitalypb.Repository, string) {
cfg := testcfg.Build(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
repo, repoPath := gittest.CloneRepo(t, cfg, cfg.Storages[0], gittest.CloneRepoOpts{
WithWorktree: !bare,
diff --git a/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go b/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go
index ba48dd00c..185b1173d 100644
--- a/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go
+++ b/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go
@@ -114,7 +114,7 @@ func TestFetchIntoObjectPool_hooks(t *testing.T) {
func TestFetchIntoObjectPool_CollectLogStatistics(t *testing.T) {
cfg, repo, _ := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
locator := config.NewLocator(cfg)
logBuffer := &bytes.Buffer{}
diff --git a/internal/gitaly/service/objectpool/testhelper_test.go b/internal/gitaly/service/objectpool/testhelper_test.go
index 86b85adcc..da3939ac5 100644
--- a/internal/gitaly/service/objectpool/testhelper_test.go
+++ b/internal/gitaly/service/objectpool/testhelper_test.go
@@ -33,7 +33,7 @@ func setup(t *testing.T, opts ...testserver.GitalyServerOpt) (config.Cfg, *gital
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
locator := config.NewLocator(cfg)
addr := runObjectPoolServer(t, cfg, locator, testhelper.DiscardTestLogger(t), opts...)
diff --git a/internal/gitaly/service/operations/testhelper_test.go b/internal/gitaly/service/operations/testhelper_test.go
index dc6613c19..4972b397a 100644
--- a/internal/gitaly/service/operations/testhelper_test.go
+++ b/internal/gitaly/service/operations/testhelper_test.go
@@ -46,9 +46,9 @@ func setupOperationsServiceWithCfg(
) (context.Context, config.Cfg, *gitalypb.Repository, string, gitalypb.OperationServiceClient) {
repo, repoPath := gittest.CloneRepo(t, cfg, cfg.Storages[0])
- testhelper.BuildGitalySSH(t, cfg)
- testhelper.BuildGitalyGit2Go(t, cfg)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
serverSocketPath := runOperationServiceServer(t, cfg, options...)
cfg.SocketPath = serverSocketPath
diff --git a/internal/gitaly/service/ref/delete_refs_test.go b/internal/gitaly/service/ref/delete_refs_test.go
index bbda1d6de..ec6864dc4 100644
--- a/internal/gitaly/service/ref/delete_refs_test.go
+++ b/internal/gitaly/service/ref/delete_refs_test.go
@@ -80,7 +80,7 @@ func TestSuccessfulDeleteRefs(t *testing.T) {
func TestDeleteRefs_transaction(t *testing.T) {
cfg := testcfg.Build(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
var votes int
txManager := &transaction.MockManager{
diff --git a/internal/gitaly/service/ref/testhelper_test.go b/internal/gitaly/service/ref/testhelper_test.go
index e933ecd7c..d6f21297a 100644
--- a/internal/gitaly/service/ref/testhelper_test.go
+++ b/internal/gitaly/service/ref/testhelper_test.go
@@ -42,7 +42,7 @@ func setupRefService(t testing.TB) (config.Cfg, *gitalypb.Repository, string, gi
func setupRefServiceWithoutRepo(t testing.TB) (config.Cfg, gitalypb.RefServiceClient) {
cfg := testcfg.Build(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
serverSocketPath := runRefServiceServer(t, cfg)
cfg.SocketPath = serverSocketPath
diff --git a/internal/gitaly/service/remote/fetch_internal_remote_test.go b/internal/gitaly/service/remote/fetch_internal_remote_test.go
index 96cb88ca2..00a4afda7 100644
--- a/internal/gitaly/service/remote/fetch_internal_remote_test.go
+++ b/internal/gitaly/service/remote/fetch_internal_remote_test.go
@@ -78,7 +78,7 @@ func TestFetchInternalRemote_successful(t *testing.T) {
t.Cleanup(cancel)
remoteCfg, remoteRepo, remoteRepoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyHooks(t, remoteCfg)
+ testcfg.BuildGitalyHooks(t, remoteCfg)
gittest.WriteCommit(t, remoteCfg, remoteRepoPath, gittest.WithBranch("master"))
remoteAddr := testserver.RunGitalyServer(t, remoteCfg, nil, func(srv *grpc.Server, deps *service.Dependencies) {
@@ -99,8 +99,8 @@ func TestFetchInternalRemote_successful(t *testing.T) {
localCfg, localRepoProto, localRepoPath := testcfg.BuildWithRepo(t)
localRepo := localrepo.NewTestRepo(t, localCfg, localRepoProto)
- testhelper.BuildGitalySSH(t, localCfg)
- testhelper.BuildGitalyHooks(t, localCfg)
+ testcfg.BuildGitalySSH(t, localCfg)
+ testcfg.BuildGitalyHooks(t, localCfg)
gittest.Exec(t, remoteCfg, "-C", localRepoPath, "symbolic-ref", "HEAD", "refs/heads/feature")
referenceTransactionHookCalled := 0
diff --git a/internal/gitaly/service/remote/update_remote_mirror_test.go b/internal/gitaly/service/remote/update_remote_mirror_test.go
index 5b726cf55..4ea75ec83 100644
--- a/internal/gitaly/service/remote/update_remote_mirror_test.go
+++ b/internal/gitaly/service/remote/update_remote_mirror_test.go
@@ -498,7 +498,7 @@ func TestUpdateRemoteMirror(t *testing.T) {
cfg := testcfg.Build(t)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
mirrorRepoPb, mirrorRepoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
diff --git a/internal/gitaly/service/repository/archive_test.go b/internal/gitaly/service/repository/archive_test.go
index c2ab3095c..b80e16992 100644
--- a/internal/gitaly/service/repository/archive_test.go
+++ b/internal/gitaly/service/repository/archive_test.go
@@ -193,7 +193,7 @@ func TestGetArchiveWithLfsSuccess(t *testing.T) {
repo, _ := gittest.CloneRepo(t, cfg, cfg.Storages[0])
- testhelper.BuildGitalyLFSSmudge(t, cfg)
+ testcfg.BuildGitalyLFSSmudge(t, cfg)
// lfs-moar branch SHA
sha := "46abbb087fcc0fd02c340f0f2f052bd2c7708da3"
@@ -489,7 +489,7 @@ env | grep -E "^GL_|CORRELATION|GITALY_"`))
cfg := testcfg.Build(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
// We re-define path to the git executable to catch parameters used to call it.
// This replacement only needs to be done for the configuration used to invoke git commands.
diff --git a/internal/gitaly/service/repository/fetch_bundle_test.go b/internal/gitaly/service/repository/fetch_bundle_test.go
index 25b2d9961..c9e225577 100644
--- a/internal/gitaly/service/repository/fetch_bundle_test.go
+++ b/internal/gitaly/service/repository/fetch_bundle_test.go
@@ -72,7 +72,7 @@ func TestServer_FetchBundle_success(t *testing.T) {
func TestServer_FetchBundle_transaction(t *testing.T) {
t.Parallel()
cfg, repoProto, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
hookManager := &mockHookManager{}
addr := testserver.RunGitalyServer(t, cfg, nil, func(srv *grpc.Server, deps *service.Dependencies) {
diff --git a/internal/gitaly/service/repository/fork_test.go b/internal/gitaly/service/repository/fork_test.go
index c1ffae9ad..284325b44 100644
--- a/internal/gitaly/service/repository/fork_test.go
+++ b/internal/gitaly/service/repository/fork_test.go
@@ -62,8 +62,8 @@ func TestSuccessfulCreateForkRequest(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
cfg, repo, _ := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
var (
client gitalypb.RepositoryServiceClient
diff --git a/internal/gitaly/service/repository/replicate_test.go b/internal/gitaly/service/repository/replicate_test.go
index f8fa705b8..739006b22 100644
--- a/internal/gitaly/service/repository/replicate_test.go
+++ b/internal/gitaly/service/repository/replicate_test.go
@@ -30,8 +30,8 @@ func TestReplicateRepository(t *testing.T) {
cfgBuilder := testcfg.NewGitalyCfgBuilder(testcfg.WithStorages("default", "replica"))
cfg := cfgBuilder.Build(t)
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
serverSocketPath := runRepositoryServerWithConfig(t, cfg, nil, testserver.WithDisablePraefect())
cfg.SocketPath = serverSocketPath
@@ -104,8 +104,8 @@ func TestReplicateRepositoryTransactional(t *testing.T) {
cfgBuilder := testcfg.NewGitalyCfgBuilder(testcfg.WithStorages("default", "replica"))
cfg := cfgBuilder.Build(t)
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
serverSocketPath := runRepositoryServerWithConfig(t, cfg, nil, testserver.WithDisablePraefect())
cfg.SocketPath = serverSocketPath
@@ -281,8 +281,8 @@ func TestReplicateRepository_BadRepository(t *testing.T) {
cfgBuilder := testcfg.NewGitalyCfgBuilder(testcfg.WithStorages("default", "target"))
cfg := cfgBuilder.Build(t)
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
serverSocketPath := runRepositoryServerWithConfig(t, cfg, nil, testserver.WithDisablePraefect())
cfg.SocketPath = serverSocketPath
@@ -336,8 +336,8 @@ func TestReplicateRepository_FailedFetchInternalRemote(t *testing.T) {
t.Parallel()
cfg := testcfg.Build(t, testcfg.WithStorages("default", "replica"))
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
// Our test setup does not allow for Praefects with multiple storages. We thus have to
// disable Praefect here.
diff --git a/internal/gitaly/service/repository/testhelper_test.go b/internal/gitaly/service/repository/testhelper_test.go
index bfcf64e8c..75fa40b00 100644
--- a/internal/gitaly/service/repository/testhelper_test.go
+++ b/internal/gitaly/service/repository/testhelper_test.go
@@ -49,8 +49,8 @@ func TestWithRubySidecar(t *testing.T) {
client, serverSocketPath := runRepositoryService(t, cfg, rubySrv)
cfg.SocketPath = serverSocketPath
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalyGit2Go(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyGit2Go(t, cfg)
fs := []func(t *testing.T, cfg config.Cfg, client gitalypb.RepositoryServiceClient, rubySrv *rubyserver.Server){
testSuccessfulFindLicenseRequest,
@@ -159,8 +159,8 @@ func setupRepositoryService(t testing.TB, opts ...testserver.GitalyServerOpt) (c
func setupRepositoryServiceWithoutRepo(t testing.TB, opts ...testserver.GitalyServerOpt) (config.Cfg, gitalypb.RepositoryServiceClient) {
cfg := testcfg.Build(t)
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
client, serverSocketPath := runRepositoryService(t, cfg, nil, opts...)
cfg.SocketPath = serverSocketPath
diff --git a/internal/gitaly/service/smarthttp/inforefs_test.go b/internal/gitaly/service/smarthttp/inforefs_test.go
index 58f3ff36c..1ed332eff 100644
--- a/internal/gitaly/service/smarthttp/inforefs_test.go
+++ b/internal/gitaly/service/smarthttp/inforefs_test.go
@@ -181,7 +181,7 @@ func TestSuccessfulInfoRefsReceivePack(t *testing.T) {
func TestObjectPoolRefAdvertisementHiding(t *testing.T) {
cfg, repo, _ := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
serverSocketPath := runSmartHTTPServer(t, cfg)
diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go
index d84eee94f..5fc0b65ea 100644
--- a/internal/gitaly/service/smarthttp/receive_pack_test.go
+++ b/internal/gitaly/service/smarthttp/receive_pack_test.go
@@ -104,7 +104,7 @@ func TestReceivePackHiddenRefs(t *testing.T) {
cfg, repoProto, repoPath := testcfg.BuildWithRepo(t)
repoProto.GlProjectPath = "project/path"
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
ctx, cancel := testhelper.Context()
defer cancel()
@@ -152,7 +152,7 @@ func TestReceivePackHiddenRefs(t *testing.T) {
func TestSuccessfulReceivePackRequestWithGitProtocol(t *testing.T) {
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
readProto, cfg := gittest.EnableGitProtocolV2Support(t, cfg)
@@ -442,7 +442,7 @@ func TestPostReceivePack_invalidObjects(t *testing.T) {
func TestReceivePackFsck(t *testing.T) {
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
head := text.ChompBytes(gittest.Exec(t, cfg, "-C", repoPath, "rev-parse", "HEAD"))
@@ -493,7 +493,7 @@ func drainPostReceivePackResponse(stream gitalypb.SmartHTTPService_PostReceivePa
func TestPostReceivePackToHooks(t *testing.T) {
cfg, repo, _ := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
const (
secretToken = "secret token"
@@ -557,7 +557,7 @@ func TestPostReceiveWithTransactionsViaPraefect(t *testing.T) {
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
secretToken := "secret token"
glID := "key-1234"
@@ -617,7 +617,7 @@ func (t *testTransactionServer) VoteTransaction(ctx context.Context, in *gitalyp
func TestPostReceiveWithReferenceTransactionHook(t *testing.T) {
cfg := testcfg.Build(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
refTransactionServer := &testTransactionServer{}
diff --git a/internal/gitaly/service/smarthttp/upload_pack_test.go b/internal/gitaly/service/smarthttp/upload_pack_test.go
index bf2920756..a51549a2a 100644
--- a/internal/gitaly/service/smarthttp/upload_pack_test.go
+++ b/internal/gitaly/service/smarthttp/upload_pack_test.go
@@ -65,7 +65,7 @@ func testServerPostUpload(t *testing.T, ctx context.Context, makeRequest request
cfg, repo, repoPath := testcfg.BuildWithRepo(t, opts...)
_, localRepoPath := gittest.CloneRepo(t, cfg, cfg.Storages[0])
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
negotiationMetrics := prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"feature"})
serverSocketPath := runSmartHTTPServer(t, cfg, WithPackfileNegotiationMetrics(negotiationMetrics))
@@ -107,7 +107,7 @@ func TestServer_PostUploadPackSidechannel_gitConfigOptions(t *testing.T) {
func testServerPostUploadPackGitConfigOptions(t *testing.T, ctx context.Context, makeRequest requestMaker, opts ...testcfg.Option) {
cfg, repo, repoPath := testcfg.BuildWithRepo(t, opts...)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
serverSocketPath := runSmartHTTPServer(t, cfg)
@@ -356,7 +356,7 @@ func testServerPostUploadPackPartialClone(t *testing.T, ctx context.Context, mak
cfg, repo, repoPath := testcfg.BuildWithRepo(t, opts...)
_, localRepoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
negotiationMetrics := prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"feature"})
serverSocketPath := runSmartHTTPServer(t, cfg, WithPackfileNegotiationMetrics(negotiationMetrics))
@@ -413,7 +413,7 @@ func testServerPostUploadPackAllowAnySHA1InWant(t *testing.T, ctx context.Contex
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
_, localRepoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
serverSocketPath := runSmartHTTPServer(t, cfg)
newCommit := gittest.WriteCommit(t, cfg, repoPath)
diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go
index db17db5d0..7a024cffb 100644
--- a/internal/gitaly/service/ssh/receive_pack_test.go
+++ b/internal/gitaly/service/ssh/receive_pack_test.go
@@ -94,7 +94,7 @@ func TestReceivePackPushSuccess(t *testing.T) {
cfg.GitlabShell.Dir = "/foo/bar/gitlab-shell"
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
hookOutputFile, cleanup := gittest.CaptureHookEnv(t)
defer cleanup()
@@ -167,8 +167,8 @@ func TestReceivePackPushSuccess(t *testing.T) {
func TestReceivePackPushSuccessWithGitProtocol(t *testing.T) {
cfg, repo, _ := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalySSH(t, cfg)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
readProto, cfg := gittest.EnableGitProtocolV2Support(t, cfg)
@@ -203,7 +203,7 @@ func TestReceivePackPushFailure(t *testing.T) {
func TestReceivePackPushHookFailure(t *testing.T) {
cfg, repo, _ := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
serverSocketPath := runSSHServer(t, cfg)
@@ -225,7 +225,7 @@ func TestReceivePackPushHookFailure(t *testing.T) {
func TestObjectPoolRefAdvertisementHidingSSH(t *testing.T) {
cfg, repo, _ := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
serverSocketPath := runSSHServer(t, cfg)
@@ -281,7 +281,7 @@ func TestReceivePackTransactional(t *testing.T) {
cfg, repoProto, repoPath := testcfg.BuildWithRepo(t)
repo := localrepo.NewTestRepo(t, cfg, repoProto)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
var votes int
serverSocketPath := runSSHServer(t, cfg, testserver.WithTransactionManager(
@@ -489,8 +489,8 @@ func TestReceivePackTransactional(t *testing.T) {
func TestSSHReceivePackToHooks(t *testing.T) {
cfg, repo, _ := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
const (
secretToken = "secret token"
diff --git a/internal/gitaly/service/ssh/upload_archive_test.go b/internal/gitaly/service/ssh/upload_archive_test.go
index efcaeb434..bdb4cbae4 100644
--- a/internal/gitaly/service/ssh/upload_archive_test.go
+++ b/internal/gitaly/service/ssh/upload_archive_test.go
@@ -105,7 +105,7 @@ func TestFailedUploadArchiveRequestDueToValidationError(t *testing.T) {
func TestUploadArchiveSuccess(t *testing.T) {
cfg, repo, _ := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
serverSocketPath := runSSHServer(t, cfg)
diff --git a/internal/gitaly/service/ssh/upload_pack_test.go b/internal/gitaly/service/ssh/upload_pack_test.go
index 019cddb8c..eb46f0567 100644
--- a/internal/gitaly/service/ssh/upload_pack_test.go
+++ b/internal/gitaly/service/ssh/upload_pack_test.go
@@ -215,8 +215,8 @@ func TestUploadPackCloneSuccess(t *testing.T) {
func testUploadPackCloneSuccess(t *testing.T, opts ...testcfg.Option) {
cfg, repo, repoPath := testcfg.BuildWithRepo(t, opts...)
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
negotiationMetrics := prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"feature"})
@@ -268,8 +268,8 @@ func TestUploadPackWithPackObjectsHook(t *testing.T) {
outputPath := filepath.Join(filterDir, "output")
cfg.BinDir = filterDir
- testhelper.BuildGitalyHooks(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
hookScript := fmt.Sprintf(
`#!/bin/sh
@@ -308,8 +308,8 @@ func TestUploadPackWithoutSideband(t *testing.T) {
func testUploadPackWithoutSideband(t *testing.T, opts ...testcfg.Option) {
cfg, repo, _ := testcfg.BuildWithRepo(t, opts...)
- testhelper.BuildGitalySSH(t, cfg)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
serverSocketPath := runSSHServer(t, cfg)
@@ -355,8 +355,8 @@ func TestUploadPackCloneWithPartialCloneFilter(t *testing.T) {
func testUploadPackCloneWithPartialCloneFilter(t *testing.T, opts ...testcfg.Option) {
cfg, repo, _ := testcfg.BuildWithRepo(t, opts...)
- testhelper.BuildGitalySSH(t, cfg)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
serverSocketPath := runSSHServer(t, cfg)
@@ -420,8 +420,8 @@ func testUploadPackCloneSuccessWithGitProtocol(t *testing.T, opts ...testcfg.Opt
serverSocketPath := runSSHServer(t, cfg)
- testhelper.BuildGitalySSH(t, cfg)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
localRepoPath := testhelper.TempDir(t)
@@ -461,8 +461,8 @@ func testUploadPackCloneSuccessWithGitProtocol(t *testing.T, opts ...testcfg.Opt
func TestUploadPackCloneHideTags(t *testing.T) {
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- testhelper.BuildGitalySSH(t, cfg)
- testhelper.BuildGitalyHooks(t, cfg)
+ testcfg.BuildGitalySSH(t, cfg)
+ testcfg.BuildGitalyHooks(t, cfg)
serverSocketPath := runSSHServer(t, cfg)
diff --git a/internal/praefect/replicator_test.go b/internal/praefect/replicator_test.go
index bb31f2ac8..62f5524e0 100644
--- a/internal/praefect/replicator_test.go
+++ b/internal/praefect/replicator_test.go
@@ -52,13 +52,13 @@ func TestReplMgr_ProcessBacklog(t *testing.T) {
t.Parallel()
primaryCfg, testRepo, testRepoPath := testcfg.BuildWithRepo(t, testcfg.WithStorages("primary"))
primaryCfg.SocketPath = testserver.RunGitalyServer(t, primaryCfg, nil, setup.RegisterAll, testserver.WithDisablePraefect())
- testhelper.BuildGitalySSH(t, primaryCfg)
- testhelper.BuildGitalyHooks(t, primaryCfg)
+ testcfg.BuildGitalySSH(t, primaryCfg)
+ testcfg.BuildGitalyHooks(t, primaryCfg)
backupCfg, _, _ := testcfg.BuildWithRepo(t, testcfg.WithStorages("backup"))
backupCfg.SocketPath = testserver.RunGitalyServer(t, backupCfg, nil, setup.RegisterAll, testserver.WithDisablePraefect())
- testhelper.BuildGitalySSH(t, backupCfg)
- testhelper.BuildGitalyHooks(t, backupCfg)
+ testcfg.BuildGitalySSH(t, backupCfg)
+ testcfg.BuildGitalyHooks(t, backupCfg)
conf := config.Config{
VirtualStorages: []*config.VirtualStorage{{
@@ -650,8 +650,8 @@ func TestProcessBacklog_FailedJobs(t *testing.T) {
backupCfg, _, _ := testcfg.BuildWithRepo(t, testcfg.WithStorages("backup"))
backupAddr := testserver.RunGitalyServer(t, backupCfg, nil, setup.RegisterAll, testserver.WithDisablePraefect())
- testhelper.BuildGitalySSH(t, backupCfg)
- testhelper.BuildGitalyHooks(t, backupCfg)
+ testcfg.BuildGitalySSH(t, backupCfg)
+ testcfg.BuildGitalyHooks(t, backupCfg)
primary := config.Node{
Storage: primaryCfg.Storages[0].Name,
@@ -746,13 +746,13 @@ func TestProcessBacklog_Success(t *testing.T) {
t.Parallel()
primaryCfg, testRepo, _ := testcfg.BuildWithRepo(t, testcfg.WithStorages("primary"))
primaryCfg.SocketPath = testserver.RunGitalyServer(t, primaryCfg, nil, setup.RegisterAll, testserver.WithDisablePraefect())
- testhelper.BuildGitalySSH(t, primaryCfg)
- testhelper.BuildGitalyHooks(t, primaryCfg)
+ testcfg.BuildGitalySSH(t, primaryCfg)
+ testcfg.BuildGitalyHooks(t, primaryCfg)
backupCfg, _, _ := testcfg.BuildWithRepo(t, testcfg.WithStorages("backup"))
backupCfg.SocketPath = testserver.RunGitalyServer(t, backupCfg, nil, setup.RegisterAll, testserver.WithDisablePraefect())
- testhelper.BuildGitalySSH(t, backupCfg)
- testhelper.BuildGitalyHooks(t, backupCfg)
+ testcfg.BuildGitalySSH(t, backupCfg)
+ testcfg.BuildGitalyHooks(t, backupCfg)
primary := config.Node{
Storage: primaryCfg.Storages[0].Name,
diff --git a/internal/supervisor/supervisor_test.go b/internal/supervisor/supervisor_test.go
index b7992b4cb..c8012024a 100644
--- a/internal/supervisor/supervisor_test.go
+++ b/internal/supervisor/supervisor_test.go
@@ -14,6 +14,7 @@ import (
"github.com/kelseyhightower/envconfig"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
)
func TestMain(m *testing.M) {
@@ -238,5 +239,5 @@ func buildPidServer(t *testing.T) string {
sourcePath, err := filepath.Abs("test-scripts/pid-server.go")
require.NoError(t, err)
- return testhelper.BuildBinary(t, testhelper.TempDir(t), sourcePath)
+ return testcfg.BuildBinary(t, testhelper.TempDir(t), sourcePath)
}
diff --git a/internal/testhelper/build.go b/internal/testhelper/testcfg/build.go
index 873e3a91f..b56197d73 100644
--- a/internal/testhelper/build.go
+++ b/internal/testhelper/testcfg/build.go
@@ -1,4 +1,4 @@
-package testhelper
+package testcfg
import (
"errors"
@@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/version"
)
@@ -49,18 +50,23 @@ func BuildPraefect(t testing.TB, cfg config.Cfg) {
BuildBinary(t, cfg.BinDir, gitalyCommandPath("praefect"))
}
+var (
+ sharedBinariesDir string
+ createGlobalBinaryDirectoryOnce sync.Once
+)
+
// BuildBinary builds a Go binary once and copies it into the target directory. The source path can
// either be a ".go" file or a directory containing Go files. Returns the path to the executable in
// the destination directory.
func BuildBinary(t testing.TB, targetDir, sourcePath string) string {
- require.NotEmpty(t, testDirectory, "you must call testhelper.Configure() first")
+ createGlobalBinaryDirectoryOnce.Do(func() {
+ sharedBinariesDir = testhelper.CreateGlobalDirectory(t, "bins")
+ })
+ require.NotEmpty(t, sharedBinariesDir, "creation of shared binary directory failed")
var (
// executableName is the name of the executable.
executableName = filepath.Base(sourcePath)
- // sharedBinariesDir is where all binaries will be compiled into. This directory is
- // shared between all tests.
- sharedBinariesDir = filepath.Join(testDirectory, "bins")
// sharedBinaryPath is the path to the binary shared between all tests.
sharedBinaryPath = filepath.Join(sharedBinariesDir, executableName)
// targetPath is the final path where the binary should be copied to.
@@ -72,10 +78,9 @@ func BuildBinary(t testing.TB, targetDir, sourcePath string) string {
require.True(t, ok)
buildOnce.Do(func() {
- require.NoError(t, os.MkdirAll(sharedBinariesDir, os.ModePerm))
require.NoFileExists(t, sharedBinaryPath, "binary has already been built")
- MustRunCommand(t, nil,
+ testhelper.MustRunCommand(t, nil,
"go",
"build",
"-tags", "static,system_libgit2",
@@ -88,7 +93,7 @@ func BuildBinary(t testing.TB, targetDir, sourcePath string) string {
require.NoFileExists(t, targetPath, "%s exists already -- do you try to build it twice?", executableName)
require.NoError(t, os.MkdirAll(targetDir, os.ModePerm))
- CopyFile(t, sharedBinaryPath, targetPath)
+ testhelper.CopyFile(t, sharedBinaryPath, targetPath)
require.NoError(t, os.Chmod(targetPath, 0o755))
return targetPath
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index 1a18ac2e9..da0b5a308 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -167,6 +167,15 @@ func Context(opts ...ContextOpt) (context.Context, func()) {
}
}
+// CreateGlobalDirectory creates a directory in the test directory that is shared across all
+// between all tests.
+func CreateGlobalDirectory(t testing.TB, name string) string {
+ require.NotEmpty(t, testDirectory, "global temporary directory does not exist")
+ path := filepath.Join(testDirectory, name)
+ require.NoError(t, os.Mkdir(path, 0o777))
+ return path
+}
+
// TempDir is a wrapper around os.MkdirTemp that provides a cleanup function.
func TempDir(t testing.TB) string {
if testDirectory == "" {
diff --git a/internal/testhelper/testserver/gitaly.go b/internal/testhelper/testserver/gitaly.go
index 9bac530bb..af8613f4a 100644
--- a/internal/testhelper/testserver/gitaly.go
+++ b/internal/testhelper/testserver/gitaly.go
@@ -34,6 +34,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/praefect/datastore/glsql"
"gitlab.com/gitlab-org/gitaly/v14/internal/streamcache"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
"google.golang.org/grpc"
"google.golang.org/grpc/health"
healthpb "google.golang.org/grpc/health/grpc_health_v1"
@@ -70,7 +71,7 @@ func StartGitalyServer(t testing.TB, cfg config.Cfg, rubyServer *rubyserver.Serv
}
}
- testhelper.BuildPraefect(t, cfg)
+ testcfg.BuildPraefect(t, cfg)
praefectAddr, shutdownPraefect := runPraefectProxy(t, cfg, gitalyAddr, filepath.Join(cfg.BinDir, "praefect"))
return GitalyServer{