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-13 09:09:35 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-10-13 09:35:23 +0300
commitc29b71bcf570ca53d70c774f0fded7a0d94e9639 (patch)
treec50c2f0e57fe9f947917ebe668e74493de067ce6 /internal/testhelper/testserver/gitaly.go
parent8139e0db9deb7fdf37dc2069badd6d88ed367643 (diff)
testserver: Simplify creation of internal socket dir
When an internal socket directory is set when running the Gitaly server, then we will create the socket directory if it doesn't exist. The logic to do so is needlessly complex though, where we try to not create it if it exists already. The intent may be to not schedule the `t.Cleanup()` call which removes the directory if it was preexisting already. But the path shouldn't ever point to anything but a temporary directory anyway, and cleaning those up after the test is done is not going to cause any harm even if it was set up by the caller. Refactor the tests to just always set up the internal socket directory.
Diffstat (limited to 'internal/testhelper/testserver/gitaly.go')
-rw-r--r--internal/testhelper/testserver/gitaly.go15
1 files changed, 2 insertions, 13 deletions
diff --git a/internal/testhelper/testserver/gitaly.go b/internal/testhelper/testserver/gitaly.go
index 12c008259..3c22fc85c 100644
--- a/internal/testhelper/testserver/gitaly.go
+++ b/internal/testhelper/testserver/gitaly.go
@@ -2,7 +2,6 @@ package testserver
import (
"context"
- "errors"
"net"
"os"
"os/exec"
@@ -234,18 +233,8 @@ func runGitaly(t testing.TB, cfg config.Cfg, rubyServer *rubyserver.Server, regi
// listen on internal socket
if cfg.InternalSocketDir != "" {
- internalSocketDir := filepath.Dir(cfg.GitalyInternalSocketPath())
- sds, err := os.Stat(internalSocketDir)
- if err != nil {
- if errors.Is(err, os.ErrNotExist) {
- require.NoError(t, os.MkdirAll(internalSocketDir, 0o700))
- t.Cleanup(func() { require.NoError(t, os.RemoveAll(internalSocketDir)) })
- } else {
- require.FailNow(t, err.Error())
- }
- } else {
- require.True(t, sds.IsDir())
- }
+ require.NoError(t, os.MkdirAll(cfg.InternalSocketDir, 0o700))
+ t.Cleanup(func() { require.NoError(t, os.RemoveAll(cfg.InternalSocketDir)) })
internalListener, err := net.Listen("unix", cfg.GitalyInternalSocketPath())
require.NoError(t, err)