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-12-15 10:38:05 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-20 12:42:56 +0300
commita7157188643e6111c1c4b5802fe4f6f52b07fadf (patch)
tree88815bde7260f69c72b630b23f6d038ad719aa52
parent48d9f9a6972f512cdbdf4d14da56963b78f4c928 (diff)
smarthttp: Convert to set hooks path via config
The smarthttp package overrides the hooks path by setting the global `config.OverrideHooksPath` variable, which is deprecated and about to be removed. Convert it to instead set up the hooks path via the Gitaly configuration. While at it, parallelize running tests now that we don't depend on global state anymore.
-rw-r--r--internal/gitaly/service/smarthttp/inforefs_test.go20
-rw-r--r--internal/gitaly/service/smarthttp/receive_pack_test.go30
-rw-r--r--internal/gitaly/service/smarthttp/upload_pack_test.go32
3 files changed, 75 insertions, 7 deletions
diff --git a/internal/gitaly/service/smarthttp/inforefs_test.go b/internal/gitaly/service/smarthttp/inforefs_test.go
index 691e916e0..be50d4b5e 100644
--- a/internal/gitaly/service/smarthttp/inforefs_test.go
+++ b/internal/gitaly/service/smarthttp/inforefs_test.go
@@ -31,6 +31,8 @@ import (
)
func TestSuccessfulInfoRefsUploadPack(t *testing.T) {
+ t.Parallel()
+
cfg, repo, _ := testcfg.BuildWithRepo(t)
serverSocketPath := runSmartHTTPServer(t, cfg)
@@ -49,6 +51,8 @@ func TestSuccessfulInfoRefsUploadPack(t *testing.T) {
}
func TestInfoRefsUploadPack_repositoryDoesntExist(t *testing.T) {
+ t.Parallel()
+
cfg := testcfg.Build(t)
serverSocketPath := runSmartHTTPServer(t, cfg)
@@ -66,6 +70,8 @@ func TestInfoRefsUploadPack_repositoryDoesntExist(t *testing.T) {
}
func TestSuccessfulInfoRefsUploadWithPartialClone(t *testing.T) {
+ t.Parallel()
+
cfg, repo, _ := testcfg.BuildWithRepo(t)
serverSocketPath := runSmartHTTPServer(t, cfg)
@@ -89,6 +95,8 @@ func TestSuccessfulInfoRefsUploadWithPartialClone(t *testing.T) {
}
func TestSuccessfulInfoRefsUploadPackWithGitConfigOptions(t *testing.T) {
+ t.Parallel()
+
cfg, repo, _ := testcfg.BuildWithRepo(t)
serverSocketPath := runSmartHTTPServer(t, cfg)
@@ -109,6 +117,8 @@ func TestSuccessfulInfoRefsUploadPackWithGitConfigOptions(t *testing.T) {
}
func TestSuccessfulInfoRefsUploadPackWithGitProtocol(t *testing.T) {
+ t.Parallel()
+
cfg, repo, _ := testcfg.BuildWithRepo(t)
readProtocol, cfg := gittest.EnableGitProtocolV2Support(t, cfg)
@@ -159,6 +169,8 @@ func makeInfoRefsUploadPackRequest(ctx context.Context, t *testing.T, serverSock
}
func TestSuccessfulInfoRefsReceivePack(t *testing.T) {
+ t.Parallel()
+
cfg, repo, _ := testcfg.BuildWithRepo(t)
serverSocketPath := runSmartHTTPServer(t, cfg)
@@ -178,6 +190,8 @@ func TestSuccessfulInfoRefsReceivePack(t *testing.T) {
}
func TestObjectPoolRefAdvertisementHiding(t *testing.T) {
+ t.Parallel()
+
cfg, repo, _ := testcfg.BuildWithRepo(t)
testcfg.BuildGitalyHooks(t, cfg)
@@ -215,6 +229,8 @@ func TestObjectPoolRefAdvertisementHiding(t *testing.T) {
}
func TestFailureRepoNotFoundInfoRefsReceivePack(t *testing.T) {
+ t.Parallel()
+
cfg := testcfg.Build(t)
serverSocketPath := runSmartHTTPServer(t, cfg)
@@ -230,6 +246,8 @@ func TestFailureRepoNotFoundInfoRefsReceivePack(t *testing.T) {
}
func TestFailureRepoNotSetInfoRefsReceivePack(t *testing.T) {
+ t.Parallel()
+
cfg := testcfg.Build(t)
serverSocketPath := runSmartHTTPServer(t, cfg)
@@ -293,6 +311,8 @@ func (ms *mockStreamer) PutStream(ctx context.Context, repo *gitalypb.Repository
}
func TestCacheInfoRefsUploadPack(t *testing.T) {
+ t.Parallel()
+
cfg, repo, _ := testcfg.BuildWithRepo(t)
locator := config.NewLocator(cfg)
diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go
index 17fd1da62..e49914e59 100644
--- a/internal/gitaly/service/smarthttp/receive_pack_test.go
+++ b/internal/gitaly/service/smarthttp/receive_pack_test.go
@@ -38,6 +38,8 @@ const (
)
func TestSuccessfulReceivePackRequest(t *testing.T) {
+ t.Parallel()
+
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
cfg.GitlabShell.Dir = "/foo/bar/gitlab-shell"
cfg, hookOutputFile := gittest.CaptureHookEnv(t, cfg)
@@ -109,6 +111,8 @@ func TestSuccessfulReceivePackRequest(t *testing.T) {
}
func TestReceivePackHiddenRefs(t *testing.T) {
+ t.Parallel()
+
cfg, repoProto, repoPath := testcfg.BuildWithRepo(t)
repoProto.GlProjectPath = "project/path"
@@ -160,6 +164,8 @@ func TestReceivePackHiddenRefs(t *testing.T) {
}
func TestSuccessfulReceivePackRequestWithGitProtocol(t *testing.T) {
+ t.Parallel()
+
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
testcfg.BuildGitalyHooks(t, cfg)
@@ -189,6 +195,8 @@ func TestSuccessfulReceivePackRequestWithGitProtocol(t *testing.T) {
}
func TestFailedReceivePackRequestWithGitOpts(t *testing.T) {
+ t.Parallel()
+
cfg, repo, _ := testcfg.BuildWithRepo(t)
serverSocketPath := runSmartHTTPServer(t, cfg)
@@ -211,14 +219,10 @@ func TestFailedReceivePackRequestWithGitOpts(t *testing.T) {
}
func TestFailedReceivePackRequestDueToHooksFailure(t *testing.T) {
- cfg, repo, _ := testcfg.BuildWithRepo(t)
-
- hookDir := testhelper.TempDir(t)
+ t.Parallel()
- defer func(override string) {
- config.OverrideHooksPath = override
- }(config.OverrideHooksPath)
- config.OverrideHooksPath = hookDir
+ cfg, repo, _ := testcfg.BuildWithRepo(t)
+ cfg.Git.HooksPath = testhelper.TempDir(t)
require.NoError(t, os.MkdirAll(cfg.HooksPath(), 0o755))
@@ -332,6 +336,8 @@ func createCommit(t *testing.T, cfg config.Cfg, repoPath string, fileContents []
}
func TestFailedReceivePackRequestDueToValidationError(t *testing.T) {
+ t.Parallel()
+
cfg := testcfg.Build(t)
serverSocketPath := runSmartHTTPServer(t, cfg)
@@ -363,6 +369,8 @@ func TestFailedReceivePackRequestDueToValidationError(t *testing.T) {
}
func TestPostReceivePack_invalidObjects(t *testing.T) {
+ t.Parallel()
+
cfg, repoProto, repoPath := testcfg.BuildWithRepo(t)
repo := localrepo.NewTestRepo(t, cfg, repoProto)
cfg, _ = gittest.CaptureHookEnv(t, cfg)
@@ -483,6 +491,8 @@ func TestPostReceivePack_invalidObjects(t *testing.T) {
}
func TestReceivePackFsck(t *testing.T) {
+ t.Parallel()
+
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
testcfg.BuildGitalyHooks(t, cfg)
@@ -536,6 +546,8 @@ func drainPostReceivePackResponse(stream gitalypb.SmartHTTPService_PostReceivePa
}
func TestPostReceivePackToHooks(t *testing.T) {
+ t.Parallel()
+
cfg, repo, _ := testcfg.BuildWithRepo(t)
testcfg.BuildGitalyHooks(t, cfg)
@@ -597,6 +609,8 @@ func TestPostReceivePackToHooks(t *testing.T) {
}
func TestPostReceiveWithTransactionsViaPraefect(t *testing.T) {
+ t.Parallel()
+
ctx, cancel := testhelper.Context()
defer cancel()
@@ -660,6 +674,8 @@ func (t *testTransactionServer) VoteTransaction(ctx context.Context, in *gitalyp
}
func TestPostReceiveWithReferenceTransactionHook(t *testing.T) {
+ t.Parallel()
+
cfg := testcfg.Build(t)
testcfg.BuildGitalyHooks(t, cfg)
diff --git a/internal/gitaly/service/smarthttp/upload_pack_test.go b/internal/gitaly/service/smarthttp/upload_pack_test.go
index 7c165dbf1..116680dfb 100644
--- a/internal/gitaly/service/smarthttp/upload_pack_test.go
+++ b/internal/gitaly/service/smarthttp/upload_pack_test.go
@@ -54,10 +54,14 @@ func runTestWithAndWithoutConfigOptions(
}
func TestServer_PostUpload(t *testing.T) {
+ t.Parallel()
+
runTestWithAndWithoutConfigOptions(t, testServerPostUpload, makePostUploadPackRequest, testcfg.WithPackObjectsCacheEnabled())
}
func TestServer_PostUploadWithChannel(t *testing.T) {
+ t.Parallel()
+
runTestWithAndWithoutConfigOptions(t, testServerPostUpload, makePostUploadPackWithSidechannelRequest, testcfg.WithPackObjectsCacheEnabled())
}
@@ -100,10 +104,14 @@ func testServerPostUpload(t *testing.T, ctx context.Context, makeRequest request
}
func TestServer_PostUploadPack_gitConfigOptions(t *testing.T) {
+ t.Parallel()
+
runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackGitConfigOptions, makePostUploadPackRequest, testcfg.WithPackObjectsCacheEnabled())
}
func TestServer_PostUploadPackSidechannel_gitConfigOptions(t *testing.T) {
+ t.Parallel()
+
runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackGitConfigOptions, makePostUploadPackWithSidechannelRequest, testcfg.WithPackObjectsCacheEnabled())
}
@@ -154,10 +162,14 @@ func testServerPostUploadPackGitConfigOptions(t *testing.T, ctx context.Context,
}
func TestServer_PostUploadPack_gitProtocol(t *testing.T) {
+ t.Parallel()
+
runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackGitProtocol, makePostUploadPackRequest, testcfg.WithPackObjectsCacheEnabled())
}
func TestServer_PostUploadPackWithSidechannel_gitProtocol(t *testing.T) {
+ t.Parallel()
+
runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackGitProtocol, makePostUploadPackWithSidechannelRequest, testcfg.WithPackObjectsCacheEnabled())
}
@@ -190,10 +202,14 @@ func testServerPostUploadPackGitProtocol(t *testing.T, ctx context.Context, make
// on 'deepen' requests even though the request is being handled just
// fine from the client perspective.
func TestServer_PostUploadPack_suppressDeepenExitError(t *testing.T) {
+ t.Parallel()
+
runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackSuppressDeepenExitError, makePostUploadPackRequest, testcfg.WithPackObjectsCacheEnabled())
}
func TestServer_PostUploadPackWithSidechannel_suppressDeepenExitError(t *testing.T) {
+ t.Parallel()
+
runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackSuppressDeepenExitError, makePostUploadPackWithSidechannelRequest, testcfg.WithPackObjectsCacheEnabled())
}
@@ -215,6 +231,8 @@ func testServerPostUploadPackSuppressDeepenExitError(t *testing.T, ctx context.C
}
func TestServer_PostUploadPack_usesPackObjectsHook(t *testing.T) {
+ t.Parallel()
+
ctx, cancel := testhelper.Context()
defer cancel()
@@ -222,6 +240,8 @@ func TestServer_PostUploadPack_usesPackObjectsHook(t *testing.T) {
}
func TestServer_PostUploadPackWithSidechannel_usesPackObjectsHook(t *testing.T) {
+ t.Parallel()
+
ctx, cancel := testhelper.Context()
defer cancel()
@@ -265,6 +285,8 @@ func testServerPostUploadPackUsesPackObjectsHook(t *testing.T, ctx context.Conte
}
func TestServer_PostUploadPack_validation(t *testing.T) {
+ t.Parallel()
+
runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackValidation, makePostUploadPackRequest, testcfg.WithPackObjectsCacheEnabled())
}
@@ -287,6 +309,8 @@ func testServerPostUploadPackValidation(t *testing.T, ctx context.Context, makeR
}
func TestServer_PostUploadPackSidechannel_validation(t *testing.T) {
+ t.Parallel()
+
runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackWithSideChannelValidation, makePostUploadPackWithSidechannelRequest, testcfg.WithPackObjectsCacheEnabled())
}
@@ -347,10 +371,14 @@ func extractPackDataFromResponse(t *testing.T, buf *bytes.Buffer) ([]byte, int,
}
func TestServer_PostUploadPack_partialClone(t *testing.T) {
+ t.Parallel()
+
runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackPartialClone, makePostUploadPackRequest, testcfg.WithPackObjectsCacheEnabled())
}
func TestServer_PostUploadPackWithSidechannel_partialClone(t *testing.T) {
+ t.Parallel()
+
runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackPartialClone, makePostUploadPackWithSidechannelRequest, testcfg.WithPackObjectsCacheEnabled())
}
@@ -400,6 +428,8 @@ func testServerPostUploadPackPartialClone(t *testing.T, ctx context.Context, mak
}
func TestServer_PostUploadPack_allowAnySHA1InWant(t *testing.T) {
+ t.Parallel()
+
ctx, cancel := testhelper.Context()
defer cancel()
@@ -407,6 +437,8 @@ func TestServer_PostUploadPack_allowAnySHA1InWant(t *testing.T) {
}
func TestServer_PostUploadPackWithSidechannel_allowAnySHA1InWant(t *testing.T) {
+ t.Parallel()
+
ctx, cancel := testhelper.Context()
defer cancel()