summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 21:12:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 21:12:42 +0000
commitc1ea2a91648ca8bfdb2e17e3ec7e3358da490dc8 (patch)
treef5770d2ec59e1fe0206fe56857e4349281566f5e /spec/workers
parente4fc62c0af80cfaaa907aea83ae4012e06a1f9e4 (diff)
downloadgitlab-ce-c1ea2a91648ca8bfdb2e17e3ec7e3358da490dc8.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/build_hooks_worker_spec.rb6
-rw-r--r--spec/workers/concerns/application_worker_spec.rb52
2 files changed, 56 insertions, 2 deletions
diff --git a/spec/workers/build_hooks_worker_spec.rb b/spec/workers/build_hooks_worker_spec.rb
index 8395d8fb0e7..3628ebc7260 100644
--- a/spec/workers/build_hooks_worker_spec.rb
+++ b/spec/workers/build_hooks_worker_spec.rb
@@ -29,8 +29,10 @@ RSpec.describe BuildHooksWorker do
stub_feature_flags(delayed_perform_for_build_hooks_worker: false)
end
- it 'does not call perform_in' do
- expect(described_class).not_to receive(:perform_in)
+ it 'delays scheduling a job by calling perform_in with default delay' do
+ expect(described_class).to receive(:perform_in).with(ApplicationWorker::DEFAULT_DELAY_INTERVAL.second, 123)
+
+ described_class.perform_async(123)
end
end
diff --git a/spec/workers/concerns/application_worker_spec.rb b/spec/workers/concerns/application_worker_spec.rb
index 5c1a1d3ae8f..45b78ff961b 100644
--- a/spec/workers/concerns/application_worker_spec.rb
+++ b/spec/workers/concerns/application_worker_spec.rb
@@ -176,6 +176,58 @@ RSpec.describe ApplicationWorker do
end
end
+ describe '.perform_async' do
+ shared_examples_for 'worker utilizes load balancing capabilities' do |data_consistency|
+ before do
+ worker.data_consistency(data_consistency)
+ end
+
+ context 'when data_consistency_delayed_execution feature flag is disabled' do
+ before do
+ stub_feature_flags(data_consistency_delayed_execution: false)
+ end
+
+ it 'data_consistency_delayed_execution_feature_flag_enabled? should return false' do
+ expect(worker).to receive(:data_consistency_delayed_execution_feature_flag_enabled?).and_return(false)
+
+ worker.perform_async
+ end
+
+ it 'does not call perform_in' do
+ expect(worker).not_to receive(:perform_in)
+
+ worker.perform_async
+ end
+ end
+
+ it 'call perform_in' do
+ expect(worker).to receive(:perform_in).with(described_class::DEFAULT_DELAY_INTERVAL.seconds, 123)
+
+ worker.perform_async(123)
+ end
+ end
+
+ context 'when workers data consistency is :sticky' do
+ it_behaves_like 'worker utilizes load balancing capabilities', :sticky
+ end
+
+ context 'when workers data consistency is :delayed' do
+ it_behaves_like 'worker utilizes load balancing capabilities', :delayed
+ 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)
+
+ worker.perform_async
+ end
+ end
+ end
+
describe '.bulk_perform_async' do
it 'enqueues jobs in bulk' do
Sidekiq::Testing.fake! do