diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-31 12:08:33 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-31 12:08:33 +0000 |
commit | 1808454313ed75c92e1384466e8c83bfbc8ae25e (patch) | |
tree | 5c006c158fd796dc6d21e9bd771542f2fb0c24e2 /spec/services/projects | |
parent | fd3a95f07ae9cd78fecffcfa5de4494f933a7808 (diff) | |
download | gitlab-ce-1808454313ed75c92e1384466e8c83bfbc8ae25e.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/projects')
-rw-r--r-- | spec/services/projects/after_import_service_spec.rb | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/spec/services/projects/after_import_service_spec.rb b/spec/services/projects/after_import_service_spec.rb index 27e8f3c45ba..4f74a779cd5 100644 --- a/spec/services/projects/after_import_service_spec.rb +++ b/spec/services/projects/after_import_service_spec.rb @@ -20,7 +20,7 @@ describe Projects::AfterImportService do allow(housekeeping_service) .to receive(:execute).and_yield - expect(housekeeping_service).to receive(:increment!) + allow(housekeeping_service).to receive(:increment!) end it 'performs housekeeping' do @@ -58,6 +58,52 @@ describe Projects::AfterImportService do end end + context 'when after import action throw non-retriable exception' do + let(:exception) { StandardError.new('after import error') } + + before do + allow(repository) + .to receive(:delete_all_refs_except) + .and_raise(exception) + end + + it 'throws after import error' do + expect { subject.execute }.to raise_exception('after import error') + end + end + + context 'when after import action throw retriable exception one time' do + let(:exception) { GRPC::DeadlineExceeded.new } + + before do + call_count = 0 + + allow(repository).to receive(:delete_all_refs_except).and_wrap_original do |original_method, *args| + call_count += 1 + call_count > 1 ? original_method.call(*args) : raise(exception) + end + + subject.execute + end + + it 'removes refs/pull/**/*' do + expect(rugged.references.map(&:name)) + .not_to include(%r{\Arefs/pull/}) + end + + it 'records the failures in the database', :aggregate_failures do + import_failure = ImportFailure.last + + expect(import_failure.source).to eq('delete_all_refs') + expect(import_failure.project_id).to eq(project.id) + expect(import_failure.relation_key).to be_nil + expect(import_failure.relation_index).to be_nil + expect(import_failure.exception_class).to eq('GRPC::DeadlineExceeded') + expect(import_failure.exception_message).to be_present + expect(import_failure.correlation_id_value).not_to be_empty + end + end + def rugged rugged_repo(repository) end |