summaryrefslogtreecommitdiff
path: root/spec/workers/pipeline_process_worker_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/workers/pipeline_process_worker_spec.rb')
-rw-r--r--spec/workers/pipeline_process_worker_spec.rb45
1 files changed, 37 insertions, 8 deletions
diff --git a/spec/workers/pipeline_process_worker_spec.rb b/spec/workers/pipeline_process_worker_spec.rb
index 0c1db3ccc5a..f8140d11f2e 100644
--- a/spec/workers/pipeline_process_worker_spec.rb
+++ b/spec/workers/pipeline_process_worker_spec.rb
@@ -3,10 +3,44 @@
require 'spec_helper'
RSpec.describe PipelineProcessWorker do
+ let_it_be(:pipeline) { create(:ci_pipeline) }
+
+ include_examples 'an idempotent worker' do
+ let(:pipeline) { create(:ci_pipeline, :created) }
+ let(:job_args) { [pipeline.id] }
+
+ before do
+ create(:ci_build, :created, pipeline: pipeline)
+ end
+
+ it 'processes the pipeline' do
+ expect(pipeline.status).to eq('created')
+ expect(pipeline.processables.pluck(:status)).to contain_exactly('created')
+
+ subject
+
+ expect(pipeline.reload.status).to eq('pending')
+ expect(pipeline.processables.pluck(:status)).to contain_exactly('pending')
+
+ subject
+
+ expect(pipeline.reload.status).to eq('pending')
+ expect(pipeline.processables.pluck(:status)).to contain_exactly('pending')
+ end
+ end
+
+ context 'when the FF ci_idempotent_pipeline_process_worker is disabled' do
+ before do
+ stub_feature_flags(ci_idempotent_pipeline_process_worker: false)
+ end
+
+ it 'is not deduplicated' do
+ expect(described_class).not_to be_deduplication_enabled
+ end
+ end
+
describe '#perform' do
context 'when pipeline exists' do
- let(:pipeline) { create(:ci_pipeline) }
-
it 'processes pipeline' do
expect_any_instance_of(Ci::ProcessPipelineService).to receive(:execute)
@@ -16,14 +50,9 @@ RSpec.describe PipelineProcessWorker do
context 'when pipeline does not exist' do
it 'does not raise exception' do
- expect { described_class.new.perform(123) }
+ expect { described_class.new.perform(non_existing_record_id) }
.not_to raise_error
end
end
-
- it_behaves_like 'worker with data consistency',
- described_class,
- feature_flag: :load_balancing_for_pipeline_process_worker,
- data_consistency: :delayed
end
end