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-04-20 03:09:27 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 03:09:27 +0300
commitafbf001676ce96bc55d891ec45bf4e68f204a853 (patch)
tree197c83ddd512f9031d360df00cd1de5d1ab41fbb /spec/workers/bulk_imports
parent3007cf75a9bb55bcac18db7df56117677035d7b3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/bulk_imports')
-rw-r--r--spec/workers/bulk_imports/entity_worker_spec.rb45
-rw-r--r--spec/workers/bulk_imports/export_request_worker_spec.rb18
-rw-r--r--spec/workers/bulk_imports/pipeline_worker_spec.rb65
3 files changed, 77 insertions, 51 deletions
diff --git a/spec/workers/bulk_imports/entity_worker_spec.rb b/spec/workers/bulk_imports/entity_worker_spec.rb
index ce45299c7f7..ab85b587975 100644
--- a/spec/workers/bulk_imports/entity_worker_spec.rb
+++ b/spec/workers/bulk_imports/entity_worker_spec.rb
@@ -36,9 +36,11 @@ RSpec.describe BulkImports::EntityWorker do
expect(logger)
.to receive(:info).twice
.with(
- worker: described_class.name,
- entity_id: entity.id,
- current_stage: nil
+ hash_including(
+ 'entity_id' => entity.id,
+ 'current_stage' => nil,
+ 'message' => 'Stage starting'
+ )
)
end
@@ -58,24 +60,26 @@ RSpec.describe BulkImports::EntityWorker do
expect(BulkImports::PipelineWorker)
.to receive(:perform_async)
- .and_raise(exception)
+ .and_raise(exception)
expect_next_instance_of(Gitlab::Import::Logger) do |logger|
expect(logger)
.to receive(:info).twice
.with(
- worker: described_class.name,
- entity_id: entity.id,
- current_stage: nil
+ hash_including(
+ 'entity_id' => entity.id,
+ 'current_stage' => nil
+ )
)
expect(logger)
.to receive(:error)
.with(
- worker: described_class.name,
- entity_id: entity.id,
- current_stage: nil,
- error_message: 'Error!'
+ hash_including(
+ 'entity_id' => entity.id,
+ 'current_stage' => nil,
+ 'message' => 'Error!'
+ )
)
end
@@ -90,6 +94,18 @@ RSpec.describe BulkImports::EntityWorker do
let(:job_args) { [entity.id, 0] }
it 'do not enqueue a new pipeline job if the current stage still running' do
+ expect_next_instance_of(Gitlab::Import::Logger) do |logger|
+ expect(logger)
+ .to receive(:info).twice
+ .with(
+ hash_including(
+ 'entity_id' => entity.id,
+ 'current_stage' => 0,
+ 'message' => 'Stage running'
+ )
+ )
+ end
+
expect(BulkImports::PipelineWorker)
.not_to receive(:perform_async)
@@ -110,9 +126,10 @@ RSpec.describe BulkImports::EntityWorker do
expect(logger)
.to receive(:info).twice
.with(
- worker: described_class.name,
- entity_id: entity.id,
- current_stage: 0
+ hash_including(
+ 'entity_id' => entity.id,
+ 'current_stage' => 0
+ )
)
end
diff --git a/spec/workers/bulk_imports/export_request_worker_spec.rb b/spec/workers/bulk_imports/export_request_worker_spec.rb
index 4f452e3dd60..846df63a4d7 100644
--- a/spec/workers/bulk_imports/export_request_worker_spec.rb
+++ b/spec/workers/bulk_imports/export_request_worker_spec.rb
@@ -35,14 +35,16 @@ RSpec.describe BulkImports::ExportRequestWorker do
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
+ expect(Gitlab::Import::Logger).to receive(:error).with(
+ hash_including(
+ '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)
diff --git a/spec/workers/bulk_imports/pipeline_worker_spec.rb b/spec/workers/bulk_imports/pipeline_worker_spec.rb
index cb7e70a6749..3578fec5bc0 100644
--- a/spec/workers/bulk_imports/pipeline_worker_spec.rb
+++ b/spec/workers/bulk_imports/pipeline_worker_spec.rb
@@ -34,9 +34,10 @@ RSpec.describe BulkImports::PipelineWorker do
expect(logger)
.to receive(:info)
.with(
- worker: described_class.name,
- pipeline_name: 'FakePipeline',
- entity_id: entity.id
+ hash_including(
+ 'pipeline_name' => 'FakePipeline',
+ 'entity_id' => entity.id
+ )
)
end
@@ -44,7 +45,7 @@ RSpec.describe BulkImports::PipelineWorker do
.to receive(:perform_async)
.with(entity.id, pipeline_tracker.stage)
- expect(subject).to receive(:jid).and_return('jid')
+ allow(subject).to receive(:jid).and_return('jid')
subject.perform(pipeline_tracker.id, pipeline_tracker.stage, entity.id)
@@ -79,10 +80,11 @@ RSpec.describe BulkImports::PipelineWorker do
expect(logger)
.to receive(:error)
.with(
- worker: described_class.name,
- pipeline_tracker_id: pipeline_tracker.id,
- entity_id: entity.id,
- message: 'Unstarted pipeline not found'
+ hash_including(
+ 'pipeline_tracker_id' => pipeline_tracker.id,
+ 'entity_id' => entity.id,
+ 'message' => 'Unstarted pipeline not found'
+ )
)
end
@@ -107,10 +109,11 @@ RSpec.describe BulkImports::PipelineWorker do
expect(logger)
.to receive(:error)
.with(
- worker: described_class.name,
- pipeline_name: 'InexistentPipeline',
- entity_id: entity.id,
- message: "'InexistentPipeline' is not a valid BulkImport Pipeline"
+ hash_including(
+ 'pipeline_name' => 'InexistentPipeline',
+ 'entity_id' => entity.id,
+ 'message' => "'InexistentPipeline' is not a valid BulkImport Pipeline"
+ )
)
end
@@ -126,7 +129,7 @@ RSpec.describe BulkImports::PipelineWorker do
.to receive(:perform_async)
.with(entity.id, pipeline_tracker.stage)
- expect(subject).to receive(:jid).and_return('jid')
+ allow(subject).to receive(:jid).and_return('jid')
subject.perform(pipeline_tracker.id, pipeline_tracker.stage, entity.id)
@@ -151,10 +154,11 @@ RSpec.describe BulkImports::PipelineWorker do
expect(logger)
.to receive(:error)
.with(
- worker: described_class.name,
- pipeline_name: 'Pipeline',
- entity_id: entity.id,
- message: 'Failed entity status'
+ hash_including(
+ 'pipeline_name' => 'Pipeline',
+ 'entity_id' => entity.id,
+ 'message' => 'Failed entity status'
+ )
)
end
@@ -183,7 +187,7 @@ RSpec.describe BulkImports::PipelineWorker do
.and_raise(exception)
end
- expect(subject).to receive(:jid).and_return('jid').twice
+ allow(subject).to receive(:jid).and_return('jid')
expect_any_instance_of(BulkImports::Tracker) do |tracker|
expect(tracker).to receive(:retry).and_call_original
@@ -193,9 +197,10 @@ RSpec.describe BulkImports::PipelineWorker do
expect(logger)
.to receive(:info)
.with(
- worker: described_class.name,
- pipeline_name: 'FakePipeline',
- entity_id: entity.id
+ hash_including(
+ 'pipeline_name' => 'FakePipeline',
+ 'entity_id' => entity.id
+ )
)
end
@@ -292,10 +297,11 @@ RSpec.describe BulkImports::PipelineWorker do
expect(logger)
.to receive(:error)
.with(
- worker: described_class.name,
- pipeline_name: 'NdjsonPipeline',
- entity_id: entity.id,
- message: 'Pipeline timeout'
+ hash_including(
+ 'pipeline_name' => 'NdjsonPipeline',
+ 'entity_id' => entity.id,
+ 'message' => 'Pipeline timeout'
+ )
)
end
@@ -318,10 +324,11 @@ RSpec.describe BulkImports::PipelineWorker do
expect(logger)
.to receive(:error)
.with(
- worker: described_class.name,
- pipeline_name: 'NdjsonPipeline',
- entity_id: entity.id,
- message: 'Error!'
+ hash_including(
+ 'pipeline_name' => 'NdjsonPipeline',
+ 'entity_id' => entity.id,
+ 'message' => 'Error!'
+ )
)
end