diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /spec/lib/gitlab/sidekiq_config_spec.rb | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/lib/gitlab/sidekiq_config_spec.rb')
-rw-r--r-- | spec/lib/gitlab/sidekiq_config_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/lib/gitlab/sidekiq_config_spec.rb b/spec/lib/gitlab/sidekiq_config_spec.rb index d216b9d0c18..d2a53185acd 100644 --- a/spec/lib/gitlab/sidekiq_config_spec.rb +++ b/spec/lib/gitlab/sidekiq_config_spec.rb @@ -122,4 +122,43 @@ RSpec.describe Gitlab::SidekiqConfig do expect(described_class.sidekiq_queues_yml_outdated?).to be(false) end end + + describe '.worker_queue_mappings' do + it 'returns the worker class => queue mappings based on the current routing configuration' do + test_routes = [ + ['urgency=high', 'default'], + ['*', nil] + ] + + allow(::Gitlab::SidekiqConfig::WorkerRouter) + .to receive(:global).and_return(::Gitlab::SidekiqConfig::WorkerRouter.new(test_routes)) + + expect(described_class.worker_queue_mappings).to include('MergeWorker' => 'default', + 'Ci::BuildFinishedWorker' => 'default', + 'BackgroundMigrationWorker' => 'background_migration', + 'AdminEmailWorker' => 'cronjob:admin_email') + end + end + + describe '.current_worker_queue_mappings' do + it 'returns worker queue mappings that have queues in the current Sidekiq options' do + test_routes = [ + ['urgency=high', 'default'], + ['*', nil] + ] + + allow(::Gitlab::SidekiqConfig::WorkerRouter) + .to receive(:global).and_return(::Gitlab::SidekiqConfig::WorkerRouter.new(test_routes)) + + allow(Sidekiq).to receive(:options).and_return(queues: %w[default background_migration]) + + mappings = described_class.current_worker_queue_mappings + + expect(mappings).to include('MergeWorker' => 'default', + 'Ci::BuildFinishedWorker' => 'default', + 'BackgroundMigrationWorker' => 'background_migration') + + expect(mappings).not_to include('AdminEmailWorker' => 'cronjob:admin_email') + end + end end |