diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-11-09 01:31:37 +0300 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-11-10 20:38:11 +0300 |
commit | 208530494e5d2c5c62a3e1c24489aae0e4935e3a (patch) | |
tree | 5e4d76a6380566ab771b58c5017fba23ff321ace /spec/lib | |
parent | 1d3ada80ad6cb9a4927512fdf4018907bf3098a6 (diff) |
Refactored initializer code to its own class and added tests
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/sidekiq_throttler_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/lib/gitlab/sidekiq_throttler_spec.rb b/spec/lib/gitlab/sidekiq_throttler_spec.rb new file mode 100644 index 00000000000..ac4a64c0f43 --- /dev/null +++ b/spec/lib/gitlab/sidekiq_throttler_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe Gitlab::SidekiqThrottler do + before do + Sidekiq.options[:concurrency] = 35 + + stub_application_setting( + sidekiq_throttling_enabled: true, + sidekiq_throttling_factor: 0.1, + sidekiq_throttling_queues: %w[build project_cache] + ) + end + + describe '#set_limit' do + it 'returns the correct limit' do + expect(Gitlab::SidekiqThrottler.send(:set_limit)).to eq 4 + end + end + + describe '#execute!' do + it 'sets limits on the selected queues' do + Gitlab::SidekiqThrottler.execute! + + expect(Sidekiq::Queue['build'].limit).to eq 4 + expect(Sidekiq::Queue['project_cache'].limit).to eq 4 + end + + it 'does not set limits on other queues' do + Gitlab::SidekiqThrottler.execute! + + expect(Sidekiq::Queue['merge'].limit).to be_nil + end + end +end |