diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-17 21:08:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-17 21:08:05 +0300 |
commit | 184c2ced0761bd8dd7032619d16d3983fed7944a (patch) | |
tree | cc82b32ee7c1797509da3cf384617e4ffa2e1733 /spec/initializers/lograge_spec.rb | |
parent | 238d22c07218adf2b8f3db630ee8b74ca6f29df5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/initializers/lograge_spec.rb')
-rw-r--r-- | spec/initializers/lograge_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/initializers/lograge_spec.rb b/spec/initializers/lograge_spec.rb index 24d366731a2..c2c1960eeab 100644 --- a/spec/initializers/lograge_spec.rb +++ b/spec/initializers/lograge_spec.rb @@ -34,5 +34,38 @@ describe 'lograge', type: :request do subject end + + it 'logs cpu_s on supported platform' do + allow(Gitlab::Metrics::System).to receive(:thread_cpu_time) + .and_return( + 0.111222333, + 0.222333833 + ) + + expect(Lograge.formatter).to receive(:call) + .with(a_hash_including(cpu_s: 0.1111115)) + .and_call_original + + expect(Lograge.logger).to receive(:send) + .with(anything, include('"cpu_s":0.1111115')) + .and_call_original + + subject + end + + it 'does not log cpu_s on unsupported platform' do + allow(Gitlab::Metrics::System).to receive(:thread_cpu_time) + .and_return(nil) + + expect(Lograge.formatter).to receive(:call) + .with(hash_not_including(:cpu_s)) + .and_call_original + + expect(Lograge.logger).not_to receive(:send) + .with(anything, include('"cpu_s":')) + .and_call_original + + subject + end end end |