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:
authorToon Claes <toon@gitlab.com>2022-03-29 13:45:09 +0300
committerToon Claes <toon@gitlab.com>2022-03-29 13:45:09 +0300
commit52284ef516c63c424a3b9cc571e3c177153fa96c (patch)
treeb999277c519eed1934ba959aa00936969cc3225b /internal/gitaly/service
parentca8820bb03f012e8abfe7f5da0dfcd9eeb8003b9 (diff)
parent4fef8d1aa7cb10f295e07acff8f29fb924cf9c06 (diff)
Merge branch 'pks-sidechannel-migrate-to-runtime-dir' into 'master'
sidechannel: Convert to use runtime directory to store sockets See merge request gitlab-org/gitaly!4428
Diffstat (limited to 'internal/gitaly/service')
-rw-r--r--internal/gitaly/service/hook/pack_objects_test.go48
-rw-r--r--internal/gitaly/service/smarthttp/receive_pack_test.go1
-rw-r--r--internal/gitaly/service/ssh/receive_pack_test.go1
3 files changed, 50 insertions, 0 deletions
diff --git a/internal/gitaly/service/hook/pack_objects_test.go b/internal/gitaly/service/hook/pack_objects_test.go
index 54deef710..e2ffb15b8 100644
--- a/internal/gitaly/service/hook/pack_objects_test.go
+++ b/internal/gitaly/service/hook/pack_objects_test.go
@@ -11,6 +11,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/git"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/pktline"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
@@ -23,6 +24,18 @@ import (
"google.golang.org/grpc/codes"
)
+func runTestsWithRuntimeDir(t *testing.T, testFunc func(*testing.T, string)) {
+ t.Helper()
+
+ t.Run("no runtime dir", func(t *testing.T) {
+ testFunc(t, "")
+ })
+
+ t.Run("with runtime dir", func(t *testing.T) {
+ testFunc(t, testhelper.TempDir(t))
+ })
+}
+
func cfgWithCache(t *testing.T) config.Cfg {
cfg := testcfg.Build(t)
cfg.PackObjectsCache.Enabled = true
@@ -59,6 +72,11 @@ func TestParsePackObjectsArgs(t *testing.T) {
}
func TestServer_PackObjectsHook_separateContext(t *testing.T) {
+ t.Parallel()
+ runTestsWithRuntimeDir(t, testServerPackObjectsHookSeparateContextWithRuntimeDir)
+}
+
+func testServerPackObjectsHookSeparateContextWithRuntimeDir(t *testing.T, runtimeDir string) {
cfg := cfgWithCache(t)
cfg.SocketPath = runHooksServer(t, cfg, nil)
@@ -85,6 +103,9 @@ func TestServer_PackObjectsHook_separateContext(t *testing.T) {
ctx1, wt1, err := hookPkg.SetupSidechannel(
ctx1,
+ git.HooksPayload{
+ RuntimeDir: runtimeDir,
+ },
func(c *net.UnixConn) error {
defer close(start2)
<-start1
@@ -121,6 +142,9 @@ func TestServer_PackObjectsHook_separateContext(t *testing.T) {
var stdout2 []byte
ctx2, wt2, err := hookPkg.SetupSidechannel(
ctx2,
+ git.HooksPayload{
+ RuntimeDir: runtimeDir,
+ },
func(c *net.UnixConn) error {
<-start2
if _, err := io.WriteString(c, stdin); err != nil {
@@ -161,6 +185,11 @@ func TestServer_PackObjectsHook_separateContext(t *testing.T) {
}
func TestServer_PackObjectsHook_usesCache(t *testing.T) {
+ t.Parallel()
+ runTestsWithRuntimeDir(t, testServerPackObjectsHookUsesCache)
+}
+
+func testServerPackObjectsHookUsesCache(t *testing.T, runtimeDir string) {
cfg := cfgWithCache(t)
tlc := &streamcache.TestLoggingCache{}
@@ -178,6 +207,9 @@ func TestServer_PackObjectsHook_usesCache(t *testing.T) {
var stdout []byte
ctx, wt, err := hookPkg.SetupSidechannel(
ctx,
+ git.HooksPayload{
+ RuntimeDir: runtimeDir,
+ },
func(c *net.UnixConn) error {
if _, err := io.WriteString(c, "3dd08961455abf80ef9115f4afdc1c6f968b503c\n--not\n\n"); err != nil {
return err
@@ -236,7 +268,10 @@ func TestServer_PackObjectsHook_usesCache(t *testing.T) {
func TestServer_PackObjectsHookWithSidechannel(t *testing.T) {
t.Parallel()
+ runTestsWithRuntimeDir(t, testServerPackObjectsHookWithSidechannelWithRuntimeDir)
+}
+func testServerPackObjectsHookWithSidechannelWithRuntimeDir(t *testing.T, runtimeDir string) {
testCases := []struct {
desc string
stdin string
@@ -268,6 +303,9 @@ func TestServer_PackObjectsHookWithSidechannel(t *testing.T) {
var packets []string
ctx, wt, err := hookPkg.SetupSidechannel(
ctx,
+ git.HooksPayload{
+ RuntimeDir: runtimeDir,
+ },
func(c *net.UnixConn) error {
if _, err := io.WriteString(c, tc.stdin); err != nil {
return err
@@ -351,6 +389,8 @@ func TestServer_PackObjectsHookWithSidechannel(t *testing.T) {
}
func TestServer_PackObjectsHookWithSidechannel_invalidArgument(t *testing.T) {
+ t.Parallel()
+
cfg := testcfg.Build(t)
cfg.SocketPath = runHooksServer(t, cfg, nil)
ctx := testhelper.Context(t)
@@ -389,11 +429,19 @@ func TestServer_PackObjectsHookWithSidechannel_invalidArgument(t *testing.T) {
}
func TestServer_PackObjectsHookWithSidechannel_Canceled(t *testing.T) {
+ t.Parallel()
+ runTestsWithRuntimeDir(t, testServerPackObjectsHookWithSidechannelCanceledWithRuntimeDir)
+}
+
+func testServerPackObjectsHookWithSidechannelCanceledWithRuntimeDir(t *testing.T, runtimeDir string) {
cfg := cfgWithCache(t)
ctx := testhelper.Context(t)
ctx, wt, err := hookPkg.SetupSidechannel(
ctx,
+ git.HooksPayload{
+ RuntimeDir: runtimeDir,
+ },
func(c *net.UnixConn) error {
// Simulate a client that successfully initiates a request, but hangs up
// before fully consuming the response.
diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go
index 122defe7e..7eb070b4d 100644
--- a/internal/gitaly/service/smarthttp/receive_pack_test.go
+++ b/internal/gitaly/service/smarthttp/receive_pack_test.go
@@ -101,6 +101,7 @@ func TestSuccessfulReceivePackRequest(t *testing.T) {
payload.Transaction = nil
require.Equal(t, git.HooksPayload{
+ RuntimeDir: cfg.RuntimeDir,
InternalSocket: cfg.GitalyInternalSocketPath(),
InternalSocketToken: cfg.Auth.Token,
ReceiveHooksPayload: &git.ReceiveHooksPayload{
diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go
index cc03f870e..a810d6766 100644
--- a/internal/gitaly/service/ssh/receive_pack_test.go
+++ b/internal/gitaly/service/ssh/receive_pack_test.go
@@ -157,6 +157,7 @@ func TestReceivePackPushSuccess(t *testing.T) {
}
require.Equal(t, git.HooksPayload{
+ RuntimeDir: cfg.RuntimeDir,
InternalSocket: cfg.GitalyInternalSocketPath(),
InternalSocketToken: cfg.Auth.Token,
ReceiveHooksPayload: &git.ReceiveHooksPayload{