diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-11-11 18:32:40 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-11-11 18:32:40 +0000 |
commit | 0e1e42885a792145dafc6aa28165d069b1cb5c03 (patch) | |
tree | 2748dddbf1f499ff9be1eca4ce6a8132f44649a1 /spec | |
parent | 52f29501be343ed8cb8bfc8ee64014cd3f4c9ba4 (diff) | |
parent | e840749b84ceb226e46ebdfb489c735e3370cff7 (diff) | |
download | gitlab-ce-0e1e42885a792145dafc6aa28165d069b1cb5c03.tar.gz |
Merge branch 'sidekiq-job-throttling' into 'master'
Allow certain Sidekiq jobs to be throttled
## What does this MR do?
Allows certain slow running Sidekiq jobs to be throttled. It is disabled by default and can be enabled via the Application Settings.
![Screen_Shot_2016-11-04_at_4.51.24_PM](/uploads/a1f1d24c693fcdb278602765cd404d94/Screen_Shot_2016-11-04_at_4.51.24_PM.png)
## Does this MR meet the acceptance criteria?
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG.md) entry added
- [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- Tests
- [x] Added for this feature/bug
- [x] All builds are passing
## What are the relevant issue numbers?
Related to #23352
See merge request !7292
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/sidekiq_throttler_spec.rb | 28 |
1 files changed, 28 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..ff32e0e699d --- /dev/null +++ b/spec/lib/gitlab/sidekiq_throttler_spec.rb @@ -0,0 +1,28 @@ +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 '#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 |