Commit 9e9748e6 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'tc-geo-primary-prometheus' into 'master'

Also log Prometheus metrics from the primary

Closes #5373

See merge request gitlab-org/gitlab-ee!5058
parents ede41e63 2a479268
......@@ -7,9 +7,9 @@ module Geo
if Gitlab::Geo.primary?
fetch_secondary_geo_nodes_metrics
else
fetch_current_geo_node_metrics
end
fetch_current_geo_node_metrics
end
private
......
---
title: Also log Geo Prometheus metrics from primary
merge_request: 5058
author:
type: added
......@@ -49,6 +49,22 @@ describe Geo::MetricsUpdateService, :geo do
}
end
let(:primary_data) do
{
success: true,
status_message: nil,
repositories_count: 10,
wikis_count: 10,
lfs_objects_count: 100,
job_artifacts_count: 100,
attachments_count: 30,
last_event_id: 2,
last_event_date: event_date,
event_log_count: 55,
event_log_max_id: 555
}
end
before do
allow(Gitlab::Metrics).to receive(:prometheus_metrics_enabled?).and_return(true)
end
......@@ -77,16 +93,19 @@ describe Geo::MetricsUpdateService, :geo do
end
it 'attempts to retrieve metrics from all nodes' do
allow(GeoNodeStatus).to receive(:current_node_status).and_return(GeoNodeStatus.from_json(primary_data.as_json))
subject.execute
expect(Gitlab::Metrics.registry.get(:geo_db_replication_lag_seconds).values.count).to eq(2)
expect(Gitlab::Metrics.registry.get(:geo_repositories).values.count).to eq(2)
expect(Gitlab::Metrics.registry.get(:geo_repositories).get({ url: secondary.url })).to eq(10)
expect(Gitlab::Metrics.registry.get(:geo_repositories).values.count).to eq(3)
expect(Gitlab::Metrics.registry.get(:geo_repositories).get({ url: secondary.url })).to eq(10)
expect(Gitlab::Metrics.registry.get(:geo_repositories).get({ url: another_secondary.url })).to eq(10)
expect(Gitlab::Metrics.registry.get(:geo_repositories).get({ url: primary.url })).to eq(10)
end
it 'updates the GeoNodeStatus entry' do
expect { subject.execute }.to change { GeoNodeStatus.count }.by(2)
expect { subject.execute }.to change { GeoNodeStatus.count }.by(3)
status = secondary.status.load_data_from_current_node
......@@ -97,7 +116,7 @@ describe Geo::MetricsUpdateService, :geo do
it 'updates only the active node' do
secondary.update_attributes(enabled: false)
expect { subject.execute }.to change { GeoNodeStatus.count }.by(1)
expect { subject.execute }.to change { GeoNodeStatus.count }.by(2)
expect(another_secondary.status).not_to be_nil
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