diff options
author | Ryan Cobb <rcobb@gitlab.com> | 2019-05-20 14:34:00 +0000 |
---|---|---|
committer | Ryan Cobb <rcobb@gitlab.com> | 2019-05-20 14:34:00 +0000 |
commit | 2334b07726f819c6a9fe94d1380969d0b9eaef85 (patch) | |
tree | 8abf7e0d0813153c91e00c79cb8011cdd133352c /spec | |
parent | 7115bd811f4bc87c0706fc2b876729878ad8fc5b (diff) | |
download | gitlab-ce-2334b07726f819c6a9fe94d1380969d0b9eaef85.tar.gz |
Revert "Merge branch '56850-add-new-unicorn-metrics' into 'master'"revert-c5a9bc17
This reverts merge request !27474
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb | 30 | ||||
-rw-r--r-- | spec/lib/gitlab/metrics/samplers/unicorn_sampler_spec.rb | 25 | ||||
-rw-r--r-- | spec/lib/gitlab/metrics/system_spec.rb | 24 |
3 files changed, 8 insertions, 71 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..7972ff253fe 100644 --- a/spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb +++ b/spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb @@ -10,20 +10,17 @@ describe Gitlab::Metrics::Samplers::RubySampler do 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(Gitlab::Metrics::System).to receive(:file_descriptor_count) expect(sampler).to receive(:sample_gc) sampler.sample end - it 'adds a metric containing the process resident memory bytes' do + it 'adds a metric containing the memory usage' do expect(Gitlab::Metrics::System).to receive(:memory_usage).and_return(9000) - expect(sampler.metrics[:process_resident_memory_bytes]).to receive(:set).with({}, 9000) + expect(sampler.metrics[:memory_usage]).to receive(:set).with({}, 9000) sampler.sample end @@ -37,27 +34,6 @@ describe Gitlab::Metrics::Samplers::RubySampler do sampler.sample end - it 'adds a metric containing the process total cpu time' do - expect(Gitlab::Metrics::System).to receive(:cpu_time).and_return(0.51) - expect(sampler.metrics[:process_cpu_seconds_total]).to receive(:set).with({}, 0.51) - - 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) - - sampler.sample - end - it 'clears any GC profiles' do expect(GC::Profiler).to receive(:clear) diff --git a/spec/lib/gitlab/metrics/samplers/unicorn_sampler_spec.rb b/spec/lib/gitlab/metrics/samplers/unicorn_sampler_spec.rb index 090e456644f..4b03f3c2532 100644 --- a/spec/lib/gitlab/metrics/samplers/unicorn_sampler_spec.rb +++ b/spec/lib/gitlab/metrics/samplers/unicorn_sampler_spec.rb @@ -39,8 +39,8 @@ describe Gitlab::Metrics::Samplers::UnicornSampler do it 'updates metrics type unix and with addr' do labels = { socket_type: 'unix', socket_address: socket_address } - expect(subject.metrics[:unicorn_active_connections]).to receive(:set).with(labels, 'active') - expect(subject.metrics[:unicorn_queued_connections]).to receive(:set).with(labels, 'queued') + expect(subject).to receive_message_chain(:unicorn_active_connections, :set).with(labels, 'active') + expect(subject).to receive_message_chain(:unicorn_queued_connections, :set).with(labels, 'queued') subject.sample end @@ -50,6 +50,7 @@ describe Gitlab::Metrics::Samplers::UnicornSampler do context 'unicorn listens on tcp sockets' do let(:tcp_socket_address) { '0.0.0.0:8080' } let(:tcp_sockets) { [tcp_socket_address] } + before do allow(unicorn).to receive(:listener_names).and_return(tcp_sockets) end @@ -70,29 +71,13 @@ describe Gitlab::Metrics::Samplers::UnicornSampler do it 'updates metrics type unix and with addr' do labels = { socket_type: 'tcp', socket_address: tcp_socket_address } - expect(subject.metrics[:unicorn_active_connections]).to receive(:set).with(labels, 'active') - expect(subject.metrics[:unicorn_queued_connections]).to receive(:set).with(labels, 'queued') + expect(subject).to receive_message_chain(:unicorn_active_connections, :set).with(labels, 'active') + expect(subject).to receive_message_chain(:unicorn_queued_connections, :set).with(labels, 'queued') subject.sample end end end - - context 'additional metrics' do - let(:unicorn_workers) { 2 } - - before do - allow(unicorn).to receive(:listener_names).and_return([""]) - allow(::Gitlab::Metrics::System).to receive(:cpu_time).and_return(3.14) - allow(subject).to receive(:unicorn_workers_count).and_return(unicorn_workers) - end - - it "sets additional metrics" do - expect(subject.metrics[:unicorn_workers]).to receive(:set).with({}, unicorn_workers) - - subject.sample - end - end end describe '#start' do diff --git a/spec/lib/gitlab/metrics/system_spec.rb b/spec/lib/gitlab/metrics/system_spec.rb index b0603d96eb2..14afcdf5daa 100644 --- a/spec/lib/gitlab/metrics/system_spec.rb +++ b/spec/lib/gitlab/metrics/system_spec.rb @@ -13,18 +13,6 @@ describe Gitlab::Metrics::System do expect(described_class.file_descriptor_count).to be > 0 end end - - describe '.max_open_file_descriptors' do - it 'returns the max allowed open file descriptors' 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 @@ -37,18 +25,6 @@ describe Gitlab::Metrics::System do expect(described_class.file_descriptor_count).to eq(0) end end - - describe '.max_open_file_descriptors' do - it 'returns 0' 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 |