Commit feb8974c authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '35941-fix-testing-issue-following-gitaly-install-fix' into 'master'

Unset the `RUBYOPT` env variable before installing `gitaly-ruby`

Closes #35941 and #35967

See merge request !13313
parents 079df312 21937a15
...@@ -21,7 +21,7 @@ namespace :gitlab do ...@@ -21,7 +21,7 @@ namespace :gitlab do
create_gitaly_configuration create_gitaly_configuration
# In CI we run scripts/gitaly-test-build instead of this command # In CI we run scripts/gitaly-test-build instead of this command
unless ENV['CI'].present? unless ENV['CI'].present?
Bundler.with_original_env { run_command!([command]) } Bundler.with_original_env { run_command!(%w[/usr/bin/env -u RUBYOPT] + [command]) }
end end
end end
end end
......
...@@ -63,8 +63,6 @@ module TestEnv ...@@ -63,8 +63,6 @@ module TestEnv
# See gitlab.yml.example test section for paths # See gitlab.yml.example test section for paths
# #
def init(opts = {}) def init(opts = {})
Rake.application.rake_require 'tasks/gitlab/helpers'
Rake::Task.define_task :environment
# Disable mailer for spinach tests # Disable mailer for spinach tests
disable_mailer if opts[:mailer] == false disable_mailer if opts[:mailer] == false
...@@ -124,41 +122,50 @@ module TestEnv ...@@ -124,41 +122,50 @@ module TestEnv
end end
def setup_gitlab_shell def setup_gitlab_shell
gitlab_shell_dir = File.dirname(Gitlab.config.gitlab_shell.path) puts "\n==> Setting up Gitlab Shell..."
gitlab_shell_needs_update = component_needs_update?(gitlab_shell_dir, start = Time.now
gitlab_shell_dir = Gitlab.config.gitlab_shell.path
shell_needs_update = component_needs_update?(gitlab_shell_dir,
Gitlab::Shell.version_required) Gitlab::Shell.version_required)
Rake.application.rake_require 'tasks/gitlab/shell' unless !shell_needs_update || system('rake', 'gitlab:shell:install')
unless !gitlab_shell_needs_update || Rake.application.invoke_task('gitlab:shell:install') puts "\nGitLab Shell failed to install, cleaning up #{gitlab_shell_dir}!\n"
FileUtils.rm_rf(gitlab_shell_dir) FileUtils.rm_rf(gitlab_shell_dir)
raise "Can't install gitlab-shell" exit 1
end end
puts " GitLab Shell setup in #{Time.now - start} seconds...\n"
end end
def setup_gitaly def setup_gitaly
puts "\n==> Setting up Gitaly..."
start = Time.now
socket_path = Gitlab::GitalyClient.address('default').sub(/\Aunix:/, '') socket_path = Gitlab::GitalyClient.address('default').sub(/\Aunix:/, '')
gitaly_dir = File.dirname(socket_path) gitaly_dir = File.dirname(socket_path)
if gitaly_dir_stale?(gitaly_dir) if gitaly_dir_stale?(gitaly_dir)
puts "rm -rf #{gitaly_dir}" puts " Gitaly is outdated, cleaning up #{gitaly_dir}!"
FileUtils.rm_rf(gitaly_dir) FileUtils.rm_rf(gitaly_dir)
end end
gitaly_needs_update = component_needs_update?(gitaly_dir, gitaly_needs_update = component_needs_update?(gitaly_dir,
Gitlab::GitalyClient.expected_server_version) Gitlab::GitalyClient.expected_server_version)
Rake.application.rake_require 'tasks/gitlab/gitaly' unless !gitaly_needs_update || system('rake', "gitlab:gitaly:install[#{gitaly_dir}]")
unless !gitaly_needs_update || Rake.application.invoke_task("gitlab:gitaly:install[#{gitaly_dir}]") puts "\nGitaly failed to install, cleaning up #{gitaly_dir}!\n"
FileUtils.rm_rf(gitaly_dir) FileUtils.rm_rf(gitaly_dir)
raise "Can't install gitaly" exit 1
end end
start_gitaly(gitaly_dir) start_gitaly(gitaly_dir)
puts " Gitaly setup in #{Time.now - start} seconds...\n"
end end
def gitaly_dir_stale?(dir) def gitaly_dir_stale?(dir)
gitaly_executable = File.join(dir, 'gitaly') gitaly_executable = File.join(dir, 'gitaly')
!File.exist?(gitaly_executable) || (File.mtime(gitaly_executable) < File.mtime(Rails.root.join('GITALY_SERVER_VERSION'))) return false unless File.exist?(gitaly_executable)
File.mtime(gitaly_executable) < File.mtime(Rails.root.join('GITALY_SERVER_VERSION'))
end end
def start_gitaly(gitaly_dir) def start_gitaly(gitaly_dir)
......
...@@ -41,6 +41,8 @@ describe 'gitlab:gitaly namespace rake task' do ...@@ -41,6 +41,8 @@ describe 'gitlab:gitaly namespace rake task' do
end end
describe 'gmake/make' do describe 'gmake/make' do
let(:command_preamble) { %w[/usr/bin/env -u RUBYOPT] }
before(:all) do before(:all) do
@old_env_ci = ENV.delete('CI') @old_env_ci = ENV.delete('CI')
end end
...@@ -57,12 +59,12 @@ describe 'gitlab:gitaly namespace rake task' do ...@@ -57,12 +59,12 @@ describe 'gitlab:gitaly namespace rake task' do
context 'gmake is available' do context 'gmake is available' do
before do before do
expect_any_instance_of(Object).to receive(:checkout_or_clone_version) expect_any_instance_of(Object).to receive(:checkout_or_clone_version)
allow_any_instance_of(Object).to receive(:run_command!).with(['gmake']).and_return(true) allow_any_instance_of(Object).to receive(:run_command!).with(command_preamble + ['gmake']).and_return(true)
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).with(%w[which gmake]).and_return(['/usr/bin/gmake', 0])
expect_any_instance_of(Object).to receive(:run_command!).with(['gmake']).and_return(true) expect_any_instance_of(Object).to receive(:run_command!).with(command_preamble + ['gmake']).and_return(true)
run_rake_task('gitlab:gitaly:install', clone_path) run_rake_task('gitlab:gitaly:install', clone_path)
end end
...@@ -71,12 +73,12 @@ describe 'gitlab:gitaly namespace rake task' do ...@@ -71,12 +73,12 @@ describe 'gitlab:gitaly namespace rake task' do
context 'gmake is not available' do context 'gmake is not available' do
before do before do
expect_any_instance_of(Object).to receive(:checkout_or_clone_version) expect_any_instance_of(Object).to receive(:checkout_or_clone_version)
allow_any_instance_of(Object).to receive(:run_command!).with(['make']).and_return(true) allow_any_instance_of(Object).to receive(:run_command!).with(command_preamble + ['make']).and_return(true)
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[which gmake]).and_return(['', 42]) expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(['', 42])
expect_any_instance_of(Object).to receive(:run_command!).with(['make']).and_return(true) expect_any_instance_of(Object).to receive(:run_command!).with(command_preamble + ['make']).and_return(true)
run_rake_task('gitlab:gitaly:install', clone_path) run_rake_task('gitlab:gitaly:install', clone_path)
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