Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-05 18:07:38 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-05 18:07:38 +0300
commitcd6f5dd0c75a473e4a45ee64b36442de546a4124 (patch)
tree8e5a188db3c986bca6a3a1e0b3df77d9aa826410 /spec/workers
parente8fc7f565017d915278fd0efbcff2f81b7e94093 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/concerns/application_worker_spec.rb71
1 files changed, 71 insertions, 0 deletions
diff --git a/spec/workers/concerns/application_worker_spec.rb b/spec/workers/concerns/application_worker_spec.rb
index 29c69ff8b4b..ac4e4a682c8 100644
--- a/spec/workers/concerns/application_worker_spec.rb
+++ b/spec/workers/concerns/application_worker_spec.rb
@@ -176,6 +176,77 @@ RSpec.describe ApplicationWorker do
end
end
+ describe '.data_consistency' do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:data_consistency, :sidekiq_option_retry, :expect_error) do
+ :delayed | false | true
+ :delayed | 0 | true
+ :delayed | 3 | false
+ :delayed | nil | false
+ :sticky | false | false
+ :sticky | 0 | false
+ :sticky | 3 | false
+ :sticky | nil | false
+ :always | false | false
+ :always | 0 | false
+ :always | 3 | false
+ :always | nil | false
+ end
+
+ with_them do
+ before do
+ worker.sidekiq_options retry: sidekiq_option_retry unless sidekiq_option_retry.nil?
+ end
+
+ context "when workers data consistency is #{params['data_consistency']}" do
+ it "#{params['expect_error'] ? '' : 'not to '}raise an exception" do
+ if expect_error
+ expect { worker.data_consistency data_consistency }
+ .to raise_error("Retry support cannot be disabled if data_consistency is set to :delayed")
+ else
+ expect { worker.data_consistency data_consistency }
+ .not_to raise_error
+ end
+ end
+ end
+ end
+ end
+
+ describe '.retry' do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:data_consistency, :sidekiq_option_retry, :expect_error) do
+ :delayed | false | true
+ :delayed | 0 | true
+ :delayed | 3 | false
+ :sticky | false | false
+ :sticky | 0 | false
+ :sticky | 3 | false
+ :always | false | false
+ :always | 0 | false
+ :always | 3 | false
+ end
+
+ with_them do
+ before do
+ worker.data_consistency(data_consistency)
+ end
+
+ context "when retry sidekiq option is #{params['sidekiq_option_retry']}" do
+ it "#{params['expect_error'] ? '' : 'not to '}raise an exception" do
+ if expect_error
+ expect { worker.sidekiq_options retry: sidekiq_option_retry }
+ .to raise_error("Retry support cannot be disabled if data_consistency is set to :delayed")
+ else
+ expect { worker.sidekiq_options retry: sidekiq_option_retry }
+ .not_to raise_error
+ end
+ end
+ end
+ end
+ end
+
describe '.perform_async' do
shared_examples_for 'worker utilizes load balancing capabilities' do |data_consistency|
before do