diff options
Diffstat (limited to 'spec/workers/ci')
-rw-r--r-- | spec/workers/ci/build_trace_chunk_flush_worker_spec.rb | 4 | ||||
-rw-r--r-- | spec/workers/ci/delete_objects_worker_spec.rb | 49 | ||||
-rw-r--r-- | spec/workers/ci/schedule_delete_objects_cron_worker_spec.rb | 15 |
3 files changed, 66 insertions, 2 deletions
diff --git a/spec/workers/ci/build_trace_chunk_flush_worker_spec.rb b/spec/workers/ci/build_trace_chunk_flush_worker_spec.rb index 352ad6d4cf6..8aac80a02be 100644 --- a/spec/workers/ci/build_trace_chunk_flush_worker_spec.rb +++ b/spec/workers/ci/build_trace_chunk_flush_worker_spec.rb @@ -14,7 +14,7 @@ RSpec.describe Ci::BuildTraceChunkFlushWorker do described_class.new.perform(chunk.id) - expect(chunk.reload).to be_persisted + expect(chunk.reload).to be_migrated end describe '#perform' do @@ -24,7 +24,7 @@ RSpec.describe Ci::BuildTraceChunkFlushWorker do it 'migrates build trace chunk to a safe store' do subject - expect(chunk.reload).to be_persisted + expect(chunk.reload).to be_migrated end end end diff --git a/spec/workers/ci/delete_objects_worker_spec.rb b/spec/workers/ci/delete_objects_worker_spec.rb new file mode 100644 index 00000000000..6cb8e0cba37 --- /dev/null +++ b/spec/workers/ci/delete_objects_worker_spec.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Ci::DeleteObjectsWorker do + let(:worker) { described_class.new } + + it { expect(described_class.idempotent?).to be_truthy } + + describe '#perform' do + it 'executes a service' do + expect_next_instance_of(Ci::DeleteObjectsService) do |instance| + expect(instance).to receive(:execute) + expect(instance).to receive(:remaining_batches_count).once.and_call_original + end + + worker.perform + end + end + + describe '#max_running_jobs' do + using RSpec::Parameterized::TableSyntax + + before do + stub_feature_flags( + ci_delete_objects_low_concurrency: low, + ci_delete_objects_medium_concurrency: medium, + ci_delete_objects_high_concurrency: high + ) + end + + subject(:max_running_jobs) { worker.max_running_jobs } + + where(:low, :medium, :high, :expected) do + false | false | false | 0 + true | true | true | 2 + true | false | false | 2 + false | true | false | 20 + false | true | true | 20 + false | false | true | 50 + end + + with_them do + it 'sets up concurrency depending on the feature flag' do + expect(max_running_jobs).to eq(expected) + end + end + end +end diff --git a/spec/workers/ci/schedule_delete_objects_cron_worker_spec.rb b/spec/workers/ci/schedule_delete_objects_cron_worker_spec.rb new file mode 100644 index 00000000000..142df271f90 --- /dev/null +++ b/spec/workers/ci/schedule_delete_objects_cron_worker_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Ci::ScheduleDeleteObjectsCronWorker do + let(:worker) { described_class.new } + + describe '#perform' do + it 'enqueues DeleteObjectsWorker jobs' do + expect(Ci::DeleteObjectsWorker).to receive(:perform_with_capacity) + + worker.perform + end + end +end |