diff options
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r-- | spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb | 16 | ||||
-rw-r--r-- | spec/lib/gitlab/metrics/system_spec.rb | 12 |
2 files changed, 8 insertions, 20 deletions
diff --git a/spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb b/spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb index aaf8c9fa2a0..4d93b70e6e3 100644 --- a/spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb +++ b/spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb @@ -8,12 +8,19 @@ describe Gitlab::Metrics::Samplers::RubySampler do allow(Gitlab::Metrics::NullMetric).to receive(:instance).and_return(null_metric) end + describe '#initialize' do + it 'sets process_start_time_seconds' do + Timecop.freeze do + expect(sampler.metrics[:process_start_time_seconds].get).to eq(Time.now.to_i) + end + end + end + describe '#sample' do it 'samples various statistics' do expect(Gitlab::Metrics::System).to receive(:cpu_time) expect(Gitlab::Metrics::System).to receive(:file_descriptor_count) expect(Gitlab::Metrics::System).to receive(:memory_usage) - expect(Gitlab::Metrics::System).to receive(:process_start_time) expect(Gitlab::Metrics::System).to receive(:max_open_file_descriptors) expect(sampler).to receive(:sample_gc) @@ -44,13 +51,6 @@ describe Gitlab::Metrics::Samplers::RubySampler do sampler.sample end - it 'adds a metric containing the process start time' do - expect(Gitlab::Metrics::System).to receive(:process_start_time).and_return(12345) - expect(sampler.metrics[:process_start_time_seconds]).to receive(:set).with({}, 12345) - - sampler.sample - end - it 'adds a metric containing the process max file descriptors' do expect(Gitlab::Metrics::System).to receive(:max_open_file_descriptors).and_return(1024) expect(sampler.metrics[:process_max_fds]).to receive(:set).with({}, 1024) diff --git a/spec/lib/gitlab/metrics/system_spec.rb b/spec/lib/gitlab/metrics/system_spec.rb index da87df15746..3b434a02f63 100644 --- a/spec/lib/gitlab/metrics/system_spec.rb +++ b/spec/lib/gitlab/metrics/system_spec.rb @@ -19,12 +19,6 @@ describe Gitlab::Metrics::System do expect(described_class.max_open_file_descriptors).to be > 0 end end - - describe '.process_start_time' do - it 'returns the process start time' do - expect(described_class.process_start_time).to be > 0 - end - end else describe '.memory_usage' do it 'returns 0.0' do @@ -43,12 +37,6 @@ describe Gitlab::Metrics::System do expect(described_class.max_open_file_descriptors).to eq(0) end end - - describe 'process_start_time' do - it 'returns 0' do - expect(described_class.process_start_time).to eq(0) - end - end end describe '.cpu_time' do |