Added rescue block for the test method for the prometheus service
This commit is contained in:
parent
91e8f7702c
commit
ad6ac17c54
3 changed files with 12 additions and 3 deletions
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue