diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-04 09:06:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-04 09:06:05 +0300 |
commit | 535d167d40638105527bc6c9a86f33d2ffd62743 (patch) | |
tree | 27c73f33497378f6bb84840223ce7d3fda42cc0a /spec/lib/gitlab/metrics | |
parent | bee11af56deccfd13243cf5f31d42bd992404066 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/metrics')
-rw-r--r-- | spec/lib/gitlab/metrics/exporter/base_exporter_spec.rb (renamed from spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb) | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb b/spec/lib/gitlab/metrics/exporter/base_exporter_spec.rb index 9eea3eb79dc..5fd7438d28a 100644 --- a/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb +++ b/spec/lib/gitlab/metrics/exporter/base_exporter_spec.rb @@ -2,20 +2,29 @@ require 'spec_helper' -describe Gitlab::Metrics::SidekiqMetricsExporter do +describe Gitlab::Metrics::Exporter::BaseExporter do let(:exporter) { described_class.new } let(:server) { double('server') } + let(:socket) { double('socket') } + let(:log_filename) { File.join(Rails.root, 'log', 'sidekiq_exporter.log') } + let(:settings) { double('settings') } before do allow(::WEBrick::HTTPServer).to receive(:new).and_return(server) allow(server).to receive(:mount) allow(server).to receive(:start) allow(server).to receive(:shutdown) + allow(server).to receive(:listeners) { [socket] } + allow(socket).to receive(:close) + allow_any_instance_of(described_class).to receive(:log_filename).and_return(log_filename) + allow_any_instance_of(described_class).to receive(:settings).and_return(settings) end describe 'when exporter is enabled' do before do - allow(Settings.monitoring.sidekiq_exporter).to receive(:enabled).and_return(true) + allow(settings).to receive(:enabled).and_return(true) + allow(settings).to receive(:port).and_return(3707) + allow(settings).to receive(:address).and_return('localhost') end describe 'when exporter is stopped' do @@ -31,8 +40,8 @@ describe Gitlab::Metrics::SidekiqMetricsExporter do let(:address) { 'sidekiq_exporter_address' } before do - allow(Settings.monitoring.sidekiq_exporter).to receive(:port).and_return(port) - allow(Settings.monitoring.sidekiq_exporter).to receive(:address).and_return(address) + allow(settings).to receive(:port).and_return(port) + allow(settings).to receive(:address).and_return(address) end it 'starts server with port and address from settings' do @@ -74,6 +83,7 @@ describe Gitlab::Metrics::SidekiqMetricsExporter do it 'shutdowns server' do expect { exporter.stop }.to change { exporter.thread? }.from(true).to(false) + expect(socket).to have_received(:close) expect(server).to have_received(:shutdown) end end @@ -82,7 +92,7 @@ describe Gitlab::Metrics::SidekiqMetricsExporter do describe 'when exporter is disabled' do before do - allow(Settings.monitoring.sidekiq_exporter).to receive(:enabled).and_return(false) + allow(settings).to receive(:enabled).and_return(false) end describe '#start' do |