debian-mirror-gitlab/spec/lib/gitlab/metrics/exporter/web_exporter_spec.rb

45 lines
1.1 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::Metrics::Exporter::WebExporter do
let(:exporter) { described_class.new }
2019-12-26 22:10:19 +05:30
let(:readiness_probe) { exporter.send(:readiness_probe).execute }
before do
stub_config(
monitoring: {
web_exporter: {
enabled: true,
port: 0,
address: '127.0.0.1'
2019-12-21 20:55:43 +05:30
}
2019-12-26 22:10:19 +05:30
}
)
2019-12-21 20:55:43 +05:30
2019-12-26 22:10:19 +05:30
exporter.start
end
2019-12-21 20:55:43 +05:30
2019-12-26 22:10:19 +05:30
after do
exporter.stop
end
2019-12-21 20:55:43 +05:30
2019-12-26 22:10:19 +05:30
context 'when running server' do
it 'readiness probe returns succesful status' do
expect(readiness_probe.http_status).to eq(200)
expect(readiness_probe.json).to include(status: 'ok')
expect(readiness_probe.json).to include('web_exporter' => [{ 'status': 'ok' }])
2019-12-21 20:55:43 +05:30
end
2019-12-26 22:10:19 +05:30
end
2019-12-21 20:55:43 +05:30
2019-12-26 22:10:19 +05:30
describe '#mark_as_not_running!' do
it 'readiness probe returns a failure status' do
exporter.mark_as_not_running!
2019-12-21 20:55:43 +05:30
2019-12-26 22:10:19 +05:30
expect(readiness_probe.http_status).to eq(503)
expect(readiness_probe.json).to include(status: 'failed')
expect(readiness_probe.json).to include('web_exporter' => [{ 'status': 'failed' }])
2019-12-21 20:55:43 +05:30
end
end
end