diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-22 15:10:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-22 15:10:20 +0300 |
commit | 860dab2f5f977c7bf14c13c01e43cae2757264f1 (patch) | |
tree | 58d34903d0158e24f0c5651d19c06810cffa48ab /spec/workers/concerns | |
parent | 56274bbb7424bcecbd43bd5f884b11a85322044e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/concerns')
-rw-r--r-- | spec/workers/concerns/application_worker_spec.rb | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/spec/workers/concerns/application_worker_spec.rb b/spec/workers/concerns/application_worker_spec.rb index fbf39b3c7cd..7608b5f49a1 100644 --- a/spec/workers/concerns/application_worker_spec.rb +++ b/spec/workers/concerns/application_worker_spec.rb @@ -248,39 +248,40 @@ RSpec.describe ApplicationWorker do end describe '.perform_async' do - before do - stub_const(worker.name, worker) - end - - shared_examples_for 'worker utilizes load balancing capabilities' do |data_consistency| - before do - worker.data_consistency(data_consistency) - end - - it 'call perform_in' do - expect(worker).to receive(:perform_in).with(described_class::DEFAULT_DELAY_INTERVAL.seconds, 123) + using RSpec::Parameterized::TableSyntax - worker.perform_async(123) - end + where(:primary_only?, :skip_scheduling_ff, :data_consistency, :schedules_job?) do + true | false | :sticky | false + true | false | :delayed | false + true | false | :always | false + true | true | :sticky | false + true | true | :delayed | false + true | true | :always | false + false | false | :sticky | true + false | false | :delayed | true + false | false | :always | false + false | true | :sticky | false + false | true | :delayed | false + false | true | :always | false end - context 'when workers data consistency is :sticky' do - it_behaves_like 'worker utilizes load balancing capabilities', :sticky - end + before do + stub_const(worker.name, worker) + worker.data_consistency(data_consistency) - context 'when workers data consistency is :delayed' do - it_behaves_like 'worker utilizes load balancing capabilities', :delayed + allow(Gitlab::Database::LoadBalancing).to receive(:primary_only?).and_return(primary_only?) + stub_feature_flags(skip_scheduling_workers_for_replicas: skip_scheduling_ff) end - context 'when workers data consistency is :always' do - before do - worker.data_consistency(:always) - end - - it 'does not call perform_in' do - expect(worker).not_to receive(:perform_in) + with_them do + it 'schedules or enqueues the job correctly' do + if schedules_job? + expect(worker).to receive(:perform_in).with(described_class::DEFAULT_DELAY_INTERVAL.seconds, 123) + else + expect(worker).not_to receive(:perform_in) + end - worker.perform_async + worker.perform_async(123) end end end |