mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Fix tests and formatting
This commit is contained in:
+8
-6
@@ -383,19 +383,21 @@ class RestApiHandler(BaseHTTPRequestHandler):
|
||||
to_char(pg_last_xact_replay_timestamp(), 'YYYY-MM-DD HH24:MI:SS.MS TZ'),
|
||||
pg_is_in_recovery() AND pg_is_xlog_replay_paused(),
|
||||
(SELECT json_agg(row_to_json(ri)) FROM replication_info ri)""", retry=retry)[0]
|
||||
|
||||
result = {
|
||||
'state': self.server.patroni.postgresql.state,
|
||||
'postmaster_start_time': row[0],
|
||||
'role': 'replica' if row[1] else 'master',
|
||||
'server_version': self.server.patroni.postgresql.server_version}
|
||||
if result['role'] == 'replica':
|
||||
result['xlog'] = {
|
||||
'server_version': self.server.patroni.postgresql.server_version,
|
||||
'xlog': ({
|
||||
'received_location': row[3],
|
||||
'replayed_location': row[4],
|
||||
'replayed_timestamp': row[5],
|
||||
'paused': row[6]}
|
||||
else:
|
||||
result['xlog'] = {'location': row[2]}
|
||||
'paused': row[6]} if row[1] else {
|
||||
'location': row[2]
|
||||
})
|
||||
}
|
||||
|
||||
if row[7]:
|
||||
result['replication'] = row[7]
|
||||
|
||||
|
||||
@@ -32,8 +32,9 @@ class MockCursor(object):
|
||||
self.results = [(0,)]
|
||||
elif sql == 'SELECT pg_is_in_recovery()':
|
||||
self.results = [(False, )]
|
||||
elif sql.startswith('SELECT to_char(pg_postmaster_start_time'):
|
||||
replication_info = '[{"application_name":"walreceiver","client_addr":"1.2.3.4","state":"streaming","sync_state":"async","sync_priority":0}]'
|
||||
elif sql.startswith('WITH replication_info AS ('):
|
||||
replication_info = '[{"application_name":"walreceiver","client_addr":"1.2.3.4",' +\
|
||||
'"state":"streaming","sync_state":"async","sync_priority":0}]'
|
||||
self.results = [('', True, '', '', '', '', False, replication_info)]
|
||||
elif sql.startswith('SELECT name, setting'):
|
||||
self.results = [('wal_segment_size', '2048', '8kB', 'integer', 'internal'),
|
||||
|
||||
Reference in New Issue
Block a user