Commit 36156a32 authored by Kamil Trzciński's avatar Kamil Trzciński

Surface gitaly compile error when running tests

Gitaly might error out when trying to compile for tests
which results in a cryptic `could not connect to tmp/tests/gitaly/gitaly.socket`.

This ensures that proper message is printed with the command execution output.
parent 1ac8a9d1
...@@ -67,7 +67,8 @@ Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]") ...@@ -67,7 +67,8 @@ Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]")
env["BUNDLE_DEPLOYMENT"] = 'false' env["BUNDLE_DEPLOYMENT"] = 'false'
end end
Gitlab::Popen.popen([make_cmd, 'all', 'git'], nil, env) output, status = Gitlab::Popen.popen([make_cmd, 'all', 'git'], nil, env)
raise "Gitaly failed to compile: #{output}" unless status&.zero?
end end
end end
end end
......
...@@ -67,21 +67,42 @@ RSpec.describe 'gitlab:gitaly namespace rake task', :silence_stdout do ...@@ -67,21 +67,42 @@ RSpec.describe 'gitlab:gitaly namespace rake task', :silence_stdout do
end end
it 'calls gmake in the gitaly directory' do it 'calls gmake in the gitaly directory' do
expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(['/usr/bin/gmake', 0]) expect(Gitlab::Popen).to receive(:popen)
expect(Gitlab::Popen).to receive(:popen).with(%w[gmake all git], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil }).and_return(true) .with(%w[which gmake])
.and_return(['/usr/bin/gmake', 0])
expect(Gitlab::Popen).to receive(:popen)
.with(%w[gmake all git], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil })
.and_return(['ok', 0])
subject subject
end end
context 'when gmake fails' do
it 'aborts process' do
expect(Gitlab::Popen).to receive(:popen)
.with(%w[which gmake])
.and_return(['/usr/bin/gmake', 0])
expect(Gitlab::Popen).to receive(:popen)
.with(%w[gmake all git], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil })
.and_return(['output', 1])
expect { subject }.to raise_error /Gitaly failed to compile: output/
end
end
end end
context 'gmake is not available' do context 'gmake is not available' do
before do before do
expect(main_object).to receive(:checkout_or_clone_version) expect(main_object).to receive(:checkout_or_clone_version)
expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(['', 42]) expect(Gitlab::Popen).to receive(:popen)
.with(%w[which gmake])
.and_return(['', 42])
end end
it 'calls make in the gitaly directory' do it 'calls make in the gitaly directory' do
expect(Gitlab::Popen).to receive(:popen).with(%w[make all git], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil }).and_return(true) expect(Gitlab::Popen).to receive(:popen)
.with(%w[make all git], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil })
.and_return(['output', 0])
subject subject
end end
...@@ -94,7 +115,9 @@ RSpec.describe 'gitlab:gitaly namespace rake task', :silence_stdout do ...@@ -94,7 +115,9 @@ RSpec.describe 'gitlab:gitaly namespace rake task', :silence_stdout do
end end
it 'calls make in the gitaly directory with BUNDLE_DEPLOYMENT and GEM_HOME variables' do it 'calls make in the gitaly directory with BUNDLE_DEPLOYMENT and GEM_HOME variables' do
expect(Gitlab::Popen).to receive(:popen).with(command, nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil, "BUNDLE_DEPLOYMENT" => 'false', "GEM_HOME" => Bundler.bundle_path.to_s }).and_return(true) expect(Gitlab::Popen).to receive(:popen)
.with(command, nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil, "BUNDLE_DEPLOYMENT" => 'false', "GEM_HOME" => Bundler.bundle_path.to_s })
.and_return(['/usr/bin/gmake', 0])
subject subject
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