Commit 45e09f21 authored by Stan Hu's avatar Stan Hu

Simplify health check and spec

parent 248e6e3c
......@@ -55,8 +55,6 @@ module Gitlab
end
def self.database_secondary?
raise NotImplementedError unless Gitlab::Database.postgresql?
ActiveRecord::Base.connection.execute('SELECT pg_is_in_recovery()')
.first
.fetch('pg_is_in_recovery') == 't'
......@@ -64,8 +62,6 @@ module Gitlab
def self.db_replication_lag
# Obtain the replication lag in seconds
raise NotImplementedError unless Gitlab::Database.postgresql?
ActiveRecord::Base.connection.execute('
SELECT CASE
WHEN pg_last_xlog_receive_location() = pg_last_xlog_replay_location()
......
......@@ -30,7 +30,7 @@ describe Gitlab::Geo::HealthCheck, :postgresql do
allow(Gitlab::Geo).to receive(:secondary?) { true }
allow(Gitlab::Geo).to receive(:configured?) { true }
allow(Gitlab::Database).to receive(:postgresql?) { true }
allow(ActiveRecord::Base).to receive_message_chain(:connection, :execute, :first, :fetch) { 'f' }
allow(described_class).to receive(:database_secondary?) { false }
expect(subject.perform_checks).not_to be_blank
end
......@@ -39,7 +39,7 @@ describe Gitlab::Geo::HealthCheck, :postgresql do
allow(Gitlab::Geo).to receive(:secondary?) { true }
allow(Gitlab::Geo).to receive(:configured?) { true }
allow(Gitlab::Database).to receive(:postgresql?) { true }
allow(ActiveRecord::Base).to receive_message_chain(:connection, :execute, :first, :fetch) { 'f' }
allow(described_class).to receive(:database_secondary?) { false }
expect(subject.perform_checks).to include('not configured for streaming replication')
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