diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 18:08:10 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 18:08:10 +0000 |
commit | 5d75b2b9a9d11c20667895e6aa68ea4e76658c5d (patch) | |
tree | 2aa529b0a153c805f5f4ecb357321a4e4f4c59cb /scripts | |
parent | 6f2065c468b05658125b746169c56764a8ccddb1 (diff) | |
download | gitlab-ce-5d75b2b9a9d11c20667895e6aa68ea4e76658c5d.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/gitaly-test-build | 7 | ||||
-rwxr-xr-x | scripts/gitaly-test-spawn | 5 | ||||
-rw-r--r-- | scripts/gitaly_test.rb | 37 |
3 files changed, 33 insertions, 16 deletions
diff --git a/scripts/gitaly-test-build b/scripts/gitaly-test-build index 374401caf89..fcf0049162b 100755 --- a/scripts/gitaly-test-build +++ b/scripts/gitaly-test-build @@ -17,13 +17,16 @@ class GitalyTestBuild check_gitaly_config! # Starting gitaly further validates its configuration - pid = start_gitaly - Process.kill('TERM', pid) + gitaly_pid = start_gitaly + praefect_pid = start_praefect + Process.kill('TERM', gitaly_pid) + Process.kill('TERM', praefect_pid) # Make the 'gitaly' executable look newer than 'GITALY_SERVER_VERSION'. # Without this a gitaly executable created in the setup-test-env job # will look stale compared to GITALY_SERVER_VERSION. FileUtils.touch(File.join(tmp_tests_gitaly_dir, 'gitaly'), mtime: Time.now + (1 << 24)) + FileUtils.touch(File.join(tmp_tests_gitaly_dir, 'praefect'), mtime: Time.now + (1 << 24)) end end diff --git a/scripts/gitaly-test-spawn b/scripts/gitaly-test-spawn index e9f91f75650..8e16b2bb656 100755 --- a/scripts/gitaly-test-spawn +++ b/scripts/gitaly-test-spawn @@ -13,10 +13,9 @@ class GitalyTestSpawn # # Uncomment line below to see all gitaly logs merged into CI trace # spawn('sleep 1; tail -f log/gitaly-test.log') - pid = start_gitaly - # In local development this pid file is used by rspec. - IO.write(File.expand_path('../tmp/tests/gitaly.pid', __dir__), pid) + IO.write(File.expand_path('../tmp/tests/gitaly.pid', __dir__), start_gitaly) + IO.write(File.expand_path('../tmp/tests/praefect.pid', __dir__), start_praefect) end end diff --git a/scripts/gitaly_test.rb b/scripts/gitaly_test.rb index 922dc17ed2e..8db47afdd4d 100644 --- a/scripts/gitaly_test.rb +++ b/scripts/gitaly_test.rb @@ -37,16 +37,31 @@ module GitalyTest env_hash end - def config_path - File.join(tmp_tests_gitaly_dir, 'config.toml') + def config_path(service) + case service + when :gitaly + File.join(tmp_tests_gitaly_dir, 'config.toml') + when :praefect + File.join(tmp_tests_gitaly_dir, 'praefect.config.toml') + end end def start_gitaly - args = %W[#{tmp_tests_gitaly_dir}/gitaly #{config_path}] - pid = spawn(env, *args, [:out, :err] => 'log/gitaly-test.log') + start(:gitaly) + end + + def start_praefect + start(:praefect) + end + + def start(service) + args = ["#{tmp_tests_gitaly_dir}/#{service}"] + args.push("-config") if service == :praefect + args.push(config_path(service)) + pid = spawn(env, *args, [:out, :err] => "log/#{service}-test.log") begin - try_connect! + try_connect!(service) rescue Process.kill('TERM', pid) raise @@ -68,11 +83,11 @@ module GitalyTest abort 'bundle check failed' unless system(env, 'bundle', 'check', chdir: File.dirname(gemfile)) end - def read_socket_path + def read_socket_path(service) # This code needs to work in an environment where we cannot use bundler, # so we cannot easily use the toml-rb gem. This ad-hoc parser should be # good enough. - config_text = IO.read(config_path) + config_text = IO.read(config_path(service)) config_text.lines.each do |line| match_data = line.match(/^\s*socket_path\s*=\s*"([^"]*)"$/) @@ -80,14 +95,14 @@ module GitalyTest return match_data[1] if match_data end - raise "failed to find socket_path in #{config_path}" + raise "failed to find socket_path in #{config_path(service)}" end - def try_connect! - print "Trying to connect to gitaly: " + def try_connect!(service) + print "Trying to connect to #{service}: " timeout = 20 delay = 0.1 - socket = read_socket_path + socket = read_socket_path(service) Integer(timeout / delay).times do UNIXSocket.new(socket) |