diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-17 15:07:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-17 15:07:33 +0300 |
commit | 6b75320f525f841454f1ab162d141d3610f2e77b (patch) | |
tree | 4971c27759e4fbc18b85e71800c3b9c12346317e /spec/lib/gitlab/metrics | |
parent | 4226aca420920c1844e8eade4798a2dff188a6fc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/metrics')
-rw-r--r-- | spec/lib/gitlab/metrics/exporter/sidekiq_exporter_spec.rb | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/spec/lib/gitlab/metrics/exporter/sidekiq_exporter_spec.rb b/spec/lib/gitlab/metrics/exporter/sidekiq_exporter_spec.rb new file mode 100644 index 00000000000..a415b6407d5 --- /dev/null +++ b/spec/lib/gitlab/metrics/exporter/sidekiq_exporter_spec.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::Metrics::Exporter::SidekiqExporter do + let(:exporter) { described_class.new } + + after do + exporter.stop + end + + context 'with valid config' do + before do + stub_config( + monitoring: { + sidekiq_exporter: { + enabled: true, + port: 0, + address: '127.0.0.1' + } + } + ) + end + + it 'does start thread' do + expect(exporter.start).not_to be_nil + end + end + + context 'when port is already taken' do + let(:first_exporter) { described_class.new } + + before do + stub_config( + monitoring: { + sidekiq_exporter: { + enabled: true, + port: 9992, + address: '127.0.0.1' + } + } + ) + + first_exporter.start + end + + after do + first_exporter.stop + end + + it 'does print error message' do + expect(Sidekiq.logger).to receive(:error) + .with( + class: described_class.to_s, + message: 'Cannot start sidekiq_exporter', + exception: anything) + + exporter.start + end + + it 'does not start thread' do + expect(exporter.start).to be_nil + end + end +end |