Commit 3013aa03 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'sh-geo-improve-node-status' into 'master'

Add more details to Geo health check status message

See merge request !1951
parents cc572c43 b08831c4
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
.geo-health { .geo-health {
display: inline-block; display: inline-block;
margin-top: 5px; margin-top: 5px;
white-space: pre-wrap;
} }
.node-badge { .node-badge {
......
...@@ -22,7 +22,16 @@ module Geo ...@@ -22,7 +22,16 @@ module Geo
if response.success? if response.success?
response.parsed_response.values_at(*KEYS) response.parsed_response.values_at(*KEYS)
else else
["Could not connect to Geo node - HTTP Status Code: #{response.code}"] message = "Could not connect to Geo node - HTTP Status Code: #{response.code} #{response.message}"
payload = response.parsed_response
details =
if payload.is_a?(Hash)
payload['message']
else
payload
end
Array([message, details].compact.join("\n"))
end end
rescue HTTParty::Error, Timeout::Error, SocketError, Errno::ECONNRESET, Errno::ECONNREFUSED => e rescue HTTParty::Error, Timeout::Error, SocketError, Errno::ECONNRESET, Errno::ECONNREFUSED => e
[e.message] [e.message]
......
require 'spec_helper'
describe Geo::NodeStatusService, services: true do
let!(:primary) { create(:geo_node, :primary) }
let(:secondary) { create(:geo_node) }
subject { described_class.new }
before do
allow(described_class).to receive(:current_node) { primary }
end
describe '#call' do
it 'parses a 401 response' do
request = double(success?: false,
code: 401,
message: 'Unauthorized',
parsed_response: { 'message' => 'Test' } )
allow(described_class).to receive(:get).and_return(request)
status = subject.call(secondary)
expect(status.health).to eq("Could not connect to Geo node - HTTP Status Code: 401 Unauthorized\nTest")
end
it 'parses a 200 response' do
data = { health: 'OK',
repositories_count: 10,
repositories_synced_count: 1,
repositories_failed_count: 2,
lfs_objects_count: 100,
lfs_objects_synced_count: 50,
attachments_count: 30,
attachments_synced_count: 30 }
request = double(success?: true, parsed_response: data.stringify_keys, code: 200)
allow(described_class).to receive(:get).and_return(request)
status = subject.call(secondary)
expect(status).to have_attributes(data)
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