Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-14 12:08:52 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-14 12:08:52 +0300
commit6aa920eeb4ef61ea7e7c77b5e10595507874b927 (patch)
treebabdd955f22707b9196543ab9e85af3e140a57f6 /spec/workers/bulk_imports
parent1943b0a274de377e0d3e212d3d4d1bfcf58d3690 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/bulk_imports')
-rw-r--r--spec/workers/bulk_imports/export_request_worker_spec.rb25
-rw-r--r--spec/workers/bulk_imports/pipeline_worker_spec.rb28
2 files changed, 53 insertions, 0 deletions
diff --git a/spec/workers/bulk_imports/export_request_worker_spec.rb b/spec/workers/bulk_imports/export_request_worker_spec.rb
index f838bff528c..4f452e3dd60 100644
--- a/spec/workers/bulk_imports/export_request_worker_spec.rb
+++ b/spec/workers/bulk_imports/export_request_worker_spec.rb
@@ -28,6 +28,31 @@ RSpec.describe BulkImports::ExportRequestWorker do
perform_multiple(job_args)
end
+
+ context 'when network error is raised' do
+ it 'logs export failure and marks entity as failed' do
+ expect_next_instance_of(BulkImports::Clients::HTTP) do |client|
+ expect(client).to receive(:post).and_raise(BulkImports::NetworkError, 'Export error').twice
+ end
+
+ expect(Gitlab::Import::Logger).to receive(:warn).with(
+ bulk_import_entity_id: entity.id,
+ pipeline_class: 'ExportRequestWorker',
+ exception_class: 'BulkImports::NetworkError',
+ exception_message: 'Export error',
+ correlation_id_value: anything,
+ bulk_import_id: bulk_import.id,
+ bulk_import_entity_type: entity.source_type
+ ).twice
+
+ perform_multiple(job_args)
+
+ failure = entity.failures.last
+
+ expect(failure.pipeline_class).to eq('ExportRequestWorker')
+ expect(failure.exception_message).to eq('Export error')
+ end
+ end
end
end
diff --git a/spec/workers/bulk_imports/pipeline_worker_spec.rb b/spec/workers/bulk_imports/pipeline_worker_spec.rb
index 2da9195a6ef..cb7e70a6749 100644
--- a/spec/workers/bulk_imports/pipeline_worker_spec.rb
+++ b/spec/workers/bulk_imports/pipeline_worker_spec.rb
@@ -136,6 +136,34 @@ RSpec.describe BulkImports::PipelineWorker do
expect(pipeline_tracker.jid).to eq('jid')
end
+ context 'when entity is failed' do
+ it 'marks tracker as failed and logs the error' do
+ pipeline_tracker = create(
+ :bulk_import_tracker,
+ entity: entity,
+ pipeline_name: 'Pipeline',
+ status_event: 'enqueue'
+ )
+
+ entity.update!(status: -1)
+
+ expect_next_instance_of(Gitlab::Import::Logger) do |logger|
+ expect(logger)
+ .to receive(:error)
+ .with(
+ worker: described_class.name,
+ pipeline_name: 'Pipeline',
+ entity_id: entity.id,
+ message: 'Failed entity status'
+ )
+ end
+
+ subject.perform(pipeline_tracker.id, pipeline_tracker.stage, entity.id)
+
+ expect(pipeline_tracker.reload.status_name).to eq(:failed)
+ end
+ end
+
context 'when it is a network error' do
it 'reenqueue on retriable network errors' do
pipeline_tracker = create(