diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2019-01-17 04:57:35 +0300 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2019-03-01 17:49:20 +0300 |
commit | 1592b5830f7b2847dff02ef2c66b745cdc60565a (patch) | |
tree | 27066c127717d21ed67f8081c3a6f3ef0332d178 /spec/lib/gitlab/hashed_storage | |
parent | ff2ca3569e704bb26c770ba5c28a888789d27230 (diff) |
Adds Rollback functionality to HashedStorage migration
We are adding sidekiq workers and service classes to allow to rollback
a hashed storage migration. There are some refactoring involved as well
as part of the code can be reused by both the migration and the rollback
logic.
Diffstat (limited to 'spec/lib/gitlab/hashed_storage')
-rw-r--r-- | spec/lib/gitlab/hashed_storage/migrator_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/lib/gitlab/hashed_storage/migrator_spec.rb b/spec/lib/gitlab/hashed_storage/migrator_spec.rb index 3942f168ceb..7c2582bb27a 100644 --- a/spec/lib/gitlab/hashed_storage/migrator_spec.rb +++ b/spec/lib/gitlab/hashed_storage/migrator_spec.rb @@ -88,4 +88,50 @@ describe Gitlab::HashedStorage::Migrator do end end end + + describe '#rollback' do + let(:project) { create(:project, :empty_repo) } + + it 'enqueues project rollback job' do + Sidekiq::Testing.fake! do + expect { subject.rollback(project) }.to change(ProjectRollbackHashedStorageWorker.jobs, :size).by(1) + end + end + + it 'rescues and log exceptions' do + allow(project).to receive(:rollback_to_hashed_storage!).and_raise(StandardError) + + expect { subject.rollback(project) }.not_to raise_error + end + + it 'rolls-back project storage' do + perform_enqueued_jobs do + subject.rollback(project) + end + + expect(project.reload.legacy_storage?).to be_truthy + end + + it 'has rolled-back project set as writable' do + perform_enqueued_jobs do + subject.rollback(project) + end + + expect(project.reload.repository_read_only?).to be_falsey + end + + context 'when project is already on legacy storage' do + let(:project) { create(:project, :legacy_storage, :empty_repo) } + + it 'doesnt enqueue any rollback job' do + Sidekiq::Testing.fake! do + expect { subject.rollback(project) }.not_to change(ProjectRollbackHashedStorageWorker.jobs, :size) + end + end + + it 'returns false' do + expect(subject.rollback(project)).to be_falsey + end + end + end end |