Skip to content

Commit f4686a4

Browse files
committed
improve test_backup_simple(), set max_attempts=0 in poll_query_until() by default
1 parent b9b1d01 commit f4686a4

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

Diff for: testgres/testgres.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ def poll_query_until(self,
915915
dbname,
916916
query,
917917
username=None,
918-
max_attempts=60,
918+
max_attempts=0,
919919
sleep_time=1,
920920
expected=True,
921921
raise_programming_error=True,
@@ -1027,7 +1027,7 @@ def replicate(self, name, username=None,
10271027
backup = self.backup(username=username, xlog_method=xlog_method)
10281028
return backup.spawn_replica(name, use_logging=use_logging)
10291029

1030-
def catchup(self):
1030+
def catchup(self, username=None):
10311031
"""
10321032
Wait until async replica catches up with its master.
10331033
"""
@@ -1049,7 +1049,10 @@ def catchup(self):
10491049

10501050
try:
10511051
lsn = master.execute('postgres', poll_lsn)[0][0]
1052-
self.poll_query_until('postgres', wait_lsn.format(lsn))
1052+
self.poll_query_until(dbname='postgres',
1053+
username=username,
1054+
query=wait_lsn.format(lsn),
1055+
max_attempts=0) # infinite
10531056
except Exception as e:
10541057
raise CatchUpException(_explain_exception(e))
10551058

Diff for: tests/test_simple.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,18 @@ def test_control_data(self):
195195

196196
def test_backup_simple(self):
197197
with get_new_node('master') as master:
198-
master.init(allow_streaming=True).start()
199198

199+
# enable streaming for backups
200+
master.init(allow_streaming=True)
201+
202+
# node must be running
203+
with self.assertRaises(BackupException):
204+
master.backup()
205+
206+
# it's time to start node
207+
master.start()
208+
209+
# fill node with some data
200210
master.psql('postgres',
201211
'create table test as select generate_series(1, 4) i')
202212

0 commit comments

Comments
 (0)