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>2021-09-30 09:09:27 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-09-30 09:09:27 +0300
commitb920d2a9831056cdf907cf71fd25d94f0aaf1e6c (patch)
tree37d937a61754aa5072fd607fbd2aa8ed00225d6a /spec/workers/bulk_imports
parent3778629470659207d15cbc8b7064b0eb3caf09ef (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/bulk_imports')
-rw-r--r--spec/workers/bulk_imports/pipeline_worker_spec.rb100
1 files changed, 75 insertions, 25 deletions
diff --git a/spec/workers/bulk_imports/pipeline_worker_spec.rb b/spec/workers/bulk_imports/pipeline_worker_spec.rb
index 56f28654ac5..fc70a2582e4 100644
--- a/spec/workers/bulk_imports/pipeline_worker_spec.rb
+++ b/spec/workers/bulk_imports/pipeline_worker_spec.rb
@@ -27,42 +27,59 @@ RSpec.describe BulkImports::PipelineWorker do
.and_return([[0, pipeline_class]])
end
- it 'runs the given pipeline successfully' do
- pipeline_tracker = create(
- :bulk_import_tracker,
- entity: entity,
- pipeline_name: 'FakePipeline'
- )
-
- expect_next_instance_of(Gitlab::Import::Logger) do |logger|
- expect(logger)
- .to receive(:info)
- .with(
- worker: described_class.name,
- pipeline_name: 'FakePipeline',
- entity_id: entity.id
- )
- end
+ shared_examples 'successfully runs the pipeline' do
+ it 'runs the given pipeline successfully' do
+ expect_next_instance_of(Gitlab::Import::Logger) do |logger|
+ expect(logger)
+ .to receive(:info)
+ .with(
+ worker: described_class.name,
+ pipeline_name: 'FakePipeline',
+ entity_id: entity.id
+ )
+ end
- expect(BulkImports::EntityWorker)
- .to receive(:perform_async)
- .with(entity.id, pipeline_tracker.stage)
+ expect(BulkImports::EntityWorker)
+ .to receive(:perform_async)
+ .with(entity.id, pipeline_tracker.stage)
+
+ expect(subject).to receive(:jid).and_return('jid')
- expect(subject).to receive(:jid).and_return('jid')
+ subject.perform(pipeline_tracker.id, pipeline_tracker.stage, entity.id)
- subject.perform(pipeline_tracker.id, pipeline_tracker.stage, entity.id)
+ pipeline_tracker.reload
- pipeline_tracker.reload
+ expect(pipeline_tracker.status_name).to eq(:finished)
+ expect(pipeline_tracker.jid).to eq('jid')
+ end
+ end
- expect(pipeline_tracker.status_name).to eq(:finished)
- expect(pipeline_tracker.jid).to eq('jid')
+ it_behaves_like 'successfully runs the pipeline' do
+ let(:pipeline_tracker) do
+ create(
+ :bulk_import_tracker,
+ entity: entity,
+ pipeline_name: 'FakePipeline'
+ )
+ end
+ end
+
+ it_behaves_like 'successfully runs the pipeline' do
+ let(:pipeline_tracker) do
+ create(
+ :bulk_import_tracker,
+ :started,
+ entity: entity,
+ pipeline_name: 'FakePipeline'
+ )
+ end
end
context 'when the pipeline cannot be found' do
it 'logs the error' do
pipeline_tracker = create(
:bulk_import_tracker,
- :started,
+ :finished,
entity: entity,
pipeline_name: 'FakePipeline'
)
@@ -126,6 +143,39 @@ RSpec.describe BulkImports::PipelineWorker do
expect(pipeline_tracker.status_name).to eq(:failed)
expect(pipeline_tracker.jid).to eq('jid')
end
+
+ context 'when it is a network error' do
+ it 'reenqueue on retriable network errors' do
+ pipeline_tracker = create(
+ :bulk_import_tracker,
+ entity: entity,
+ pipeline_name: 'FakePipeline'
+ )
+
+ exception = BulkImports::NetworkError.new(
+ response: double(code: 429, headers: {})
+ )
+
+ expect_next_instance_of(pipeline_class) do |pipeline|
+ expect(pipeline)
+ .to receive(:run)
+ .and_raise(exception)
+ end
+
+ expect(subject).to receive(:jid).and_return('jid')
+
+ expect(described_class)
+ .to receive(:perform_in)
+ .with(
+ 60.seconds,
+ pipeline_tracker.id,
+ pipeline_tracker.stage,
+ pipeline_tracker.entity.id
+ )
+
+ subject.perform(pipeline_tracker.id, pipeline_tracker.stage, entity.id)
+ end
+ end
end
context 'when ndjson pipeline' do