diff options
author | Robert Speicher <robert@gitlab.com> | 2017-03-04 01:38:30 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-03-04 01:38:30 +0000 |
commit | 5f190ea18698a9881e3b1411e90e0864050d88f9 (patch) | |
tree | d3f1d0720084ad188bf0605dffb06f254927fdb1 /spec | |
parent | 445f815bb6c6a6137f7a60552a23a1ae366442ff (diff) | |
parent | ffd970d97dc9faf82752e6494aab8ba6fdce759a (diff) | |
download | gitlab-ce-5f190ea18698a9881e3b1411e90e0864050d88f9.tar.gz |
Merge branch 'sh-improve-sidekiq-status' into 'master'
Make SidekiqStatus able to count number of jobs completed/running
See merge request !9694
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/sidekiq_status_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/lib/gitlab/sidekiq_status_spec.rb b/spec/lib/gitlab/sidekiq_status_spec.rb index 0aa36a3416b..56f06b61afb 100644 --- a/spec/lib/gitlab/sidekiq_status_spec.rb +++ b/spec/lib/gitlab/sidekiq_status_spec.rb @@ -39,6 +39,32 @@ describe Gitlab::SidekiqStatus do end end + describe '.num_running', :redis do + it 'returns 0 if all jobs have been completed' do + expect(described_class.num_running(%w(123))).to eq(0) + end + + it 'returns 2 if two jobs are still running' do + described_class.set('123') + described_class.set('456') + + expect(described_class.num_running(%w(123 456 789))).to eq(2) + end + end + + describe '.num_completed', :redis do + it 'returns 1 if all jobs have been completed' do + expect(described_class.num_completed(%w(123))).to eq(1) + end + + it 'returns 1 if a job has not yet been completed' do + described_class.set('123') + described_class.set('456') + + expect(described_class.num_completed(%w(123 456 789))).to eq(1) + end + end + describe '.key_for' do it 'returns the key for a job ID' do key = described_class.key_for('123') |