return'Geo database configuration file is missing.'unlessGitlab::Geo.geo_database_configured?
return'Geo database configuration file is missing.'unlessGitlab::Geo.geo_database_configured?
return'Geo node has a database that is not configured for streaming replication with the primary node.'unlessGitlab::Database.db_read_only?
return'Geo node has a database that is writable which is an indication it is not configured for replication with the primary node.'unlessGitlab::Database.db_read_only?
return'Geo node does not appear to be replicating the database from the primary node.'ifGitlab::Database.pg_stat_wal_receiver_supported?&&!streaming_active?
return'Geo node does not appear to be replicating the database from the primary node.'ifreplication_enabled?&&!replication_working?
return"Current Geo database version (#{database_version}) does not match latest migration (#{migration_version}).\nYou may have to run `gitlab-rake geo:db:migrate` as root on the secondary."unlessdatabase_migration_version_match?
return"Geo database version (#{database_version}) does not match latest migration (#{migration_version}).\nYou may have to run `gitlab-rake geo:db:migrate` as root on the secondary."unlessdatabase_migration_version_match?
return'Geo database is not configured to use Foreign Data Wrapper.'unlessGitlab::Geo::Fdw.enabled?
return'Geo database is not configured to use Foreign Data Wrapper.'unlessGitlab::Geo::Fdw.enabled?
@@ -61,26 +61,48 @@ describe Gitlab::Geo::HealthCheck, :geo do
...
@@ -61,26 +61,48 @@ describe Gitlab::Geo::HealthCheck, :geo do
let(:db_read_only){false}
let(:db_read_only){false}
it'returns an error'do
it'returns an error'do
expect(subject.perform_checks).toinclude('Geo node has a database that is not configured for streaming replication with the primary node.')
expect(subject.perform_checks).toinclude('Geo node has a database that is writable which is an indication it is not configured for replication with the primary node.')
end
end
end
end
context'streaming replication'do
context'streaming replication'do
it'returns an error when replication is not working'do
allow(ActiveRecord::Base).toreceive_message_chain('connection.execute').with(no_args).with('SELECT * FROM pg_last_xlog_receive_location() as result').and_return(['result'=>'fake'])
allow(ActiveRecord::Base).toreceive_message_chain('connection.select_values').with(no_args).with('SELECT pid FROM pg_stat_wal_receiver').and_return([])
expect(subject.perform_checks).tomatch(/Geo node does not appear to be replicating the database from the primary node/)
end
end
context'archive recovery replication'do
it'returns an error when replication is not working'do
allow(ActiveRecord::Base).toreceive_message_chain('connection.execute').with(no_args).with('SELECT * FROM pg_last_xact_replay_timestamp() as result').and_return([{'result'=>nil}])
expect(subject.perform_checks).tomatch(/Geo node does not appear to be replicating the database from the primary node/)
allow(ActiveRecord::Base).toreceive_message_chain('connection.select_values').with(no_args).with('SELECT pid FROM pg_stat_wal_receiver').and_return([])
expect(subject.perform_checks).tomatch(/Geo node does not appear to be replicating the database from the primary node/)
expect(subject.perform_checks).tomatch(/Geo node does not appear to be replicating the database from the primary node/)
end
end
end
end
context'that is supported and working'do
context'that is working'do
beforedo
beforedo
allow(ActiveRecord::Base).toreceive_message_chain('connection.select_values').with(no_args).with('SELECT pid FROM pg_stat_wal_receiver').and_return(['123'])