As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Unverified Commit afb19df2 authored by Ash McKenzie's avatar Ash McKenzie
Browse files

Use os.MkdirTemp() for UNIX socket creation

parent f7f60f1a
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -84,12 +84,19 @@ func StartGitalyServer(t *testing.T, network string) (string, *TestGitalyServer)
switch network {
case "unix":
tempDir := t.TempDir()
// We can't use t.TempDir() here because it will create a directory that
// far exceeds the 108 character limit which results in the socket failing
// to be created.
//
// See https://gitlab.com/gitlab-org/gitlab-shell/-/issues/696#note_1664726924
// for more detail.
tempDir, err := os.MkdirTemp("", "gitlab-shell-test-api")
require.NoError(t, err)
gitalySocketPath := path.Join(tempDir, "gitaly.sock")
t.Cleanup(func() { require.NoError(t, os.RemoveAll(tempDir)) })
err := os.MkdirAll(filepath.Dir(gitalySocketPath), 0700)
err = os.MkdirAll(filepath.Dir(gitalySocketPath), 0700)
require.NoError(t, err)
addr, testServer := doStartTestServer(t, "unix", gitalySocketPath)
Loading
Loading
Loading
Loading
@@ -25,11 +25,18 @@ type TestRequestHandler struct {
func StartSocketHttpServer(t *testing.T, handlers []TestRequestHandler) string {
t.Helper()
tempDir := t.TempDir()
// We can't use t.TempDir() here because it will create a directory that
// far exceeds the 108 character limit which results in the socket failing
// to be created.
//
// See https://gitlab.com/gitlab-org/gitlab-shell/-/issues/696#note_1664726924
// for more detail.
tempDir, err := os.MkdirTemp("", "gitlab-shell-test-api")
require.NoError(t, err)
t.Cleanup(func() { os.RemoveAll(tempDir) })
testSocket := path.Join(tempDir, "internal.sock")
err := os.MkdirAll(filepath.Dir(testSocket), 0700)
err = os.MkdirAll(filepath.Dir(testSocket), 0700)
require.NoError(t, err)
socketListener, err := net.Listen("unix", testSocket)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment