From 260935868acfb7c0cb720088d4f8c4c1c1088ddb Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 14 Dec 2017 11:49:35 +0100 Subject: add new git fsck rake task and spec --- spec/tasks/gitlab/git_rake_spec.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 spec/tasks/gitlab/git_rake_spec.rb (limited to 'spec/tasks') diff --git a/spec/tasks/gitlab/git_rake_spec.rb b/spec/tasks/gitlab/git_rake_spec.rb new file mode 100644 index 00000000000..63a7f7efe73 --- /dev/null +++ b/spec/tasks/gitlab/git_rake_spec.rb @@ -0,0 +1,27 @@ +require 'rake_helper' + +describe 'gitlab:git rake tasks' do + before do + Rake.application.rake_require 'tasks/gitlab/git' + + stub_warn_user_is_not_gitlab + + FileUtils.mkdir(Settings.absolute('tmp/tests/default_storage')) + end + + after do + FileUtils.rm_rf(Settings.absolute('tmp/tests/default_storage')) + end + + describe 'fsck' do + let(:storages) do + { 'default' => { 'path' => Settings.absolute('tmp/tests/default_storage') } } + end + + it 'outputs the right git command' do + expect(Kernel).to receive(:system).with('').and_return(true) + + run_rake_task('gitlab:git:fsck') + end + end +end -- cgit v1.2.3 From 7721e8dfca9d272376f58dcb03ff277aef0a9c31 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 14 Dec 2017 14:53:34 +0100 Subject: fix spec --- spec/tasks/gitlab/git_rake_spec.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'spec/tasks') diff --git a/spec/tasks/gitlab/git_rake_spec.rb b/spec/tasks/gitlab/git_rake_spec.rb index 63a7f7efe73..60b51186ceb 100644 --- a/spec/tasks/gitlab/git_rake_spec.rb +++ b/spec/tasks/gitlab/git_rake_spec.rb @@ -4,9 +4,11 @@ describe 'gitlab:git rake tasks' do before do Rake.application.rake_require 'tasks/gitlab/git' - stub_warn_user_is_not_gitlab + storages = { 'default' => { 'path' => Settings.absolute('tmp/tests/default_storage') } } - FileUtils.mkdir(Settings.absolute('tmp/tests/default_storage')) + FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/repo/test.git')) + allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) + stub_warn_user_is_not_gitlab end after do @@ -14,14 +16,8 @@ describe 'gitlab:git rake tasks' do end describe 'fsck' do - let(:storages) do - { 'default' => { 'path' => Settings.absolute('tmp/tests/default_storage') } } - end - it 'outputs the right git command' do - expect(Kernel).to receive(:system).with('').and_return(true) - - run_rake_task('gitlab:git:fsck') + expect { run_rake_task('gitlab:git:fsck') }.to output(/Performed Checking integrity/).to_stdout end end end -- cgit v1.2.3 From f8e1b44dc5d2a78676672dfc7d44c17e6defeda6 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Wed, 3 Jan 2018 14:51:04 +0100 Subject: add locks chek --- spec/tasks/gitlab/git_rake_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'spec/tasks') diff --git a/spec/tasks/gitlab/git_rake_spec.rb b/spec/tasks/gitlab/git_rake_spec.rb index 60b51186ceb..19d298fb36d 100644 --- a/spec/tasks/gitlab/git_rake_spec.rb +++ b/spec/tasks/gitlab/git_rake_spec.rb @@ -1,3 +1,5 @@ + + require 'rake_helper' describe 'gitlab:git rake tasks' do @@ -6,7 +8,7 @@ describe 'gitlab:git rake tasks' do storages = { 'default' => { 'path' => Settings.absolute('tmp/tests/default_storage') } } - FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/repo/test.git')) + FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@repo/1/2/test.git')) allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) stub_warn_user_is_not_gitlab end -- cgit v1.2.3 From 5b9e7773766eebbe73bb400025de002962532a7c Mon Sep 17 00:00:00 2001 From: James Lopez Date: Wed, 3 Jan 2018 15:32:16 +0100 Subject: add lock specs --- spec/tasks/gitlab/git_rake_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'spec/tasks') diff --git a/spec/tasks/gitlab/git_rake_spec.rb b/spec/tasks/gitlab/git_rake_spec.rb index 19d298fb36d..44a2607bea2 100644 --- a/spec/tasks/gitlab/git_rake_spec.rb +++ b/spec/tasks/gitlab/git_rake_spec.rb @@ -21,5 +21,18 @@ describe 'gitlab:git rake tasks' do it 'outputs the right git command' do expect { run_rake_task('gitlab:git:fsck') }.to output(/Performed Checking integrity/).to_stdout end + + it 'errors out about config.lock issues' do + FileUtils.touch(Settings.absolute('tmp/tests/default_storage/@repo/1/2/test.git/config.lock')) + + expect { run_rake_task('gitlab:git:fsck') }.to output(/file exists\? ... yes/).to_stdout + end + + it 'errors out about ref lock issues' do + FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@repo/1/2/test.git/refs/heads')) + FileUtils.touch(Settings.absolute('tmp/tests/default_storage/@repo/1/2/test.git/refs/heads/blah.lock')) + + expect { run_rake_task('gitlab:git:fsck') }.to output(/Ref lock files exist:/).to_stdout + end end end -- cgit v1.2.3 From de36a8e27961d4c2af43d0ac2d700a391c245353 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 4 Jan 2018 11:02:43 +0100 Subject: refactor spec, add docs --- spec/tasks/gitlab/git_rake_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'spec/tasks') diff --git a/spec/tasks/gitlab/git_rake_spec.rb b/spec/tasks/gitlab/git_rake_spec.rb index 44a2607bea2..dacc5dc5ae7 100644 --- a/spec/tasks/gitlab/git_rake_spec.rb +++ b/spec/tasks/gitlab/git_rake_spec.rb @@ -1,5 +1,3 @@ - - require 'rake_helper' describe 'gitlab:git rake tasks' do @@ -8,8 +6,10 @@ describe 'gitlab:git rake tasks' do storages = { 'default' => { 'path' => Settings.absolute('tmp/tests/default_storage') } } - FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@repo/1/2/test.git')) + FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@hashed/1/2/test.git')) allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) + allow_any_instance_of(String).to receive(:color) { |string, _color| string } + stub_warn_user_is_not_gitlab end @@ -18,19 +18,19 @@ describe 'gitlab:git rake tasks' do end describe 'fsck' do - it 'outputs the right git command' do - expect { run_rake_task('gitlab:git:fsck') }.to output(/Performed Checking integrity/).to_stdout + it 'outputs the integrity check for a repo' do + expect { run_rake_task('gitlab:git:fsck') }.to output(/Performed Checking integrity at .*@hashed\/1\/2\/test.git/).to_stdout end it 'errors out about config.lock issues' do - FileUtils.touch(Settings.absolute('tmp/tests/default_storage/@repo/1/2/test.git/config.lock')) + FileUtils.touch(Settings.absolute('tmp/tests/default_storage/@hashed/1/2/test.git/config.lock')) expect { run_rake_task('gitlab:git:fsck') }.to output(/file exists\? ... yes/).to_stdout end it 'errors out about ref lock issues' do - FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@repo/1/2/test.git/refs/heads')) - FileUtils.touch(Settings.absolute('tmp/tests/default_storage/@repo/1/2/test.git/refs/heads/blah.lock')) + FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@hashed/1/2/test.git/refs/heads')) + FileUtils.touch(Settings.absolute('tmp/tests/default_storage/@hashed/1/2/test.git/refs/heads/blah.lock')) expect { run_rake_task('gitlab:git:fsck') }.to output(/Ref lock files exist:/).to_stdout end -- cgit v1.2.3