From 6f1e9f7ef773ead892a1d43ec15a38dfb486e229 Mon Sep 17 00:00:00 2001 From: "Jacob Vosmaer (GitLab)" Date: Tue, 21 Nov 2017 12:28:02 +0000 Subject: Fix slow gitaly dev test bundle --- spec/tasks/gitlab/gitaly_rake_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/tasks') diff --git a/spec/tasks/gitlab/gitaly_rake_spec.rb b/spec/tasks/gitlab/gitaly_rake_spec.rb index 5dd8fe8eaa5..255f0a37ec8 100644 --- a/spec/tasks/gitlab/gitaly_rake_spec.rb +++ b/spec/tasks/gitlab/gitaly_rake_spec.rb @@ -57,7 +57,7 @@ describe 'gitlab:gitaly namespace rake task' 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(main_object).to receive(:run_command!).with(command_preamble + %w[gmake BUNDLE_PATH=/fake/bundle_path]).and_return(true) + expect(main_object).to receive(:run_command!).with(command_preamble + %w[gmake BUNDLE_FLAGS=--no-deployment]).and_return(true) run_rake_task('gitlab:gitaly:install', clone_path) end @@ -70,7 +70,7 @@ describe 'gitlab:gitaly namespace rake task' do end it 'calls make in the gitaly directory' do - expect(main_object).to receive(:run_command!).with(command_preamble + %w[make BUNDLE_PATH=/fake/bundle_path]).and_return(true) + expect(main_object).to receive(:run_command!).with(command_preamble + %w[make BUNDLE_FLAGS=--no-deployment]).and_return(true) run_rake_task('gitlab:gitaly:install', clone_path) end -- cgit v1.2.3 From c33ca9d807a70be51afea2692b7191d7790edd6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rodr=C3=ADguez?= Date: Tue, 21 Nov 2017 17:45:36 +0000 Subject: Use `make install` for Gitaly setups in non-test environments --- spec/tasks/gitlab/gitaly_rake_spec.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'spec/tasks') diff --git a/spec/tasks/gitlab/gitaly_rake_spec.rb b/spec/tasks/gitlab/gitaly_rake_spec.rb index 255f0a37ec8..a51374e2645 100644 --- a/spec/tasks/gitlab/gitaly_rake_spec.rb +++ b/spec/tasks/gitlab/gitaly_rake_spec.rb @@ -47,7 +47,7 @@ describe 'gitlab:gitaly namespace rake task' do stub_env('CI', false) FileUtils.mkdir_p(clone_path) expect(Dir).to receive(:chdir).with(clone_path).and_call_original - allow(Bundler).to receive(:bundle_path).and_return('/fake/bundle_path') + allow(Rails.env).to receive(:test?).and_return(false) end context 'gmake is available' do @@ -57,7 +57,7 @@ describe 'gitlab:gitaly namespace rake task' 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(main_object).to receive(:run_command!).with(command_preamble + %w[gmake BUNDLE_FLAGS=--no-deployment]).and_return(true) + expect(main_object).to receive(:run_command!).with(command_preamble + %w[gmake]).and_return(true) run_rake_task('gitlab:gitaly:install', clone_path) end @@ -70,18 +70,20 @@ describe 'gitlab:gitaly namespace rake task' do end it 'calls make in the gitaly directory' do - expect(main_object).to receive(:run_command!).with(command_preamble + %w[make BUNDLE_FLAGS=--no-deployment]).and_return(true) + expect(main_object).to receive(:run_command!).with(command_preamble + %w[make]).and_return(true) run_rake_task('gitlab:gitaly:install', clone_path) end - context 'when Rails.env is not "test"' do + context 'when Rails.env is test' do + let(:command) { %w[make BUNDLE_FLAGS=--no-deployment] } + before do - allow(Rails.env).to receive(:test?).and_return(false) + allow(Rails.env).to receive(:test?).and_return(true) end - it 'calls make in the gitaly directory without BUNDLE_PATH' do - expect(main_object).to receive(:run_command!).with(command_preamble + ['make']).and_return(true) + it 'calls make in the gitaly directory with --no-deployment flag for bundle' do + expect(main_object).to receive(:run_command!).with(command_preamble + command).and_return(true) run_rake_task('gitlab:gitaly:install', clone_path) end -- cgit v1.2.3 From 5e861a052551d307e928fa0797a64d30da380eeb Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Tue, 21 Nov 2017 20:26:53 +0000 Subject: ignore hashed repos (for now) when using `rake gitlab:cleanup:repos` --- spec/tasks/gitlab/cleanup_rake_spec.rb | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 spec/tasks/gitlab/cleanup_rake_spec.rb (limited to 'spec/tasks') diff --git a/spec/tasks/gitlab/cleanup_rake_spec.rb b/spec/tasks/gitlab/cleanup_rake_spec.rb new file mode 100644 index 00000000000..641eccfd334 --- /dev/null +++ b/spec/tasks/gitlab/cleanup_rake_spec.rb @@ -0,0 +1,41 @@ +require 'rake_helper' + +describe 'gitlab:cleanup rake tasks' do + before do + Rake.application.rake_require 'tasks/gitlab/cleanup' + end + + context 'cleanup repositories' do + let(:gitaly_address) { Gitlab.config.repositories.storages.default.gitaly_address } + let(:storages) do + { + 'default' => { 'path' => Settings.absolute('tmp/tests/default_storage'), 'gitaly_address' => gitaly_address } + } + end + + before do + FileUtils.mkdir(Settings.absolute('tmp/tests/default_storage')) + allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) + end + + after do + FileUtils.rm_rf(Settings.absolute('tmp/tests/default_storage')) + end + + it 'moves it to an orphaned path' do + FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/broken/project.git')) + run_rake_task('gitlab:cleanup:repos') + repo_list = Dir['tmp/tests/default_storage/broken/*'] + + expect(repo_list.first).to include('+orphaned+') + end + + it 'ignores @hashed repos' do + FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git')) + + run_rake_task('gitlab:cleanup:repos') + + expect(Dir.exist?(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git'))).to be_truthy + end + end +end -- cgit v1.2.3 From 571f1dda17203d162dac65270a6b68366de1f101 Mon Sep 17 00:00:00 2001 From: "Jacob Vosmaer (GitLab)" Date: Wed, 22 Nov 2017 10:19:42 +0000 Subject: Add FetchSourceBranch Gitaly call --- spec/tasks/gitlab/gitaly_rake_spec.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'spec/tasks') diff --git a/spec/tasks/gitlab/gitaly_rake_spec.rb b/spec/tasks/gitlab/gitaly_rake_spec.rb index a51374e2645..6aba86fdc3c 100644 --- a/spec/tasks/gitlab/gitaly_rake_spec.rb +++ b/spec/tasks/gitlab/gitaly_rake_spec.rb @@ -112,6 +112,7 @@ describe 'gitlab:gitaly namespace rake task' do expected_output = <<~TOML # Gitaly storage configuration generated from #{Gitlab.config.source} on #{Time.current.to_s(:long)} # This is in TOML format suitable for use in Gitaly's config.toml file. + bin_dir = "tmp/tests/gitaly" socket_path = "/path/to/my.socket" [gitlab-shell] dir = "#{Gitlab.config.gitlab_shell.path}" -- cgit v1.2.3 From 17069a9547c14c53491af76035c06dc66b8d8049 Mon Sep 17 00:00:00 2001 From: digitalMoksha Date: Fri, 24 Nov 2017 19:29:25 +0100 Subject: ignore hashed repositories when doing rake gitlab:cleanup:dirs --- spec/tasks/gitlab/cleanup_rake_spec.rb | 47 ++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'spec/tasks') diff --git a/spec/tasks/gitlab/cleanup_rake_spec.rb b/spec/tasks/gitlab/cleanup_rake_spec.rb index 641eccfd334..647f40fa695 100644 --- a/spec/tasks/gitlab/cleanup_rake_spec.rb +++ b/spec/tasks/gitlab/cleanup_rake_spec.rb @@ -5,7 +5,8 @@ describe 'gitlab:cleanup rake tasks' do Rake.application.rake_require 'tasks/gitlab/cleanup' end - context 'cleanup repositories' do + describe 'cleanup' do + let(:gitaly_address) { Gitlab.config.repositories.storages.default.gitaly_address } let(:storages) do { @@ -22,20 +23,46 @@ describe 'gitlab:cleanup rake tasks' do FileUtils.rm_rf(Settings.absolute('tmp/tests/default_storage')) end - it 'moves it to an orphaned path' do - FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/broken/project.git')) - run_rake_task('gitlab:cleanup:repos') - repo_list = Dir['tmp/tests/default_storage/broken/*'] + describe 'cleanup:repos' do + before do + FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/broken/project.git')) + FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git')) + end + + it 'moves it to an orphaned path' do + run_rake_task('gitlab:cleanup:repos') + repo_list = Dir['tmp/tests/default_storage/broken/*'] + + expect(repo_list.first).to include('+orphaned+') + end + + it 'ignores @hashed repos' do + run_rake_task('gitlab:cleanup:repos') - expect(repo_list.first).to include('+orphaned+') + expect(Dir.exist?(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git'))).to be_truthy + end end - it 'ignores @hashed repos' do - FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git')) + describe 'cleanup:dirs' do + it 'removes missing namespaces' do + FileUtils.mkdir_p(Settings.absolute("tmp/tests/default_storage/namespace_1/project.git")) + FileUtils.mkdir_p(Settings.absolute("tmp/tests/default_storage/namespace_2/project.git")) + allow(Namespace).to receive(:pluck).and_return('namespace_1') + + stub_env('REMOVE', 'true') + run_rake_task('gitlab:cleanup:dirs') + + expect(Dir.exist?(Settings.absolute('tmp/tests/default_storage/namespace_1'))).to be_truthy + expect(Dir.exist?(Settings.absolute('tmp/tests/default_storage/namespace_2'))).to be_falsey + end + + it 'ignores @hashed directory' do + FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git')) - run_rake_task('gitlab:cleanup:repos') + run_rake_task('gitlab:cleanup:dirs') - expect(Dir.exist?(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git'))).to be_truthy + expect(Dir.exist?(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git'))).to be_truthy + end end end end -- cgit v1.2.3 From 02dd3b4ed1e15b37aad224ea3a36fc3606fa013d Mon Sep 17 00:00:00 2001 From: digitalMoksha Date: Fri, 24 Nov 2017 21:10:00 +0100 Subject: static analysis fix --- spec/tasks/gitlab/cleanup_rake_spec.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'spec/tasks') diff --git a/spec/tasks/gitlab/cleanup_rake_spec.rb b/spec/tasks/gitlab/cleanup_rake_spec.rb index 647f40fa695..9e746ceddd6 100644 --- a/spec/tasks/gitlab/cleanup_rake_spec.rb +++ b/spec/tasks/gitlab/cleanup_rake_spec.rb @@ -6,7 +6,6 @@ describe 'gitlab:cleanup rake tasks' do end describe 'cleanup' do - let(:gitaly_address) { Gitlab.config.repositories.storages.default.gitaly_address } let(:storages) do { -- cgit v1.2.3 From 03ac8d5d0b8331a2ecfae05137e02c78428fa899 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Thu, 7 Dec 2017 15:33:30 +0000 Subject: Remove Rugged::Repository#empty? --- spec/tasks/gitlab/backup_rake_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/tasks') diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb index bf2e11bc360..b41c3b3958a 100644 --- a/spec/tasks/gitlab/backup_rake_spec.rb +++ b/spec/tasks/gitlab/backup_rake_spec.rb @@ -212,7 +212,7 @@ describe 'gitlab:app namespace rake task' do # Avoid asking gitaly about the root ref (which will fail beacuse of the # mocked storages) - allow_any_instance_of(Repository).to receive(:empty_repo?).and_return(false) + allow_any_instance_of(Repository).to receive(:empty?).and_return(false) end after do -- cgit v1.2.3