diff options
Diffstat (limited to 'scripts/gitaly_test.rb')
-rw-r--r-- | scripts/gitaly_test.rb | 37 |
1 files changed, 26 insertions, 11 deletions
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) |