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:
authorPavlo Strokov <pstrokov@gitlab.com>2020-11-08 18:24:31 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2020-11-20 13:07:13 +0300
commita874e075ed161671d4eb91a57e0dd4d9b2e4a610 (patch)
treeed5bf9af1edbdf47d954ba27c0c9ef15f2720483
parent9191f8f0f17d3b7a958424f91527aa8d8b4c3fcb (diff)
Unbound initialization and validation funcs from global Config
In order to remove dependency on the global config.Config var we need to break dependencies between Config and it's initialization and validation functions. Most of them now represented as a methods on the config.Cfg type. It allows us to setup required Cfg struct for the tests to run without need to sync changes done on the shared global Config var. The tests that were heavily dependent on the Config var now depend on the struct initialized inside the test instead. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699 Blocks: https://gitlab.com/gitlab-org/gitaly/-/issues/3166
-rw-r--r--cmd/gitaly-hooks/hooks.go4
-rw-r--r--cmd/gitaly/main.go12
-rw-r--r--internal/cache/walker.go2
-rw-r--r--internal/cache/walker_test.go4
-rw-r--r--internal/command/command.go2
-rw-r--r--internal/git/catfile/batch_cache.go2
-rw-r--r--internal/git/hooks.go2
-rw-r--r--internal/git/remoterepo/repository_test.go2
-rw-r--r--internal/gitaly/config/config.go195
-rw-r--r--internal/gitaly/config/config_test.go272
-rw-r--r--internal/gitaly/config/locator_test.go21
-rw-r--r--internal/gitaly/config/ruby.go28
-rw-r--r--internal/gitaly/linguist/linguist.go6
-rw-r--r--internal/gitaly/linguist/linguist_test.go8
-rw-r--r--internal/gitaly/rubyserver/rubyserver.go13
-rw-r--r--internal/gitaly/server/server.go8
-rw-r--r--internal/gitaly/server/server_factory.go3
-rw-r--r--internal/gitaly/service/blob/testhelper_test.go6
-rw-r--r--internal/gitaly/service/operations/branches_test.go2
-rw-r--r--internal/gitaly/service/operations/merge.go3
-rw-r--r--internal/gitaly/service/operations/testhelper_test.go2
-rw-r--r--internal/gitaly/service/register.go2
-rw-r--r--internal/gitaly/service/repository/fetch_test.go2
-rw-r--r--internal/gitaly/service/repository/replicate_test.go4
-rw-r--r--internal/gitaly/service/repository/search_files_test.go4
-rw-r--r--internal/gitaly/service/repository/testhelper_test.go2
-rw-r--r--internal/gitaly/service/smarthttp/receive_pack_test.go6
-rw-r--r--internal/gitlabshell/env_test.go4
-rw-r--r--internal/praefect/helper_test.go12
-rw-r--r--internal/praefect/info_service_test.go2
-rw-r--r--internal/praefect/replicator_test.go4
-rw-r--r--internal/praefect/server_factory_test.go2
-rw-r--r--internal/praefect/server_test.go12
-rw-r--r--internal/testhelper/testhelper.go12
-rw-r--r--internal/testhelper/testserver/gitaly.go3
35 files changed, 302 insertions, 366 deletions
diff --git a/cmd/gitaly-hooks/hooks.go b/cmd/gitaly-hooks/hooks.go
index 80b000c90..2b30cf142 100644
--- a/cmd/gitaly-hooks/hooks.go
+++ b/cmd/gitaly-hooks/hooks.go
@@ -327,9 +327,11 @@ func check(configPath string) (*hook.CheckInfo, error) {
}
defer cfgFile.Close()
- if err := config.Load(cfgFile); err != nil {
+ cfg, err := config.Load(cfgFile)
+ if err != nil {
return nil, err
}
+ config.Config = cfg
gitlabAPI, err := hook.NewGitlabAPI(config.Config.Gitlab, config.Config.TLS)
if err != nil {
diff --git a/cmd/gitaly/main.go b/cmd/gitaly/main.go
index b47f04658..b58db95db 100644
--- a/cmd/gitaly/main.go
+++ b/cmd/gitaly/main.go
@@ -36,11 +36,17 @@ func loadConfig(configPath string) error {
}
defer cfgFile.Close()
- if err = config.Load(cfgFile); err != nil {
+ cfg, err := config.Load(cfgFile)
+ if err != nil {
+ return err
+ }
+
+ if err := cfg.Validate(); err != nil {
return err
}
- return config.Validate()
+ config.Config = cfg
+ return nil
}
func flagUsage() {
@@ -132,7 +138,7 @@ func run(b *bootstrap.Bootstrap) error {
for _, c := range []starter.Config{
{starter.Unix, config.Config.SocketPath},
- {starter.Unix, config.GitalyInternalSocketPath()},
+ {starter.Unix, config.Config.GitalyInternalSocketPath()},
{starter.TCP, config.Config.ListenAddr},
{starter.TLS, config.Config.TLSListenAddr},
} {
diff --git a/internal/cache/walker.go b/internal/cache/walker.go
index 775f04896..503379192 100644
--- a/internal/cache/walker.go
+++ b/internal/cache/walker.go
@@ -166,7 +166,7 @@ func moveAndClear(storagePath string) error {
}
func init() {
- config.RegisterHook(func(cfg config.Cfg) error {
+ config.RegisterHook(func(cfg *config.Cfg) error {
pathSet := map[string]struct{}{}
for _, storage := range cfg.Storages {
pathSet[storage.Path] = struct{}{}
diff --git a/internal/cache/walker_test.go b/internal/cache/walker_test.go
index d4c341299..301432609 100644
--- a/internal/cache/walker_test.go
+++ b/internal/cache/walker_test.go
@@ -56,7 +56,7 @@ func TestDiskCacheObjectWalker(t *testing.T) {
*cache.ExportDisableMoveAndClear = true
defer func() { *cache.ExportDisableMoveAndClear = false }()
- require.NoError(t, config.Validate()) // triggers walker
+ require.NoError(t, config.Config.Validate()) // triggers walker
pollCountersUntil(t, expectRemovals)
@@ -87,7 +87,7 @@ func TestDiskCacheInitialClear(t *testing.T) {
// validation will run cache walker hook which synchronously
// runs the move-and-clear function
- require.NoError(t, config.Validate())
+ require.NoError(t, config.Config.Validate())
testhelper.AssertPathNotExists(t, canary)
}
diff --git a/internal/command/command.go b/internal/command/command.go
index 59d06a287..5373853b7 100644
--- a/internal/command/command.go
+++ b/internal/command/command.go
@@ -133,7 +133,7 @@ func GitPath() string {
if config.Config.Git.BinPath == "" {
// This shouldn't happen outside of testing, SetGitPath should be called by
// main.go to ensure correctness of the configuration on start-up.
- if err := config.SetGitPath(); err != nil {
+ if err := config.Config.SetGitPath(); err != nil {
logrus.Fatal(err) // Bail out.
}
}
diff --git a/internal/git/catfile/batch_cache.go b/internal/git/catfile/batch_cache.go
index d20568d36..63bcd290b 100644
--- a/internal/git/catfile/batch_cache.go
+++ b/internal/git/catfile/batch_cache.go
@@ -32,7 +32,7 @@ var cache *batchCache
func init() {
prometheus.MustRegister(catfileCacheMembers)
- config.RegisterHook(func(cfg config.Cfg) error {
+ config.RegisterHook(func(cfg *config.Cfg) error {
cache = newCache(DefaultBatchfileTTL, cfg.Git.CatfileCacheSize)
return nil
})
diff --git a/internal/git/hooks.go b/internal/git/hooks.go
index 97099b859..8716ffc7b 100644
--- a/internal/git/hooks.go
+++ b/internal/git/hooks.go
@@ -44,7 +44,7 @@ func refHookEnv(ctx context.Context, repo *gitalypb.Repository, cfg config.Cfg)
}
return []string{
- "GITALY_SOCKET=" + config.GitalyInternalSocketPath(),
+ "GITALY_SOCKET=" + cfg.GitalyInternalSocketPath(),
fmt.Sprintf("GITALY_REPO=%s", repoJSON),
fmt.Sprintf("GITALY_TOKEN=%s", cfg.Auth.Token),
fmt.Sprintf("%s=true", featureflag.ReferenceTransactionHookEnvVar),
diff --git a/internal/git/remoterepo/repository_test.go b/internal/git/remoterepo/repository_test.go
index 15408e0d5..1e23a7615 100644
--- a/internal/git/remoterepo/repository_test.go
+++ b/internal/git/remoterepo/repository_test.go
@@ -14,7 +14,7 @@ import (
)
func TestRepository(t *testing.T) {
- _, serverSocketPath, cleanup := testserver.RunInternalGitalyServer(t, config.Config.Storages, config.Config.Auth.Token)
+ _, serverSocketPath, cleanup := testserver.RunInternalGitalyServer(t, config.Config.GitalyInternalSocketPath(), config.Config.Storages, config.Config.Auth.Token)
defer cleanup()
ctx, cancel := testhelper.Context()
diff --git a/internal/gitaly/config/config.go b/internal/gitaly/config/config.go
index e832cff4a..3d718904e 100644
--- a/internal/gitaly/config/config.go
+++ b/internal/gitaly/config/config.go
@@ -10,7 +10,6 @@ import (
"os/exec"
"path/filepath"
"strings"
- "sync"
"time"
"github.com/kelseyhightower/envconfig"
@@ -28,7 +27,7 @@ var (
// Config stores the global configuration
Config Cfg
- hooks []func(Cfg) error
+ hooks []func(*Cfg) error
)
// DailyJob enables a daily task to be scheduled for specific storages
@@ -127,56 +126,58 @@ type Concurrency struct {
// Load initializes the Config variable from file and the environment.
// Environment variables take precedence over the file.
-func Load(file io.Reader) error {
- Config = Cfg{}
+func Load(file io.Reader) (Cfg, error) {
+ var cfg Cfg
- if err := toml.NewDecoder(file).Decode(&Config); err != nil {
- return fmt.Errorf("load toml: %v", err)
+ if err := toml.NewDecoder(file).Decode(&cfg); err != nil {
+ return Cfg{}, fmt.Errorf("load toml: %v", err)
}
- if err := envconfig.Process("gitaly", &Config); err != nil {
- return fmt.Errorf("envconfig: %v", err)
+ if err := envconfig.Process("gitaly", &cfg); err != nil {
+ return Cfg{}, fmt.Errorf("envconfig: %v", err)
}
- Config.setDefaults()
+ if err := cfg.setDefaults(); err != nil {
+ return Cfg{}, err
+ }
- for i := range Config.Storages {
- Config.Storages[i].Path = filepath.Clean(Config.Storages[i].Path)
+ for i := range cfg.Storages {
+ cfg.Storages[i].Path = filepath.Clean(cfg.Storages[i].Path)
}
- return nil
+ return cfg, nil
}
// RegisterHook adds a post-validation callback. Your hook should only
// access config via the Cfg instance it gets passed. This avoids race
// conditions during testing, when the global config.Config instance gets
// updated after these hooks have run.
-func RegisterHook(f func(c Cfg) error) {
+func RegisterHook(f func(c *Cfg) error) {
hooks = append(hooks, f)
}
// Validate checks the current Config for sanity. It also runs all hooks
// registered with RegisterHook.
-func Validate() error {
- for _, err := range []error{
- validateListeners(),
- validateStorages(),
- validateToken(),
- SetGitPath(),
- validateShell(),
- ConfigureRuby(),
- validateBinDir(),
- validateInternalSocketDir(),
- validateHooks(),
- validateMaintenance(),
+func (cfg *Cfg) Validate() error {
+ for _, run := range []func() error{
+ cfg.validateListeners,
+ cfg.validateStorages,
+ cfg.validateToken,
+ cfg.SetGitPath,
+ cfg.validateShell,
+ cfg.ConfigureRuby,
+ cfg.validateBinDir,
+ cfg.validateInternalSocketDir,
+ cfg.validateHooks,
+ cfg.validateMaintenance,
} {
- if err != nil {
+ if err := run(); err != nil {
return err
}
}
for _, f := range hooks {
- if err := f(Config); err != nil {
+ if err := f(cfg); err != nil {
return err
}
}
@@ -184,33 +185,48 @@ func Validate() error {
return nil
}
-func (c *Cfg) setDefaults() {
- if c.GracefulRestartTimeout.Duration() == 0 {
- c.GracefulRestartTimeout = Duration(time.Minute)
+func (cfg *Cfg) setDefaults() error {
+ if cfg.GracefulRestartTimeout.Duration() == 0 {
+ cfg.GracefulRestartTimeout = Duration(time.Minute)
}
- if c.Gitlab.SecretFile == "" {
- c.Gitlab.SecretFile = filepath.Join(c.GitlabShell.Dir, ".gitlab_shell_secret")
+ if cfg.Gitlab.SecretFile == "" {
+ cfg.Gitlab.SecretFile = filepath.Join(cfg.GitlabShell.Dir, ".gitlab_shell_secret")
}
- if c.Hooks.CustomHooksDir == "" {
- c.Hooks.CustomHooksDir = filepath.Join(c.GitlabShell.Dir, "hooks")
+ if cfg.Hooks.CustomHooksDir == "" {
+ cfg.Hooks.CustomHooksDir = filepath.Join(cfg.GitlabShell.Dir, "hooks")
}
+
+ if cfg.InternalSocketDir == "" {
+ // The socket path must be short-ish because listen(2) fails on long
+ // socket paths. We hope/expect that ioutil.TempDir creates a directory
+ // that is not too deep. We need a directory, not a tempfile, because we
+ // will later want to set its permissions to 0700
+
+ tmpDir, err := ioutil.TempDir("", "gitaly-internal")
+ if err != nil {
+ return fmt.Errorf("create internal socket directory: %w", err)
+ }
+ cfg.InternalSocketDir = tmpDir
+ }
+
+ return nil
}
-func validateListeners() error {
- if len(Config.SocketPath) == 0 && len(Config.ListenAddr) == 0 {
+func (cfg *Cfg) validateListeners() error {
+ if len(cfg.SocketPath) == 0 && len(cfg.ListenAddr) == 0 {
return fmt.Errorf("invalid listener config: at least one of socket_path and listen_addr must be set")
}
return nil
}
-func validateShell() error {
- if len(Config.GitlabShell.Dir) == 0 {
+func (cfg *Cfg) validateShell() error {
+ if len(cfg.GitlabShell.Dir) == 0 {
return fmt.Errorf("gitlab-shell.dir is not set")
}
- return validateIsDirectory(Config.GitlabShell.Dir, "gitlab-shell.dir")
+ return validateIsDirectory(cfg.GitlabShell.Dir, "gitlab-shell.dir")
}
func checkExecutable(path string) error {
@@ -241,7 +257,7 @@ func (h *hookErrs) Add(err error) {
h.errors = append(h.errors, err)
}
-func validateHooks() error {
+func (cfg *Cfg) validateHooks() error {
if SkipHooks() {
return nil
}
@@ -249,7 +265,7 @@ func validateHooks() error {
errs := &hookErrs{}
for _, hookName := range []string{"pre-receive", "post-receive", "update"} {
- if err := checkExecutable(filepath.Join(Config.Ruby.Dir, "git-hooks", hookName)); err != nil {
+ if err := checkExecutable(filepath.Join(cfg.Ruby.Dir, "git-hooks", hookName)); err != nil {
errs.Add(err)
continue
}
@@ -277,12 +293,12 @@ func validateIsDirectory(path, name string) error {
return nil
}
-func validateStorages() error {
- if len(Config.Storages) == 0 {
+func (cfg *Cfg) validateStorages() error {
+ if len(cfg.Storages) == 0 {
return fmt.Errorf("no storage configurations found. Are you using the right format? https://gitlab.com/gitlab-org/gitaly/issues/397")
}
- for i, storage := range Config.Storages {
+ for i, storage := range cfg.Storages {
if storage.Name == "" {
return fmt.Errorf("empty storage name in %+v", storage)
}
@@ -300,7 +316,7 @@ func validateStorages() error {
return fmt.Errorf("storage %+v path must be a dir", storage)
}
- for _, other := range Config.Storages[:i] {
+ for _, other := range cfg.Storages[:i] {
if other.Name == storage.Name {
return fmt.Errorf("storage %q is defined more than once", storage.Name)
}
@@ -329,13 +345,13 @@ func SkipHooks() bool {
// SetGitPath populates the variable GitPath with the path to the `git`
// executable. It warns if no path was specified in the configuration.
-func SetGitPath() error {
- if Config.Git.BinPath != "" {
+func (cfg *Cfg) SetGitPath() error {
+ if cfg.Git.BinPath != "" {
return nil
}
if path, ok := os.LookupEnv("GITALY_TESTING_GIT_BINARY"); ok {
- Config.Git.BinPath = path
+ cfg.Git.BinPath = path
return nil
}
@@ -348,21 +364,21 @@ func SetGitPath() error {
"resolvedPath": resolvedPath,
}).Warn("git path not configured. Using default path resolution")
- Config.Git.BinPath = resolvedPath
+ cfg.Git.BinPath = resolvedPath
return nil
}
// StoragePath looks up the base path for storageName. The second boolean
// return value indicates if anything was found.
-func (c Cfg) StoragePath(storageName string) (string, bool) {
- storage, ok := c.Storage(storageName)
+func (cfg *Cfg) StoragePath(storageName string) (string, bool) {
+ storage, ok := cfg.Storage(storageName)
return storage.Path, ok
}
// Storage looks up storageName.
-func (c Cfg) Storage(storageName string) (Storage, bool) {
- for _, storage := range c.Storages {
+func (cfg *Cfg) Storage(storageName string) (Storage, bool) {
+ for _, storage := range cfg.Storages {
if storage.Name == storageName {
return storage, true
}
@@ -370,19 +386,24 @@ func (c Cfg) Storage(storageName string) (Storage, bool) {
return Storage{}, false
}
-func validateBinDir() error {
- if err := validateIsDirectory(Config.BinDir, "bin_dir"); err != nil {
+// GitalyInternalSocketPath is the path to the internal gitaly socket
+func (cfg *Cfg) GitalyInternalSocketPath() string {
+ return filepath.Join(cfg.InternalSocketDir, "internal.sock")
+}
+
+func (cfg *Cfg) validateBinDir() error {
+ if err := validateIsDirectory(cfg.BinDir, "bin_dir"); err != nil {
log.WithError(err).Warn("Gitaly bin directory is not configured")
return err
}
var err error
- Config.BinDir, err = filepath.Abs(Config.BinDir)
+ cfg.BinDir, err = filepath.Abs(cfg.BinDir)
return err
}
-func validateToken() error {
- if !Config.Auth.Transitioning || len(Config.Auth.Token) == 0 {
+func (cfg *Cfg) validateToken() error {
+ if !cfg.Auth.Transitioning || len(cfg.Auth.Token) == 0 {
return nil
}
@@ -390,58 +411,12 @@ func validateToken() error {
return nil
}
-var (
- lazyInit sync.Once
- generatedInternalSocketDir string
-)
-
-func generateSocketPath() {
- // The socket path must be short-ish because listen(2) fails on long
- // socket paths. We hope/expect that ioutil.TempDir creates a directory
- // that is not too deep. We need a directory, not a tempfile, because we
- // will later want to set its permissions to 0700
-
- var err error
- generatedInternalSocketDir, err = ioutil.TempDir("", "gitaly-internal")
- if err != nil {
- log.Fatalf("create ruby server socket directory: %v", err)
- }
-}
-
-// InternalSocketDir will generate a temp dir for internal sockets if one is not provided in the config
-func InternalSocketDir() string {
- if Config.InternalSocketDir != "" {
- return Config.InternalSocketDir
- }
-
- if generatedInternalSocketDir == "" {
- lazyInit.Do(generateSocketPath)
- }
-
- return generatedInternalSocketDir
-}
-
-// GitalyInternalSocketPath is the path to the internal gitaly socket
-func GitalyInternalSocketPath() string {
- socketDir := InternalSocketDir()
- if socketDir == "" {
- panic("internal socket directory is missing")
- }
-
- return filepath.Join(socketDir, "internal.sock")
-}
-
-// GeneratedInternalSocketDir returns the path to the generated internal socket directory
-func GeneratedInternalSocketDir() string {
- return generatedInternalSocketDir
-}
-
-func validateInternalSocketDir() error {
- if Config.InternalSocketDir == "" {
+func (cfg *Cfg) validateInternalSocketDir() error {
+ if cfg.InternalSocketDir == "" {
return nil
}
- dir := Config.InternalSocketDir
+ dir := cfg.InternalSocketDir
f, err := os.Stat(dir)
switch {
@@ -475,11 +450,11 @@ func trySocketCreation(dir string) error {
return l.Close()
}
-func validateMaintenance() error {
- dm := Config.DailyMaintenance
+func (cfg *Cfg) validateMaintenance() error {
+ dm := cfg.DailyMaintenance
sNames := map[string]struct{}{}
- for _, s := range Config.Storages {
+ for _, s := range cfg.Storages {
sNames[s.Name] = struct{}{}
}
for _, sName := range dm.Storages {
diff --git a/internal/gitaly/config/config_test.go b/internal/gitaly/config/config_test.go
index da302bad9..da6107904 100644
--- a/internal/gitaly/config/config_test.go
+++ b/internal/gitaly/config/config_test.go
@@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"fmt"
- "io"
"io/ioutil"
"os"
"os/exec"
@@ -18,94 +17,92 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config/sentry"
)
-func configFileReader(content string) io.Reader {
- return bytes.NewReader([]byte(content))
-}
+func TestLoad_doesntClearPreviousGlobalConfig(t *testing.T) {
+ defer func(old Cfg) { Config = old }(Config)
-func TestLoadClearPrevConfig(t *testing.T) {
Config = Cfg{SocketPath: "/tmp"}
- err := Load(&bytes.Buffer{})
- assert.NoError(t, err)
+ cfg, err := Load(&bytes.Buffer{})
+ require.NoError(t, err)
- assert.Empty(t, Config.SocketPath)
+ require.Equal(t, "", cfg.SocketPath)
+ require.Equal(t, "/tmp", Config.SocketPath)
}
func TestLoadBrokenConfig(t *testing.T) {
- tmpFile := configFileReader(`path = "/tmp"\nname="foo"`)
- err := Load(tmpFile)
+ tmpFile := strings.NewReader(`path = "/tmp"\nname="foo"`)
+ _, err := Load(tmpFile)
assert.Error(t, err)
-
- assert.Equal(t, Cfg{}, Config)
}
func TestLoadEmptyConfig(t *testing.T) {
- tmpFile := configFileReader(``)
-
- err := Load(tmpFile)
- assert.NoError(t, err)
+ cfg, err := Load(strings.NewReader(``))
+ require.NoError(t, err)
- defaultConf := Cfg{}
- defaultConf.setDefaults()
+ defaultConf := Cfg{InternalSocketDir: cfg.InternalSocketDir}
+ require.NoError(t, defaultConf.setDefaults())
- assert.Equal(t, defaultConf, Config)
+ assert.Equal(t, defaultConf, cfg)
}
func TestLoadURLs(t *testing.T) {
- tmpFile := configFileReader(`
+ tmpFile := strings.NewReader(`
[gitlab]
url = "unix:///tmp/test.socket"
relative_url_root = "/gitlab"`)
- err := Load(tmpFile)
- assert.NoError(t, err)
+ cfg, err := Load(tmpFile)
+ require.NoError(t, err)
- defaultConf := Cfg{Gitlab: Gitlab{
- URL: "unix:///tmp/test.socket",
- RelativeURLRoot: "/gitlab",
- }}
- defaultConf.setDefaults()
+ defaultConf := Cfg{
+ Gitlab: Gitlab{
+ URL: "unix:///tmp/test.socket",
+ RelativeURLRoot: "/gitlab",
+ },
+ }
+ require.NoError(t, defaultConf.setDefaults())
- assert.Equal(t, defaultConf, Config)
+ assert.Equal(t, defaultConf.Gitlab, cfg.Gitlab)
}
func TestLoadStorage(t *testing.T) {
- tmpFile := configFileReader(`[[storage]]
+ tmpFile := strings.NewReader(`[[storage]]
name = "default"
path = "/tmp/"`)
- err := Load(tmpFile)
- assert.NoError(t, err)
+ cfg, err := Load(tmpFile)
+ require.NoError(t, err)
- if assert.Equal(t, 1, len(Config.Storages), "Expected one (1) storage") {
+ if assert.Equal(t, 1, len(cfg.Storages), "Expected one (1) storage") {
expectedConf := Cfg{
Storages: []Storage{
{Name: "default", Path: "/tmp"},
},
}
- expectedConf.setDefaults()
+ require.NoError(t, expectedConf.setDefaults())
- assert.Equal(t, expectedConf, Config)
+ assert.Equal(t, expectedConf.Storages, cfg.Storages)
}
}
func TestUncleanStoragePaths(t *testing.T) {
- require.NoError(t, Load(strings.NewReader(`[[storage]]
+ cfg, err := Load(strings.NewReader(`[[storage]]
name="unclean-path-1"
path="/tmp/repos1//"
[[storage]]
name="unclean-path-2"
path="/tmp/repos2/subfolder/.."
-`)))
+`))
+ require.NoError(t, err)
require.Equal(t, []Storage{
{Name: "unclean-path-1", Path: "/tmp/repos1"},
{Name: "unclean-path-2", Path: "/tmp/repos2"},
- }, Config.Storages)
+ }, cfg.Storages)
}
func TestLoadMultiStorage(t *testing.T) {
- tmpFile := configFileReader(`[[storage]]
+ tmpFile := strings.NewReader(`[[storage]]
name="default"
path="/tmp/repos1"
@@ -113,30 +110,30 @@ path="/tmp/repos1"
name="other"
path="/tmp/repos2/"`)
- err := Load(tmpFile)
- assert.NoError(t, err)
+ cfg, err := Load(tmpFile)
+ require.NoError(t, err)
- if assert.Equal(t, 2, len(Config.Storages), "Expected one (1) storage") {
+ if assert.Equal(t, 2, len(cfg.Storages), "Expected one (1) storage") {
expectedConf := Cfg{
Storages: []Storage{
{Name: "default", Path: "/tmp/repos1"},
{Name: "other", Path: "/tmp/repos2"},
},
}
- expectedConf.setDefaults()
+ require.NoError(t, expectedConf.setDefaults())
- assert.Equal(t, expectedConf, Config)
+ assert.Equal(t, expectedConf.Storages, cfg.Storages)
}
}
func TestLoadSentry(t *testing.T) {
- tmpFile := configFileReader(`[logging]
+ tmpFile := strings.NewReader(`[logging]
sentry_environment = "production"
sentry_dsn = "abc123"
ruby_sentry_dsn = "xyz456"`)
- err := Load(tmpFile)
- assert.NoError(t, err)
+ cfg, err := Load(tmpFile)
+ require.NoError(t, err)
expectedConf := Cfg{
Logging: Logging{
@@ -147,36 +144,36 @@ ruby_sentry_dsn = "xyz456"`)
RubySentryDSN: "xyz456",
},
}
- expectedConf.setDefaults()
+ require.NoError(t, expectedConf.setDefaults())
- assert.Equal(t, expectedConf, Config)
+ assert.Equal(t, expectedConf.Logging, cfg.Logging)
}
func TestLoadPrometheus(t *testing.T) {
- tmpFile := configFileReader(`prometheus_listen_addr=":9236"`)
+ tmpFile := strings.NewReader(`prometheus_listen_addr=":9236"`)
- err := Load(tmpFile)
- assert.NoError(t, err)
+ cfg, err := Load(tmpFile)
+ require.NoError(t, err)
- assert.Equal(t, ":9236", Config.PrometheusListenAddr)
+ assert.Equal(t, ":9236", cfg.PrometheusListenAddr)
}
func TestLoadSocketPath(t *testing.T) {
- tmpFile := configFileReader(`socket_path="/tmp/gitaly.sock"`)
+ tmpFile := strings.NewReader(`socket_path="/tmp/gitaly.sock"`)
- err := Load(tmpFile)
- assert.NoError(t, err)
+ cfg, err := Load(tmpFile)
+ require.NoError(t, err)
- assert.Equal(t, "/tmp/gitaly.sock", Config.SocketPath)
+ assert.Equal(t, "/tmp/gitaly.sock", cfg.SocketPath)
}
func TestLoadListenAddr(t *testing.T) {
- tmpFile := configFileReader(`listen_addr=":8080"`)
+ tmpFile := strings.NewReader(`listen_addr=":8080"`)
- err := Load(tmpFile)
- assert.NoError(t, err)
+ cfg, err := Load(tmpFile)
+ require.NoError(t, err)
- assert.Equal(t, ":8080", Config.ListenAddr)
+ assert.Equal(t, ":8080", cfg.ListenAddr)
}
func tempEnv(key, value string) func() {
@@ -197,37 +194,33 @@ func TestLoadOverrideEnvironment(t *testing.T) {
tempEnv3 := tempEnv("GITALY_PROMETHEUS_LISTEN_ADDR", ":9237")
defer tempEnv3()
- tmpFile := configFileReader(`socket_path = "/tmp/gitaly.sock"
+ tmpFile := strings.NewReader(`socket_path = "/tmp/gitaly.sock"
listen_addr = ":8080"
prometheus_listen_addr = ":9236"`)
- err := Load(tmpFile)
- assert.NoError(t, err)
+ cfg, err := Load(tmpFile)
+ require.NoError(t, err)
- assert.Equal(t, ":9237", Config.PrometheusListenAddr)
- assert.Equal(t, "/tmp/gitaly2.sock", Config.SocketPath)
- assert.Equal(t, ":8081", Config.ListenAddr)
+ assert.Equal(t, ":9237", cfg.PrometheusListenAddr)
+ assert.Equal(t, "/tmp/gitaly2.sock", cfg.SocketPath)
+ assert.Equal(t, ":8081", cfg.ListenAddr)
}
func TestLoadOnlyEnvironment(t *testing.T) {
// Test that this works since we still want this to work
- os.Setenv("GITALY_SOCKET_PATH", "/tmp/gitaly2.sock")
- os.Setenv("GITALY_LISTEN_ADDR", ":8081")
- os.Setenv("GITALY_PROMETHEUS_LISTEN_ADDR", ":9237")
+ defer tempEnv("GITALY_SOCKET_PATH", "/tmp/gitaly2.sock")()
+ defer tempEnv("GITALY_LISTEN_ADDR", ":8081")()
+ defer tempEnv("GITALY_PROMETHEUS_LISTEN_ADDR", ":9237")()
- err := Load(&bytes.Buffer{})
- assert.NoError(t, err)
+ cfg, err := Load(&bytes.Buffer{})
+ require.NoError(t, err)
- assert.Equal(t, ":9237", Config.PrometheusListenAddr)
- assert.Equal(t, "/tmp/gitaly2.sock", Config.SocketPath)
- assert.Equal(t, ":8081", Config.ListenAddr)
+ assert.Equal(t, ":9237", cfg.PrometheusListenAddr)
+ assert.Equal(t, "/tmp/gitaly2.sock", cfg.SocketPath)
+ assert.Equal(t, ":8081", cfg.ListenAddr)
}
func TestValidateStorages(t *testing.T) {
- defer func(oldStorages []Storage) {
- Config.Storages = oldStorages
- }(Config.Storages)
-
repositories, err := filepath.Abs("testdata/repositories")
require.NoError(t, err)
@@ -322,8 +315,9 @@ func TestValidateStorages(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
- Config.Storages = tc.storages
- err := validateStorages()
+ cfg := Cfg{Storages: tc.storages}
+
+ err := cfg.validateStorages()
if tc.invalid {
assert.Error(t, err, "%+v", tc.storages)
return
@@ -437,7 +431,7 @@ func TestValidateHooks(t *testing.T) {
tempHookDir, cleanup := setupTempHookDirs(t, tc.hookFiles)
defer cleanup()
- Config = Cfg{
+ cfg := Cfg{
Ruby: Ruby{
Dir: filepath.Join(tempHookDir, "ruby"),
},
@@ -447,8 +441,9 @@ func TestValidateHooks(t *testing.T) {
BinDir: filepath.Join(tempHookDir, "/bin"),
}
- err := validateHooks()
+ err := cfg.validateHooks()
if tc.expectedErrRegex != "" {
+ require.Error(t, err)
require.Regexp(t, tc.expectedErrRegex, err.Error(), "error should match regexp")
}
})
@@ -456,27 +451,19 @@ func TestValidateHooks(t *testing.T) {
}
func TestLoadGit(t *testing.T) {
- defer func(oldGitSettings Git) {
- Config.Git = oldGitSettings
- }(Config.Git)
-
- tmpFile := configFileReader(`[git]
+ tmpFile := strings.NewReader(`[git]
bin_path = "/my/git/path"
catfile_cache_size = 50
`)
- err := Load(tmpFile)
+ cfg, err := Load(tmpFile)
require.NoError(t, err)
- require.Equal(t, "/my/git/path", Config.Git.BinPath)
- require.Equal(t, 50, Config.Git.CatfileCacheSize)
+ require.Equal(t, "/my/git/path", cfg.Git.BinPath)
+ require.Equal(t, 50, cfg.Git.CatfileCacheSize)
}
func TestSetGitPath(t *testing.T) {
- defer func(oldGitSettings Git) {
- Config.Git = oldGitSettings
- }(Config.Git)
-
var resolvedGitPath string
if path, ok := os.LookupEnv("GITALY_TESTING_GIT_BINARY"); ok {
resolvedGitPath = path
@@ -505,18 +492,14 @@ func TestSetGitPath(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
- Config.Git.BinPath = tc.gitBinPath
- SetGitPath()
- assert.Equal(t, tc.expected, Config.Git.BinPath, tc.desc)
+ cfg := Cfg{Git: Git{BinPath: tc.gitBinPath}}
+ require.NoError(t, cfg.SetGitPath())
+ assert.Equal(t, tc.expected, cfg.Git.BinPath, tc.desc)
})
}
}
func TestValidateShellPath(t *testing.T) {
- defer func(oldShellSettings GitlabShell) {
- Config.GitlabShell = oldShellSettings
- }(Config.GitlabShell)
-
tmpDir, err := ioutil.TempDir("", "gitaly-tests-")
require.NoError(t, err)
require.NoError(t, os.MkdirAll(filepath.Join(tmpDir, "bin"), 0755))
@@ -554,22 +537,19 @@ func TestValidateShellPath(t *testing.T) {
}
for _, tc := range testCases {
- t.Log(tc.desc)
- Config.GitlabShell.Dir = tc.path
- err = validateShell()
- if tc.shouldErr {
- assert.Error(t, err)
- } else {
- assert.NoError(t, err)
- }
+ t.Run(tc.desc, func(t *testing.T) {
+ cfg := Cfg{GitlabShell: GitlabShell{Dir: tc.path}}
+ err := cfg.validateShell()
+ if tc.shouldErr {
+ assert.Error(t, err)
+ } else {
+ assert.NoError(t, err)
+ }
+ })
}
}
func TestConfigureRuby(t *testing.T) {
- defer func(oldRuby Ruby) {
- Config.Ruby = oldRuby
- }(Config.Ruby)
-
tmpDir, err := ioutil.TempDir("", "gitaly-test")
require.NoError(t, err)
defer os.RemoveAll(tmpDir)
@@ -591,9 +571,9 @@ func TestConfigureRuby(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
- Config.Ruby = Ruby{Dir: tc.dir}
+ cfg := Cfg{Ruby: Ruby{Dir: tc.dir}}
- err := ConfigureRuby()
+ err := cfg.ConfigureRuby()
if !tc.ok {
require.Error(t, err)
return
@@ -601,17 +581,13 @@ func TestConfigureRuby(t *testing.T) {
require.NoError(t, err)
- dir := Config.Ruby.Dir
+ dir := cfg.Ruby.Dir
require.True(t, filepath.IsAbs(dir), "expected %q to be absolute path", dir)
})
}
}
func TestConfigureRubyNumWorkers(t *testing.T) {
- defer func(oldRuby Ruby) {
- Config.Ruby = oldRuby
- }(Config.Ruby)
-
testCases := []struct {
in, out int
}{
@@ -624,18 +600,14 @@ func TestConfigureRubyNumWorkers(t *testing.T) {
for _, tc := range testCases {
t.Run(fmt.Sprintf("%+v", tc), func(t *testing.T) {
- Config.Ruby = Ruby{Dir: "/", NumWorkers: tc.in}
- require.NoError(t, ConfigureRuby())
- require.Equal(t, tc.out, Config.Ruby.NumWorkers)
+ cfg := Cfg{Ruby: Ruby{Dir: "/", NumWorkers: tc.in}}
+ require.NoError(t, cfg.ConfigureRuby())
+ require.Equal(t, tc.out, cfg.Ruby.NumWorkers)
})
}
}
func TestValidateListeners(t *testing.T) {
- defer func(cfg Cfg) {
- Config = cfg
- }(Config)
-
testCases := []struct {
desc string
Cfg
@@ -649,8 +621,7 @@ func TestValidateListeners(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
- Config = tc.Cfg
- err := validateListeners()
+ err := tc.Cfg.validateListeners()
if tc.ok {
require.NoError(t, err)
} else {
@@ -678,12 +649,12 @@ func TestLoadGracefulRestartTimeout(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
- tmpFile := configFileReader(test.config)
+ tmpFile := strings.NewReader(test.config)
- err := Load(tmpFile)
+ cfg, err := Load(tmpFile)
assert.NoError(t, err)
- assert.Equal(t, test.expected, Config.GracefulRestartTimeout.Duration())
+ assert.Equal(t, test.expected, cfg.GracefulRestartTimeout.Duration())
})
}
}
@@ -698,19 +669,16 @@ func TestGitlabShellDefaults(t *testing.T) {
CustomHooksDir: filepath.Join(gitlabShellDir, "hooks"),
}
- tmpFile := configFileReader(fmt.Sprintf(`[gitlab-shell]
+ tmpFile := strings.NewReader(fmt.Sprintf(`[gitlab-shell]
dir = '%s'`, gitlabShellDir))
- require.NoError(t, Load(tmpFile))
+ cfg, err := Load(tmpFile)
+ require.NoError(t, err)
- require.Equal(t, expectedGitlab, Config.Gitlab)
- require.Equal(t, expectedHooks, Config.Hooks)
+ require.Equal(t, expectedGitlab, cfg.Gitlab)
+ require.Equal(t, expectedHooks, cfg.Hooks)
}
func TestValidateInternalSocketDir(t *testing.T) {
- defer func(internalSocketDir string) {
- Config.InternalSocketDir = internalSocketDir
- }(Config.InternalSocketDir)
-
// create a valid socket directory
tempDir, err := ioutil.TempDir("testdata", t.Name())
require.NoError(t, err)
@@ -764,23 +732,20 @@ func TestValidateInternalSocketDir(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
- Config.InternalSocketDir = tc.internalSocketDir
+ cfg := Cfg{InternalSocketDir: tc.internalSocketDir}
if tc.shouldError {
- assert.Error(t, validateInternalSocketDir())
+ assert.Error(t, cfg.validateInternalSocketDir())
return
}
- assert.NoError(t, validateInternalSocketDir())
+ assert.NoError(t, cfg.validateInternalSocketDir())
})
}
}
func TestInternalSocketDir(t *testing.T) {
- defer func(internalSocketDir string) {
- Config.InternalSocketDir = internalSocketDir
- }(Config.InternalSocketDir)
-
- Config.InternalSocketDir = ""
- socketDir := InternalSocketDir()
+ cfg, err := Load(bytes.NewReader(nil))
+ require.NoError(t, err)
+ socketDir := cfg.InternalSocketDir
require.NoError(t, trySocketCreation(socketDir))
require.NoError(t, os.RemoveAll(socketDir))
@@ -843,10 +808,11 @@ storages = ["default"]
},
} {
t.Run(tt.name, func(t *testing.T) {
- tmpFile := configFileReader(tt.rawCfg)
- require.Equal(t, tt.loadErr, Load(tmpFile))
- require.Equal(t, tt.expect, Config.DailyMaintenance)
- require.Equal(t, tt.validateErr, validateMaintenance())
+ tmpFile := strings.NewReader(tt.rawCfg)
+ cfg, err := Load(tmpFile)
+ require.Equal(t, tt.loadErr, err)
+ require.Equal(t, tt.expect, cfg.DailyMaintenance)
+ require.Equal(t, tt.validateErr, cfg.validateMaintenance())
})
}
}
diff --git a/internal/gitaly/config/locator_test.go b/internal/gitaly/config/locator_test.go
index 84088a8dc..315f6df2b 100644
--- a/internal/gitaly/config/locator_test.go
+++ b/internal/gitaly/config/locator_test.go
@@ -21,15 +21,18 @@ func TestConfigLocator_GetObjectDirectoryPath(t *testing.T) {
repoPath := filepath.Join(tmpDir, "relative")
require.NoError(t, os.MkdirAll(repoPath, 0755))
- require.NoError(t, SetGitPath())
- cmd := exec.Command(Config.Git.BinPath, "init", "--bare", "--quiet")
+ cfg := Cfg{
+ Storages: []Storage{{
+ Name: "gitaly-1",
+ Path: filepath.Dir(repoPath),
+ }},
+ }
+ require.NoError(t, cfg.SetGitPath())
+ cmd := exec.Command(cfg.Git.BinPath, "init", "--bare", "--quiet")
cmd.Dir = repoPath
require.NoError(t, cmd.Run())
- locator := NewLocator(Cfg{Storages: []Storage{{
- Name: "gitaly-1",
- Path: filepath.Dir(repoPath),
- }}})
+ locator := NewLocator(cfg)
repoWithGitObjDir := func(dir string) *gitalypb.Repository {
return &gitalypb.Repository{
@@ -101,11 +104,7 @@ func TestConfigLocator_GetObjectDirectoryPath(t *testing.T) {
return
}
- if err != nil {
- require.NoError(t, err)
- return
- }
-
+ require.NoError(t, err)
require.Equal(t, tc.path, path)
})
}
diff --git a/internal/gitaly/config/ruby.go b/internal/gitaly/config/ruby.go
index bd9722d8b..a2a95de3f 100644
--- a/internal/gitaly/config/ruby.go
+++ b/internal/gitaly/config/ruby.go
@@ -40,40 +40,40 @@ func (d Duration) MarshalText() ([]byte, error) {
}
// ConfigureRuby validates the gitaly-ruby configuration and sets default values.
-func ConfigureRuby() error {
- if Config.Ruby.GracefulRestartTimeout.Duration() == 0 {
- Config.Ruby.GracefulRestartTimeout = Duration(10 * time.Minute)
+func (cfg *Cfg) ConfigureRuby() error {
+ if cfg.Ruby.GracefulRestartTimeout.Duration() == 0 {
+ cfg.Ruby.GracefulRestartTimeout = Duration(10 * time.Minute)
}
- if Config.Ruby.MaxRSS == 0 {
- Config.Ruby.MaxRSS = 200 * 1024 * 1024
+ if cfg.Ruby.MaxRSS == 0 {
+ cfg.Ruby.MaxRSS = 200 * 1024 * 1024
}
- if Config.Ruby.RestartDelay.Duration() == 0 {
- Config.Ruby.RestartDelay = Duration(5 * time.Minute)
+ if cfg.Ruby.RestartDelay.Duration() == 0 {
+ cfg.Ruby.RestartDelay = Duration(5 * time.Minute)
}
- if len(Config.Ruby.Dir) == 0 {
+ if len(cfg.Ruby.Dir) == 0 {
return fmt.Errorf("gitaly-ruby.dir is not set")
}
minWorkers := 2
- if Config.Ruby.NumWorkers < minWorkers {
- Config.Ruby.NumWorkers = minWorkers
+ if cfg.Ruby.NumWorkers < minWorkers {
+ cfg.Ruby.NumWorkers = minWorkers
}
var err error
- Config.Ruby.Dir, err = filepath.Abs(Config.Ruby.Dir)
+ cfg.Ruby.Dir, err = filepath.Abs(cfg.Ruby.Dir)
if err != nil {
return err
}
- if len(Config.Ruby.RuggedGitConfigSearchPath) != 0 {
- Config.Ruby.RuggedGitConfigSearchPath, err = filepath.Abs(Config.Ruby.RuggedGitConfigSearchPath)
+ if len(cfg.Ruby.RuggedGitConfigSearchPath) != 0 {
+ cfg.Ruby.RuggedGitConfigSearchPath, err = filepath.Abs(cfg.Ruby.RuggedGitConfigSearchPath)
if err != nil {
return err
}
}
- return validateIsDirectory(Config.Ruby.Dir, "gitaly-ruby.dir")
+ return validateIsDirectory(cfg.Ruby.Dir, "gitaly-ruby.dir")
}
diff --git a/internal/gitaly/linguist/linguist.go b/internal/gitaly/linguist/linguist.go
index 29916e934..9d92e05b7 100644
--- a/internal/gitaly/linguist/linguist.go
+++ b/internal/gitaly/linguist/linguist.go
@@ -63,7 +63,7 @@ func Color(language string) string {
}
// LoadColors loads the name->color map from the Linguist gem.
-func LoadColors(cfg config.Cfg) error {
+func LoadColors(cfg *config.Cfg) error {
jsonReader, err := openLanguagesJSON(cfg)
if err != nil {
return err
@@ -115,7 +115,7 @@ func startGitLinguist(ctx context.Context, repoPath string, commitID string, lin
return internalCmd, nil
}
-func openLanguagesJSON(cfg config.Cfg) (io.ReadCloser, error) {
+func openLanguagesJSON(cfg *config.Cfg) (io.ReadCloser, error) {
if jsonPath := cfg.Ruby.LinguistLanguagesPath; jsonPath != "" {
// This is a fallback for environments where dynamic discovery of the
// linguist path via Bundler is not working for some reason, for example
@@ -137,7 +137,7 @@ func openLanguagesJSON(cfg config.Cfg) (io.ReadCloser, error) {
// on its stdout.
rubyScript := `FileUtils.ln_sf(Bundler.rubygems.find_name('github-linguist').first.full_gem_path, ARGV.first)`
cmd := exec.Command("bundle", "exec", "ruby", "-rfileutils", "-e", rubyScript, linguistPathSymlink.Name())
- cmd.Dir = config.Config.Ruby.Dir
+ cmd.Dir = cfg.Ruby.Dir
// We have learned that in practice the command we are about to run is a
// canary for Ruby/Bundler configuration problems. Including stderr and
diff --git a/internal/gitaly/linguist/linguist_test.go b/internal/gitaly/linguist/linguist_test.go
index 284b25b17..72037bd75 100644
--- a/internal/gitaly/linguist/linguist_test.go
+++ b/internal/gitaly/linguist/linguist_test.go
@@ -36,20 +36,24 @@ func TestStatsUnmarshalJSONError(t *testing.T) {
}
func TestLoadLanguages(t *testing.T) {
+ defer func(old config.Cfg) { config.Config = old }(config.Config)
+
colorMap = make(map[string]Language)
- require.NoError(t, LoadColors(config.Config), "load colors")
+ require.NoError(t, LoadColors(&config.Config), "load colors")
require.Equal(t, "#701516", Color("Ruby"), "color value for 'Ruby'")
}
func TestLoadLanguagesCustomPath(t *testing.T) {
+ defer func(old config.Cfg) { config.Config = old }(config.Config)
+
jsonPath, err := filepath.Abs("testdata/fake-languages.json")
require.NoError(t, err)
config.Config.Ruby.LinguistLanguagesPath = jsonPath
colorMap = make(map[string]Language)
- require.NoError(t, LoadColors(config.Config), "load colors")
+ require.NoError(t, LoadColors(&config.Config), "load colors")
require.Equal(t, "foo color", Color("FooBar"))
}
diff --git a/internal/gitaly/rubyserver/rubyserver.go b/internal/gitaly/rubyserver/rubyserver.go
index 3d5db50ac..1d7542859 100644
--- a/internal/gitaly/rubyserver/rubyserver.go
+++ b/internal/gitaly/rubyserver/rubyserver.go
@@ -39,15 +39,6 @@ func init() {
}
}
-func socketPath(id int) string {
- socketDir := config.InternalSocketDir()
- if socketDir == "" {
- panic("internal socket directory is missing")
- }
-
- return filepath.Join(socketDir, fmt.Sprintf("ruby.%d", id))
-}
-
// Server represents a gitaly-ruby helper process.
type Server struct {
startOnce sync.Once
@@ -101,7 +92,7 @@ func (s *Server) start() error {
"GITALY_RUBY_DIR="+cfg.Ruby.Dir,
"GITALY_VERSION="+version.GetVersion(),
"GITALY_GIT_HOOKS_DIR="+hooks.Path(),
- "GITALY_SOCKET="+config.GitalyInternalSocketPath(),
+ "GITALY_SOCKET="+cfg.GitalyInternalSocketPath(),
"GITALY_TOKEN="+cfg.Auth.Token,
"GITALY_RUGGED_GIT_CONFIG_SEARCH_PATH="+cfg.Ruby.RuggedGitConfigSearchPath)
env = append(env, gitlabshellEnv...)
@@ -123,7 +114,7 @@ func (s *Server) start() error {
for i := 0; i < numWorkers; i++ {
name := fmt.Sprintf("gitaly-ruby.%d", i)
- socketPath := socketPath(i)
+ socketPath := filepath.Join(cfg.InternalSocketDir, fmt.Sprintf("ruby.%d", i))
// Use 'ruby-cd' to make sure gitaly-ruby has the same working directory
// as the current process. This is a hack to sort-of support relative
diff --git a/internal/gitaly/server/server.go b/internal/gitaly/server/server.go
index b46750fac..0cb14648a 100644
--- a/internal/gitaly/server/server.go
+++ b/internal/gitaly/server/server.go
@@ -3,7 +3,6 @@ package server
import (
"context"
"crypto/tls"
- "os"
"time"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
@@ -153,10 +152,3 @@ func NewInsecure(rubyServer *rubyserver.Server, hookManager hook.Manager, cfg co
func NewSecure(rubyServer *rubyserver.Server, hookManager hook.Manager, cfg config.Cfg, conns *client.Pool) *grpc.Server {
return createNewServer(rubyServer, hookManager, cfg, true, conns)
}
-
-// CleanupInternalSocketDir will clean up the directory for internal sockets if it is a generated temp dir
-func CleanupInternalSocketDir() {
- if tmpDir := config.GeneratedInternalSocketDir(); tmpDir != "" {
- os.RemoveAll(tmpDir)
- }
-}
diff --git a/internal/gitaly/server/server_factory.go b/internal/gitaly/server/server_factory.go
index e98e3a879..dfe526195 100644
--- a/internal/gitaly/server/server_factory.go
+++ b/internal/gitaly/server/server_factory.go
@@ -48,7 +48,7 @@ func (s *GitalyServerFactory) StartWorkers(ctx context.Context, l logrus.FieldLo
))
}
- cc, err := client.Dial("unix://"+config.GitalyInternalSocketPath(), opts)
+ cc, err := client.Dial("unix://"+cfg.GitalyInternalSocketPath(), opts)
if err != nil {
return nil, err
}
@@ -96,7 +96,6 @@ func (s *GitalyServerFactory) Stop() {
}
s.ruby.Stop()
- CleanupInternalSocketDir()
}
// GracefulStop stops both the secure and insecure servers gracefully
diff --git a/internal/gitaly/service/blob/testhelper_test.go b/internal/gitaly/service/blob/testhelper_test.go
index 600ff98f2..6702407d5 100644
--- a/internal/gitaly/service/blob/testhelper_test.go
+++ b/internal/gitaly/service/blob/testhelper_test.go
@@ -6,6 +6,7 @@ import (
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/rubyserver"
"gitlab.com/gitlab-org/gitaly/internal/storage"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
@@ -25,7 +26,10 @@ func testMain(m *testing.M) int {
cleanup := testhelper.Configure()
defer cleanup()
- testhelper.ConfigureRuby()
+
+ if err := testhelper.ConfigureRuby(&config.Config); err != nil {
+ log.Fatal(err)
+ }
if err := rubyServer.Start(); err != nil {
log.Error(err)
diff --git a/internal/gitaly/service/operations/branches_test.go b/internal/gitaly/service/operations/branches_test.go
index 76ce28ebd..701025940 100644
--- a/internal/gitaly/service/operations/branches_test.go
+++ b/internal/gitaly/service/operations/branches_test.go
@@ -119,7 +119,7 @@ func testUserCreateBranchWithTransaction(t *testing.T, withRefTxHook bool) {
testRepo, testRepoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- internalSocket := config.GitalyInternalSocketPath()
+ internalSocket := config.Config.GitalyInternalSocketPath()
internalListener, err := net.Listen("unix", internalSocket)
require.NoError(t, err)
diff --git a/internal/gitaly/service/operations/merge.go b/internal/gitaly/service/operations/merge.go
index e953dd95b..73ce55c95 100644
--- a/internal/gitaly/service/operations/merge.go
+++ b/internal/gitaly/service/operations/merge.go
@@ -11,7 +11,6 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/updateref"
"gitlab.com/gitlab-org/gitaly/internal/git2go"
- "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/hook"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/rubyserver"
"gitlab.com/gitlab-org/gitaly/internal/gitlabshell"
@@ -122,7 +121,7 @@ func (s *server) updateReferenceWithHooks(ctx context.Context, repo *gitalypb.Re
fmt.Sprintf("GL_USERNAME=%s", user.GetGlUsername()),
fmt.Sprintf("GL_REPOSITORY=%s", repo.GetGlRepository()),
fmt.Sprintf("GL_PROJECT_PATH=%s", repo.GetGlProjectPath()),
- fmt.Sprintf("GITALY_SOCKET=" + config.GitalyInternalSocketPath()),
+ fmt.Sprintf("GITALY_SOCKET=" + s.cfg.GitalyInternalSocketPath()),
fmt.Sprintf("GITALY_REPO=%s", repo),
fmt.Sprintf("GITALY_TOKEN=%s", s.cfg.Auth.Token),
}, gitlabshellEnv...)
diff --git a/internal/gitaly/service/operations/testhelper_test.go b/internal/gitaly/service/operations/testhelper_test.go
index 47567c886..029f0591d 100644
--- a/internal/gitaly/service/operations/testhelper_test.go
+++ b/internal/gitaly/service/operations/testhelper_test.go
@@ -90,7 +90,7 @@ func runOperationServiceServer(t *testing.T) (string, func()) {
func runOperationServiceServerWithRubyServer(t *testing.T, ruby *rubyserver.Server) (string, func()) {
srv := testhelper.NewServerWithAuth(t, nil, nil, config.Config.Auth.Token)
- internalSocket := config.GitalyInternalSocketPath()
+ internalSocket := config.Config.GitalyInternalSocketPath()
internalListener, err := net.Listen("unix", internalSocket)
require.NoError(t, err)
diff --git a/internal/gitaly/service/register.go b/internal/gitaly/service/register.go
index c609346ce..ed6aed76a 100644
--- a/internal/gitaly/service/register.go
+++ b/internal/gitaly/service/register.go
@@ -76,7 +76,7 @@ func RegisterAll(grpcServer *grpc.Server, cfg config.Cfg, rubyServer *rubyserver
gitalypb.RegisterNamespaceServiceServer(grpcServer, namespace.NewServer(locator))
gitalypb.RegisterOperationServiceServer(grpcServer, operations.NewServer(cfg, rubyServer, hookManager, locator, conns))
gitalypb.RegisterRefServiceServer(grpcServer, ref.NewServer(locator))
- gitalypb.RegisterRepositoryServiceServer(grpcServer, repository.NewServer(cfg, rubyServer, locator, config.GitalyInternalSocketPath()))
+ gitalypb.RegisterRepositoryServiceServer(grpcServer, repository.NewServer(cfg, rubyServer, locator, cfg.GitalyInternalSocketPath()))
gitalypb.RegisterSSHServiceServer(grpcServer, ssh.NewServer(
locator,
ssh.WithPackfileNegotiationMetrics(sshPackfileNegotiationMetrics),
diff --git a/internal/gitaly/service/repository/fetch_test.go b/internal/gitaly/service/repository/fetch_test.go
index f8ff12fd4..425ddf195 100644
--- a/internal/gitaly/service/repository/fetch_test.go
+++ b/internal/gitaly/service/repository/fetch_test.go
@@ -394,7 +394,7 @@ func runFullServer(t *testing.T) (string, func()) {
require.NoError(t, err)
//listen on internal socket
- internalListener, err := net.Listen("unix", config.GitalyInternalSocketPath())
+ internalListener, err := net.Listen("unix", config.Config.GitalyInternalSocketPath())
require.NoError(t, err)
go server.Serve(internalListener)
diff --git a/internal/gitaly/service/repository/replicate_test.go b/internal/gitaly/service/repository/replicate_test.go
index bd71e6e8e..7ac3c1f96 100644
--- a/internal/gitaly/service/repository/replicate_test.go
+++ b/internal/gitaly/service/repository/replicate_test.go
@@ -319,10 +319,10 @@ func runServerWithBadFetchInternalRemote(t *testing.T) (*grpc.Server, string) {
listener, err := net.Listen("unix", serverSocketPath)
require.NoError(t, err)
- internalListener, err := net.Listen("unix", config.GitalyInternalSocketPath())
+ internalListener, err := net.Listen("unix", config.Config.GitalyInternalSocketPath())
require.NoError(t, err)
- gitalypb.RegisterRepositoryServiceServer(server, repository.NewServer(config.Config, repository.RubyServer, config.NewLocator(config.Config), config.GitalyInternalSocketPath()))
+ gitalypb.RegisterRepositoryServiceServer(server, repository.NewServer(config.Config, repository.RubyServer, config.NewLocator(config.Config), config.Config.GitalyInternalSocketPath()))
gitalypb.RegisterRemoteServiceServer(server, &mockRemoteServer{})
reflection.Register(server)
diff --git a/internal/gitaly/service/repository/search_files_test.go b/internal/gitaly/service/repository/search_files_test.go
index 3aba2e20c..e80369da6 100644
--- a/internal/gitaly/service/repository/search_files_test.go
+++ b/internal/gitaly/service/repository/search_files_test.go
@@ -212,7 +212,7 @@ func TestSearchFilesByContentLargeFile(t *testing.T) {
}
func TestSearchFilesByContentFailure(t *testing.T) {
- server := NewServer(config.Config, RubyServer, config.NewLocator(config.Config), config.GitalyInternalSocketPath())
+ server := NewServer(config.Config, RubyServer, config.NewLocator(config.Config), config.Config.GitalyInternalSocketPath())
testRepo, _, cleanupRepo := testhelper.NewTestRepo(t)
defer cleanupRepo()
@@ -334,7 +334,7 @@ func TestSearchFilesByNameSuccessful(t *testing.T) {
}
func TestSearchFilesByNameFailure(t *testing.T) {
- server := NewServer(config.Config, RubyServer, config.NewLocator(config.Config), config.GitalyInternalSocketPath())
+ server := NewServer(config.Config, RubyServer, config.NewLocator(config.Config), config.Config.GitalyInternalSocketPath())
testCases := []struct {
desc string
diff --git a/internal/gitaly/service/repository/testhelper_test.go b/internal/gitaly/service/repository/testhelper_test.go
index aea1a3b21..9095225ff 100644
--- a/internal/gitaly/service/repository/testhelper_test.go
+++ b/internal/gitaly/service/repository/testhelper_test.go
@@ -106,7 +106,7 @@ func runRepoServerWithConfig(t *testing.T, cfg config.Cfg, locator storage.Locat
srv := testhelper.NewServerWithAuth(t, streamInt, unaryInt, cfg.Auth.Token, opts...)
- gitalypb.RegisterRepositoryServiceServer(srv.GrpcServer(), NewServer(cfg, RubyServer, locator, config.GitalyInternalSocketPath()))
+ gitalypb.RegisterRepositoryServiceServer(srv.GrpcServer(), NewServer(cfg, RubyServer, locator, config.Config.GitalyInternalSocketPath()))
reflection.Register(srv.GrpcServer())
require.NoError(t, srv.Start())
diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go
index 9c719ee74..82bb8a995 100644
--- a/internal/gitaly/service/smarthttp/receive_pack_test.go
+++ b/internal/gitaly/service/smarthttp/receive_pack_test.go
@@ -439,7 +439,7 @@ func runSmartHTTPHookServiceServer(t *testing.T) (*grpc.Server, string) {
if err != nil {
t.Fatal(err)
}
- internalListener, err := net.Listen("unix", config.GitalyInternalSocketPath())
+ internalListener, err := net.Listen("unix", config.Config.GitalyInternalSocketPath())
if err != nil {
t.Fatal(err)
}
@@ -512,7 +512,7 @@ func TestPostReceiveWithTransactionsViaPraefect(t *testing.T) {
require.NoError(t, gitalyServer.Start())
defer gitalyServer.Stop()
- internalSocket := config.GitalyInternalSocketPath()
+ internalSocket := config.Config.GitalyInternalSocketPath()
internalListener, err := net.Listen("unix", internalSocket)
require.NoError(t, err)
@@ -562,7 +562,7 @@ func TestPostReceiveWithReferenceTransactionHook(t *testing.T) {
listener, err := net.Listen("unix", gitalySocketPath)
require.NoError(t, err)
- internalListener, err := net.Listen("unix", config.GitalyInternalSocketPath())
+ internalListener, err := net.Listen("unix", config.Config.GitalyInternalSocketPath())
require.NoError(t, err)
go gitalyServer.Serve(listener)
diff --git a/internal/gitlabshell/env_test.go b/internal/gitlabshell/env_test.go
index 88c667300..ff5627a4a 100644
--- a/internal/gitlabshell/env_test.go
+++ b/internal/gitlabshell/env_test.go
@@ -14,12 +14,12 @@ import (
)
func TestGitHooksConfig(t *testing.T) {
- testhelper.ConfigureRuby()
-
defer func(cfg config.Cfg) {
config.Config = cfg
}(config.Config)
+ require.NoError(t, testhelper.ConfigureRuby(&config.Config))
+
loggingDir, err := ioutil.TempDir("", t.Name())
require.NoError(t, err)
defer func() { os.RemoveAll(loggingDir) }()
diff --git a/internal/praefect/helper_test.go b/internal/praefect/helper_test.go
index 7e5ac3f97..7da736dad 100644
--- a/internal/praefect/helper_test.go
+++ b/internal/praefect/helper_test.go
@@ -146,10 +146,10 @@ func flattenVirtualStoragesToStoragePath(virtualStorages []*config.VirtualStorag
// withRealGitalyShared will configure a real Gitaly server backend for a
// Praefect server. The same Gitaly server instance is used for all backend
// storages.
-func withRealGitalyShared(t testing.TB) func([]*config.VirtualStorage) []testhelper.Cleanup {
+func withRealGitalyShared(t testing.TB, cfg gconfig.Cfg) func([]*config.VirtualStorage) []testhelper.Cleanup {
return func(virtualStorages []*config.VirtualStorage) []testhelper.Cleanup {
gStorages := flattenVirtualStoragesToStoragePath(virtualStorages, testhelper.GitlabTestStoragePath())
- _, backendAddr, cleanupGitaly := testserver.RunInternalGitalyServer(t, gStorages, virtualStorages[0].Nodes[0].Token)
+ _, backendAddr, cleanupGitaly := testserver.RunInternalGitalyServer(t, cfg.GitalyInternalSocketPath(), gStorages, virtualStorages[0].Nodes[0].Token)
for _, vs := range virtualStorages {
for i, node := range vs.Nodes {
@@ -162,17 +162,17 @@ func withRealGitalyShared(t testing.TB) func([]*config.VirtualStorage) []testhel
}
}
-func runPraefectServerWithGitaly(t *testing.T, conf config.Config) (*grpc.ClientConn, *grpc.Server, testhelper.Cleanup) {
- return runPraefectServerWithGitalyWithDatastore(t, conf, defaultQueue(conf))
+func runPraefectServerWithGitaly(t *testing.T, cfg gconfig.Cfg, conf config.Config) (*grpc.ClientConn, *grpc.Server, testhelper.Cleanup) {
+ return runPraefectServerWithGitalyWithDatastore(t, cfg, conf, defaultQueue(conf))
}
// runPraefectServerWithGitaly runs a praefect server with actual Gitaly nodes
// requires exactly 1 virtual storage
-func runPraefectServerWithGitalyWithDatastore(t *testing.T, conf config.Config, queue datastore.ReplicationEventQueue) (*grpc.ClientConn, *grpc.Server, testhelper.Cleanup) {
+func runPraefectServerWithGitalyWithDatastore(t *testing.T, cfg gconfig.Cfg, conf config.Config, queue datastore.ReplicationEventQueue) (*grpc.ClientConn, *grpc.Server, testhelper.Cleanup) {
return runPraefectServer(t, conf, buildOptions{
withQueue: queue,
withTxMgr: transactions.NewManager(conf),
- withBackends: withRealGitalyShared(t),
+ withBackends: withRealGitalyShared(t, cfg),
})
}
diff --git a/internal/praefect/info_service_test.go b/internal/praefect/info_service_test.go
index 8d59575bd..625e6428c 100644
--- a/internal/praefect/info_service_test.go
+++ b/internal/praefect/info_service_test.go
@@ -50,7 +50,7 @@ func TestInfoService_RepositoryReplicas(t *testing.T) {
testRepo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- cc, _, cleanup := runPraefectServerWithGitaly(t, conf)
+ cc, _, cleanup := runPraefectServerWithGitaly(t, gconfig.Config, conf)
defer cleanup()
testRepoPrimary, _, cleanup := cloneRepoAtStorage(t, testRepo, conf.VirtualStorages[0].Nodes[0].Storage)
diff --git a/internal/praefect/replicator_test.go b/internal/praefect/replicator_test.go
index 2629cad84..d51d98202 100644
--- a/internal/praefect/replicator_test.go
+++ b/internal/praefect/replicator_test.go
@@ -979,7 +979,7 @@ func runFullGitalyServer(t *testing.T) (string, func()) {
t.Fatal(err)
}
//listen on internal socket
- internalListener, err := net.Listen("unix", gitaly_config.GitalyInternalSocketPath())
+ internalListener, err := net.Listen("unix", gitaly_config.Config.GitalyInternalSocketPath())
require.NoError(t, err)
go server.Serve(listener)
@@ -995,7 +995,7 @@ func runFullGitalyServer(t *testing.T) (string, func()) {
// are the only ones needed for replication
func newReplicationService(tb testing.TB) (*grpc.Server, string) {
socketName := testhelper.GetTemporaryGitalySocketFileName()
- internalSocketName := gitaly_config.GitalyInternalSocketPath()
+ internalSocketName := gitaly_config.Config.GitalyInternalSocketPath()
require.NoError(tb, os.RemoveAll(internalSocketName))
svr := testhelper.NewTestGrpcServer(tb, nil, nil)
diff --git a/internal/praefect/server_factory_test.go b/internal/praefect/server_factory_test.go
index a7f260b5f..b30075618 100644
--- a/internal/praefect/server_factory_test.go
+++ b/internal/praefect/server_factory_test.go
@@ -39,7 +39,7 @@ func TestServerFactory(t *testing.T) {
go gitalyServerFactory.Serve(gitalyListener, false)
// start gitaly serving on internal endpoint
- gitalyInternalSocketPath := gconfig.GitalyInternalSocketPath()
+ gitalyInternalSocketPath := gconfig.Config.GitalyInternalSocketPath()
defer func() { require.NoError(t, os.RemoveAll(gitalyInternalSocketPath)) }()
gitalyInternalListener, err := net.Listen(starter.Unix, gitalyInternalSocketPath)
require.NoError(t, err)
diff --git a/internal/praefect/server_test.go b/internal/praefect/server_test.go
index 58579da4d..f5f349e69 100644
--- a/internal/praefect/server_test.go
+++ b/internal/praefect/server_test.go
@@ -72,7 +72,7 @@ func TestGitalyServerInfo(t *testing.T) {
}
t.Run("gitaly responds with ok", func(t *testing.T) {
- cc, _, cleanup := runPraefectServerWithGitaly(t, conf)
+ cc, _, cleanup := runPraefectServerWithGitaly(t, gconfig.Config, conf)
defer cleanup()
expected := &gitalypb.ServerInfoResponse{
@@ -158,7 +158,7 @@ func TestGitalyDiskStatistics(t *testing.T) {
},
}
- cc, _, cleanup := runPraefectServerWithGitaly(t, conf)
+ cc, _, cleanup := runPraefectServerWithGitaly(t, gconfig.Config, conf)
defer cleanup()
client := gitalypb.NewServerServiceClient(cc)
@@ -176,7 +176,7 @@ func TestGitalyDiskStatistics(t *testing.T) {
}
func TestHealthCheck(t *testing.T) {
- cc, _, cleanup := runPraefectServerWithGitaly(t, testConfig(1))
+ cc, _, cleanup := runPraefectServerWithGitaly(t, gconfig.Config, testConfig(1))
defer cleanup()
ctx, cancel := testhelper.Context(testhelper.ContextWithTimeout(time.Second))
@@ -202,7 +202,7 @@ func TestRejectBadStorage(t *testing.T) {
},
}
- cc, _, cleanup := runPraefectServerWithGitaly(t, conf)
+ cc, _, cleanup := runPraefectServerWithGitaly(t, gconfig.Config, conf)
defer cleanup()
badTargetRepo := gitalypb.Repository{
@@ -414,7 +414,7 @@ func TestRepoRemoval(t *testing.T) {
return queue.Acknowledge(ctx, state, ids)
})
- cc, _, cleanup := runPraefectServerWithGitalyWithDatastore(t, conf, queueInterceptor)
+ cc, _, cleanup := runPraefectServerWithGitalyWithDatastore(t, gconfig.Config, conf, queueInterceptor)
defer cleanup()
ctx, cancel := testhelper.Context()
@@ -530,7 +530,7 @@ func TestRepoRename(t *testing.T) {
return queue.Acknowledge(ctx, state, ids)
})
- cc, _, cleanup := runPraefectServerWithGitalyWithDatastore(t, conf, evq)
+ cc, _, cleanup := runPraefectServerWithGitalyWithDatastore(t, gconfig.Config, conf, evq)
defer cleanup()
ctx, cancel := testhelper.Context()
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index cdfbec1f5..7389ef7ea 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -110,9 +110,9 @@ func Configure() func() {
}
for _, f := range []func() error{
- ConfigureRuby,
+ func() error { return ConfigureRuby(&config.Config) },
ConfigureGit,
- config.Validate,
+ func() error { return config.Config.Validate() },
} {
if err := f(); err != nil {
os.RemoveAll(testDirectory)
@@ -369,19 +369,19 @@ func ConfigureGit() error {
}
// ConfigureRuby configures Ruby settings for test purposes at run time.
-func ConfigureRuby() error {
+func ConfigureRuby(cfg *config.Cfg) error {
if dir := os.Getenv("GITALY_TEST_RUBY_DIR"); len(dir) > 0 {
// Sometimes runtime.Caller is unreliable. This environment variable provides a bypass.
- config.Config.Ruby.Dir = dir
+ cfg.Ruby.Dir = dir
} else {
_, currentFile, _, ok := runtime.Caller(0)
if !ok {
return fmt.Errorf("could not get caller info")
}
- config.Config.Ruby.Dir = filepath.Join(filepath.Dir(currentFile), "../../ruby")
+ cfg.Ruby.Dir = filepath.Join(filepath.Dir(currentFile), "../../ruby")
}
- if err := config.ConfigureRuby(); err != nil {
+ if err := cfg.ConfigureRuby(); err != nil {
log.Fatalf("validate ruby config: %v", err)
}
diff --git a/internal/testhelper/testserver/gitaly.go b/internal/testhelper/testserver/gitaly.go
index 5f3e950d1..3e64e0bc3 100644
--- a/internal/testhelper/testserver/gitaly.go
+++ b/internal/testhelper/testserver/gitaly.go
@@ -58,7 +58,7 @@ func RealGitaly(storages []config.Storage, authToken, internalSocketPath string)
}
}
-func RunInternalGitalyServer(t testing.TB, storages []config.Storage, token string) (*grpc.Server, string, func()) {
+func RunInternalGitalyServer(t testing.TB, internalSocketPath string, storages []config.Storage, token string) (*grpc.Server, string, func()) {
streamInt := []grpc.StreamServerInterceptor{auth.StreamServerInterceptor(internalauth.Config{Token: token})}
unaryInt := []grpc.UnaryServerInterceptor{auth.UnaryServerInterceptor(internalauth.Config{Token: token})}
@@ -68,7 +68,6 @@ func RunInternalGitalyServer(t testing.TB, storages []config.Storage, token stri
listener, err := net.Listen("unix", serverSocketPath)
require.NoError(t, err)
- internalSocketPath := config.GitalyInternalSocketPath()
internalListener, err := net.Listen("unix", internalSocketPath)
require.NoError(t, err)