Commit f67778c0 authored by Toon Claes's avatar Toon Claes

test: Move spawning of Gitaly to GitalySetup

GitalySetup was shelling out to scripts/gitaly-test-spawn to spawn
Gitaly processes, which was quite complicated to understand.

This change simplifies the back-and-forth between the script and the
Ruby file. It avoids writing the PID of the Gitaly processes to file, to
pass them back to the test environment.

With the previous changes included, now scripts/gitaly-test-build &
scripts/gitaly-test-spawn are *only* used in CI. When running tests in a
local GDK, the Ruby code to build and spawn Gitaly in test is directly
called from TestEnv.init.
parent 08fc9756
......@@ -9,16 +9,8 @@ class GitalyTestSpawn
include GitalySetup
def run
install_gitaly_gems if ENV['CI']
check_gitaly_config!
# # Uncomment line below to see all gitaly logs merged into CI trace
# spawn('sleep 1; tail -f log/gitaly-test.log')
# In local development this pid file is used by rspec.
IO.write(File.expand_path('../tmp/tests/gitaly.pid', __dir__), start_gitaly)
IO.write(File.expand_path('../tmp/tests/gitaly2.pid', __dir__), start_gitaly2)
IO.write(File.expand_path('../tmp/tests/praefect.pid', __dir__), start_praefect)
install_gitaly_gems
spawn_gitaly
end
end
......
......@@ -285,25 +285,27 @@ module GitalySetup
end
def spawn_gitaly
spawn_script = Rails.root.join('scripts/gitaly-test-spawn').to_s
Bundler.with_original_env do
unless system(spawn_script)
message = 'gitaly spawn failed'
message += " (try `rm -rf #{gitaly_dir}` ?)" unless ENV['CI']
raise message
end
end
check_gitaly_config!
gitaly_pid = Integer(File.read(TMP_TEST_PATH.join('gitaly.pid')))
gitaly2_pid = Integer(File.read(TMP_TEST_PATH.join('gitaly2.pid')))
praefect_pid = Integer(File.read(TMP_TEST_PATH.join('praefect.pid')))
gitaly_pid = start_gitaly
gitaly2_pid = start_gitaly2
praefect_pid = start_praefect
Kernel.at_exit do
# In CI this function is called by scripts/gitaly-test-spawn, triggered a
# before_script. Gitaly needs to remain running until the container is
# stopped.
next if ENV['CI']
pids = [gitaly_pid, gitaly2_pid, praefect_pid]
pids.each { |pid| stop(pid) }
end
wait('gitaly')
wait('praefect')
rescue StandardError
message = 'gitaly spawn failed'
message += " (try `rm -rf #{gitaly_dir}` ?)" unless ENV['CI']
raise message
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment