diff options
Diffstat (limited to 'spec/lib/gitlab/sidekiq_config_spec.rb')
-rw-r--r-- | spec/lib/gitlab/sidekiq_config_spec.rb | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/lib/gitlab/sidekiq_config_spec.rb b/spec/lib/gitlab/sidekiq_config_spec.rb index 39bb149cf73..20690a35dc8 100644 --- a/spec/lib/gitlab/sidekiq_config_spec.rb +++ b/spec/lib/gitlab/sidekiq_config_spec.rb @@ -80,4 +80,64 @@ describe Gitlab::SidekiqConfig do expect(described_class.all_queues_yml_outdated?).to be(false) end end + + describe '.queues_for_sidekiq_queues_yml' do + before do + workers = [ + Namespaces::RootStatisticsWorker, + Namespaces::ScheduleAggregationWorker, + MergeWorker, + ProcessCommitWorker + ].map { |worker| described_class::Worker.new(worker, ee: false) } + + allow(described_class).to receive(:workers).and_return(workers) + end + + it 'returns queues and weights, aggregating namespaces with the same weight' do + expected_queues = [ + ['merge', 5], + ['process_commit', 3], + ['update_namespace_statistics', 1] + ] + + expect(described_class.queues_for_sidekiq_queues_yml).to eq(expected_queues) + end + end + + describe '.sidekiq_queues_yml_outdated?' do + before do + workers = [ + Namespaces::RootStatisticsWorker, + Namespaces::ScheduleAggregationWorker, + MergeWorker, + ProcessCommitWorker + ].map { |worker| described_class::Worker.new(worker, ee: false) } + + allow(described_class).to receive(:workers).and_return(workers) + end + + let(:expected_queues) do + [ + ['merge', 5], + ['process_commit', 3], + ['update_namespace_statistics', 1] + ] + end + + it 'returns true if the YAML file does not match the application code' do + allow(File).to receive(:read) + .with(described_class::SIDEKIQ_QUEUES_PATH) + .and_return(YAML.dump(queues: expected_queues.reverse)) + + expect(described_class.sidekiq_queues_yml_outdated?).to be(true) + end + + it 'returns false if the YAML file matches the application code' do + allow(File).to receive(:read) + .with(described_class::SIDEKIQ_QUEUES_PATH) + .and_return(YAML.dump(queues: expected_queues)) + + expect(described_class.sidekiq_queues_yml_outdated?).to be(false) + end + end end |