diff options
author | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2018-03-05 21:33:46 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <zegerjan@gitlab.com> | 2018-03-05 21:33:46 +0300 |
commit | 3b751d3116d21ed1a8739bfa2855a8ff23dea3b5 (patch) | |
tree | 30a4d849d1b48181dbf0e17be63abd3583f1e4c7 /internal/config | |
parent | 37c8b66e3ad87e68d18c677f0155fc01c8e6d4cb (diff) |
Use only 1 gitaly-ruby process in test
Diffstat (limited to 'internal/config')
-rw-r--r-- | internal/config/config_test.go | 25 | ||||
-rw-r--r-- | internal/config/ruby.go | 6 |
2 files changed, 31 insertions, 0 deletions
diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 3e50a8e64..cdd8f3561 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -2,6 +2,7 @@ package config import ( "bytes" + "fmt" "io" "io/ioutil" "os" @@ -381,6 +382,30 @@ func TestConfigureRuby(t *testing.T) { } } +func TestConfigureRubyNumWorkers(t *testing.T) { + defer func(oldRuby Ruby) { + Config.Ruby = oldRuby + }(Config.Ruby) + + testCases := []struct { + in, out int + }{ + {in: -1, out: 2}, + {in: 0, out: 2}, + {in: 1, out: 2}, + {in: 2, out: 2}, + {in: 3, out: 3}, + } + + 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) + }) + } +} + func TestValidateListeners(t *testing.T) { defer func(cfg config) { Config = cfg diff --git a/internal/config/ruby.go b/internal/config/ruby.go index 4d65939b2..462dd93a6 100644 --- a/internal/config/ruby.go +++ b/internal/config/ruby.go @@ -13,6 +13,7 @@ type Ruby struct { GracefulRestartTimeoutToml duration `toml:"graceful_restart_timeout"` RestartDelay time.Duration RestartDelayToml duration `toml:"restart_delay"` + NumWorkers int `toml:"num_workers"` } // This type is a trick to let our TOML library parse durations from strings. @@ -46,5 +47,10 @@ func ConfigureRuby() error { return fmt.Errorf("gitaly-ruby.dir is not set") } + minWorkers := 2 + if Config.Ruby.NumWorkers < minWorkers { + Config.Ruby.NumWorkers = minWorkers + } + return validateIsDirectory(Config.Ruby.Dir, "gitaly-ruby.dir") } |