summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-05-05 13:50:03 +0000
committerRobert Speicher <robert@gitlab.com>2017-05-05 13:50:03 +0000
commit10c1bf2d77fd0ab21309d0b136cbc0ac11f56c77 (patch)
treeb171476c60bec5cacffbf1b65b09f83c8d6ce44f /spec/lib
parentfaf2ce89cd4eafdccb78823cf1a32c338a8d9a79 (diff)
parent6eb9e981c61969a904ccbae2c5f52f562b02d199 (diff)
downloadgitlab-ce-10c1bf2d77fd0ab21309d0b136cbc0ac11f56c77.tar.gz
Merge branch 'prometheus-integration-test-setting-fix' into 'master'
Added rescue block for the test method for the prometheus service Closes #31451 See merge request !10994
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/prometheus_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/lib/gitlab/prometheus_spec.rb b/spec/lib/gitlab/prometheus_spec.rb
index 280264188e2..fc453a2704b 100644
--- a/spec/lib/gitlab/prometheus_spec.rb
+++ b/spec/lib/gitlab/prometheus_spec.rb
@@ -49,6 +49,36 @@ describe Gitlab::Prometheus, lib: true do
end
end
+ describe 'failure to reach a provided prometheus url' do
+ let(:prometheus_url) {"https://prometheus.invalid.example.com"}
+
+ context 'exceptions are raised' do
+ it 'raises a Gitlab::PrometheusError error when a SocketError is rescued' do
+ req_stub = stub_prometheus_request_with_exception(prometheus_url, SocketError)
+
+ expect { subject.send(:get, prometheus_url) }
+ .to raise_error(Gitlab::PrometheusError, "Can't connect to #{prometheus_url}")
+ expect(req_stub).to have_been_requested
+ end
+
+ it 'raises a Gitlab::PrometheusError error when a SSLError is rescued' do
+ req_stub = stub_prometheus_request_with_exception(prometheus_url, OpenSSL::SSL::SSLError)
+
+ expect { subject.send(:get, prometheus_url) }
+ .to raise_error(Gitlab::PrometheusError, "#{prometheus_url} contains invalid SSL data")
+ expect(req_stub).to have_been_requested
+ end
+
+ it 'raises a Gitlab::PrometheusError error when a HTTParty::Error is rescued' do
+ req_stub = stub_prometheus_request_with_exception(prometheus_url, HTTParty::Error)
+
+ expect { subject.send(:get, prometheus_url) }
+ .to raise_error(Gitlab::PrometheusError, "Network connection error")
+ expect(req_stub).to have_been_requested
+ end
+ end
+ end
+
describe '#query' do
let(:prometheus_query) { prometheus_cpu_query('env-slug') }
let(:query_url) { prometheus_query_url(prometheus_query) }