diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-01-13 17:54:45 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-01-13 17:54:45 +0300 |
commit | b7f49aa0f0cbcd699396799fd746fa4f5735a250 (patch) | |
tree | 72a71e18487fdf5581f3d37ddbc4ff59614155d8 /spec | |
parent | c7d9e7806a2cfb887533e1fab24a8340988272d4 (diff) | |
parent | 057eb824b5d7f38547506303dc80da6164715420 (diff) |
Merge branch 'configure-randomize-metrics-sample-interval' into 'master'
See merge request !2406
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/metrics/sampler_spec.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/spec/lib/gitlab/metrics/sampler_spec.rb b/spec/lib/gitlab/metrics/sampler_spec.rb index 27211350fbe..38da77adc9f 100644 --- a/spec/lib/gitlab/metrics/sampler_spec.rb +++ b/spec/lib/gitlab/metrics/sampler_spec.rb @@ -9,7 +9,7 @@ describe Gitlab::Metrics::Sampler do describe '#start' do it 'gathers a sample at a given interval' do - expect(sampler).to receive(:sleep).with(5) + expect(sampler).to receive(:sleep).with(a_kind_of(Numeric)) expect(sampler).to receive(:sample) expect(sampler).to receive(:loop).and_yield @@ -116,4 +116,24 @@ describe Gitlab::Metrics::Sampler do sampler.add_metric('cats', value: 10) end end + + describe '#sleep_interval' do + it 'returns a Numeric' do + expect(sampler.sleep_interval).to be_a_kind_of(Numeric) + end + + # Testing random behaviour is very hard, so treat this test as a basic smoke + # test instead of a very accurate behaviour/unit test. + it 'does not return the same interval twice in a row' do + last = nil + + 100.times do + interval = sampler.sleep_interval + + expect(interval).to_not eq(last) + + last = interval + end + end + end end |