Skip to content
代码片段 群组 项目
提交 f67778c0 编辑于 作者: 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.
上级 08fc9756
No related branches found
No related tags found
无相关合并请求
...@@ -9,16 +9,8 @@ class GitalyTestSpawn ...@@ -9,16 +9,8 @@ class GitalyTestSpawn
include GitalySetup include GitalySetup
def run def run
install_gitaly_gems if ENV['CI'] install_gitaly_gems
check_gitaly_config! spawn_gitaly
# # 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)
end end
end end
......
...@@ -285,25 +285,27 @@ def stop(pid) ...@@ -285,25 +285,27 @@ def stop(pid)
end end
def spawn_gitaly def spawn_gitaly
spawn_script = Rails.root.join('scripts/gitaly-test-spawn').to_s check_gitaly_config!
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
gitaly_pid = Integer(File.read(TMP_TEST_PATH.join('gitaly.pid'))) gitaly_pid = start_gitaly
gitaly2_pid = Integer(File.read(TMP_TEST_PATH.join('gitaly2.pid'))) gitaly2_pid = start_gitaly2
praefect_pid = Integer(File.read(TMP_TEST_PATH.join('praefect.pid'))) praefect_pid = start_praefect
Kernel.at_exit do 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 = [gitaly_pid, gitaly2_pid, praefect_pid]
pids.each { |pid| stop(pid) } pids.each { |pid| stop(pid) }
end end
wait('gitaly') wait('gitaly')
wait('praefect') wait('praefect')
rescue StandardError
message = 'gitaly spawn failed'
message += " (try `rm -rf #{gitaly_dir}` ?)" unless ENV['CI']
raise message
end end
end end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册