debian-mirror-gitlab/spec/lib/gitlab/metrics/prometheus_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1 KiB
Ruby
Raw Normal View History

2019-12-04 20:38:33 +05:30
# frozen_string_literal: true
2018-11-08 19:23:39 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Metrics::Prometheus, :prometheus do
2018-11-08 19:23:39 +05:30
let(:all_metrics) { Gitlab::Metrics }
let(:registry) { all_metrics.registry }
2020-01-12 00:16:45 +05:30
after do
all_metrics.clear_errors!
end
2018-11-08 19:23:39 +05:30
describe '#reset_registry!' do
it 'clears existing metrics' do
registry.counter(:test, 'test metric')
expect(registry.metrics.count).to eq(1)
all_metrics.reset_registry!
expect(all_metrics.registry.metrics.count).to eq(0)
end
end
2020-01-12 00:16:45 +05:30
describe '#error_detected!' do
before do
allow(all_metrics).to receive(:metrics_folder_present?).and_return(true)
stub_application_setting(prometheus_metrics_enabled: true)
end
it 'disables Prometheus metrics' do
expect(all_metrics.error?).to be_falsey
expect(all_metrics.prometheus_metrics_enabled?).to be_truthy
all_metrics.error_detected!
expect(all_metrics.prometheus_metrics_enabled?).to be_falsey
expect(all_metrics.error?).to be_truthy
end
end
2018-11-08 19:23:39 +05:30
end