summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-13 19:27:03 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-13 19:27:03 +0000
commit7f5f940041c8d1ee074be96cc64bdccdd95649b1 (patch)
tree334342b5d7c1898efcbe345c51838b63aa5106bc /spec/services
parentb16db1458f5e0f6b0427cf3e2471302657297427 (diff)
downloadgitlab-ce-7f5f940041c8d1ee074be96cc64bdccdd95649b1.tar.gz
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.4
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/projects/hashed_storage/migrate_repository_service_spec.rb36
-rw-r--r--spec/services/projects/hashed_storage/rollback_repository_service_spec.rb36
2 files changed, 72 insertions, 0 deletions
diff --git a/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb b/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb
index e03e75653ff..f0fd243f0ca 100644
--- a/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb
+++ b/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb
@@ -77,6 +77,42 @@ RSpec.describe Projects::HashedStorage::MigrateRepositoryService do
end
end
+ context 'when exception happens' do
+ it 'handles OpenSSL::Cipher::CipherError' do
+ expect(project).to receive(:ensure_runners_token).and_raise(OpenSSL::Cipher::CipherError)
+
+ expect { service.execute }.not_to raise_exception
+ end
+
+ it 'ensures rollback when OpenSSL::Cipher::CipherError' do
+ expect(project).to receive(:ensure_runners_token).and_raise(OpenSSL::Cipher::CipherError)
+ expect(service).to receive(:rollback_folder_move).and_call_original
+
+ service.execute
+ project.reload
+
+ expect(project.legacy_storage?).to be_truthy
+ expect(project.repository_read_only?).to be_falsey
+ end
+
+ it 'handles Gitlab::Git::CommandError' do
+ expect(project).to receive(:write_repository_config).and_raise(Gitlab::Git::CommandError)
+
+ expect { service.execute }.not_to raise_exception
+ end
+
+ it 'ensures rollback when Gitlab::Git::CommandError' do
+ expect(project).to receive(:write_repository_config).and_raise(Gitlab::Git::CommandError)
+ expect(service).to receive(:rollback_folder_move).and_call_original
+
+ service.execute
+ project.reload
+
+ expect(project.legacy_storage?).to be_truthy
+ expect(project.repository_read_only?).to be_falsey
+ end
+ end
+
context 'when one move fails' do
it 'rollsback repositories to original name' do
allow(service).to receive(:move_repository).and_call_original
diff --git a/spec/services/projects/hashed_storage/rollback_repository_service_spec.rb b/spec/services/projects/hashed_storage/rollback_repository_service_spec.rb
index f2b1ce30a54..492eb0956aa 100644
--- a/spec/services/projects/hashed_storage/rollback_repository_service_spec.rb
+++ b/spec/services/projects/hashed_storage/rollback_repository_service_spec.rb
@@ -77,6 +77,42 @@ RSpec.describe Projects::HashedStorage::RollbackRepositoryService, :clean_gitlab
end
end
+ context 'when exception happens' do
+ it 'handles OpenSSL::Cipher::CipherError' do
+ expect(project).to receive(:ensure_runners_token).and_raise(OpenSSL::Cipher::CipherError)
+
+ expect { service.execute }.not_to raise_exception
+ end
+
+ it 'ensures rollback when OpenSSL::Cipher::CipherError' do
+ expect(project).to receive(:ensure_runners_token).and_raise(OpenSSL::Cipher::CipherError)
+ expect(service).to receive(:rollback_folder_move).and_call_original
+
+ service.execute
+ project.reload
+
+ expect(project.hashed_storage?(:repository)).to be_truthy
+ expect(project.repository_read_only?).to be_falsey
+ end
+
+ it 'handles Gitlab::Git::CommandError' do
+ expect(project).to receive(:write_repository_config).and_raise(Gitlab::Git::CommandError)
+
+ expect { service.execute }.not_to raise_exception
+ end
+
+ it 'ensures rollback when Gitlab::Git::CommandError' do
+ expect(project).to receive(:write_repository_config).and_raise(Gitlab::Git::CommandError)
+ expect(service).to receive(:rollback_folder_move).and_call_original
+
+ service.execute
+ project.reload
+
+ expect(project.hashed_storage?(:repository)).to be_truthy
+ expect(project.repository_read_only?).to be_falsey
+ end
+ end
+
context 'when one move fails' do
it 'rolls repositories back to original name' do
allow(service).to receive(:move_repository).and_call_original