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>2020-01-24 21:09:00 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-24 21:09:00 +0300
commit411cc77938f99b495e0fe802705d275a28e939ef (patch)
tree97770ec9904daeaaa1f7546b191d23b0a642da47 /spec/lib/gitlab/sidekiq_config_spec.rb
parent3e36f70be4bd74a412b2ea1286090b54803a8c20 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/sidekiq_config_spec.rb')
-rw-r--r--spec/lib/gitlab/sidekiq_config_spec.rb60
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