Commit ad6ac17c authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Added rescue block for the test method for the prometheus service

parent 91e8f770
---
title: Added rescue block for the test method
merge_request: 10994
author:
......@@ -49,7 +49,11 @@ module Gitlab
end
def get(url)
handle_response(HTTParty.get(url))
begin
handle_response(HTTParty.get(url))
rescue SocketError
raise PrometheusError, "Can't connect to #{url}"
end
end
def handle_response(response)
......
......@@ -93,11 +93,12 @@ describe PrometheusService, models: true, caching: true do
[404, 500].each do |status|
context "when Prometheus responds with #{status}" do
body_response = 'QUERY_FAILED'
before do
stub_all_prometheus_requests(environment.slug, status: status, body: 'QUERY FAILED!')
stub_all_prometheus_requests(environment.slug, status: status, body: body_response)
end
it { is_expected.to eq(success: false, result: %(#{status} - "QUERY FAILED!")) }
it { is_expected.to eq(success: false, result: %(#{status} - \"#{body_response}\")) }
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment