diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-20 06:14:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-20 06:14:16 +0300 |
commit | 602b7079493074b56bd024fd04afbdb8f729fc2f (patch) | |
tree | 0da123356cabcc10b9c36f404179197df8a235cb /spec/workers | |
parent | aac72676438d00eca8f58aefb673e03af8c6c04b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/bulk_imports/finish_batched_pipeline_worker_spec.rb | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/spec/workers/bulk_imports/finish_batched_pipeline_worker_spec.rb b/spec/workers/bulk_imports/finish_batched_pipeline_worker_spec.rb index 59ae4205c0f..959b063e061 100644 --- a/spec/workers/bulk_imports/finish_batched_pipeline_worker_spec.rb +++ b/spec/workers/bulk_imports/finish_batched_pipeline_worker_spec.rb @@ -33,6 +33,8 @@ RSpec.describe BulkImports::FinishBatchedPipelineWorker, feature_category: :impo ) end + let!(:batch_1) { create(:bulk_import_batch_tracker, :finished, tracker: pipeline_tracker) } + subject(:worker) { described_class.new } describe '#perform' do @@ -45,27 +47,27 @@ RSpec.describe BulkImports::FinishBatchedPipelineWorker, feature_category: :impo end end - context 'when import is in progress' do - it 'marks the tracker as finished' do - expect_next_instance_of(BulkImports::Logger) do |logger| - expect(logger).to receive(:info).with( - a_hash_including('message' => 'Tracker finished') - ) - end - - expect { subject.perform(pipeline_tracker.id) } - .to change { pipeline_tracker.reload.finished? } - .from(false).to(true) + it 'marks the tracker as finished' do + expect_next_instance_of(BulkImports::Logger) do |logger| + expect(logger).to receive(:info).with( + a_hash_including('message' => 'Tracker finished') + ) end - it "calls the pipeline's `#on_finish`" do - expect_next_instance_of(pipeline_class) do |pipeline| - expect(pipeline).to receive(:on_finish) - end + expect { subject.perform(pipeline_tracker.id) } + .to change { pipeline_tracker.reload.finished? } + .from(false).to(true) + end - subject.perform(pipeline_tracker.id) + it "calls the pipeline's `#on_finish`" do + expect_next_instance_of(pipeline_class) do |pipeline| + expect(pipeline).to receive(:on_finish) end + subject.perform(pipeline_tracker.id) + end + + context 'when import is in progress' do it 're-enqueues for any started batches' do create(:bulk_import_batch_tracker, :started, tracker: pipeline_tracker) @@ -88,14 +90,14 @@ RSpec.describe BulkImports::FinishBatchedPipelineWorker, feature_category: :impo end context 'when pipeline tracker is stale' do - let(:pipeline_tracker) { create(:bulk_import_tracker, :started, :batched, :stale, entity: entity) } + before do + batch_1.update!(updated_at: 5.hours.ago) + end it 'fails pipeline tracker and its batches' do - create(:bulk_import_batch_tracker, :finished, tracker: pipeline_tracker) - expect_next_instance_of(BulkImports::Logger) do |logger| expect(logger).to receive(:error).with( - a_hash_including('message' => 'Tracker stale. Failing batches and tracker') + a_hash_including('message' => 'Batch stale. Failing batches and tracker') ) end |