Skip to content

Commit 88cc76d

Browse files
committed
compatibility fix for postgres 10
1 parent c69535a commit 88cc76d

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

testgres/testgres.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ def backup(self, name):
597597
backup_path = os.path.join(self.base_dir, name)
598598
os.makedirs(backup_path)
599599
params = [pg_basebackup, "-D", backup_path, "-p {}".format(
600-
self.port), "-x"]
600+
self.port), "-X", "fetch"]
601601
with open(self.output_filename, "a") as file_out, \
602602
open(self.error_filename, "a") as file_err:
603603
ret = subprocess.call(

testgres/tests/test_simple.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import tempfile
77
import logging.config
88

9-
from testgres import get_new_node, stop_all
9+
from testgres import get_new_node, stop_all, get_config
1010

1111

1212
class SimpleTest(unittest.TestCase):
@@ -41,15 +41,21 @@ def test_backup_and_replication(self):
4141
self.assertEqual(len(res), 1)
4242
self.assertEqual(res[0], (1, 2))
4343

44+
# Prepare the query which would check whether record reached replica
45+
# (It is slightly different for Postgres 9.6 and Postgres 10+)
46+
if get_config()['VERSION_NUM'] >= 1000000:
47+
wait_lsn = 'SELECT pg_current_wal_lsn() <= replay_lsn ' \
48+
'FROM pg_stat_replication WHERE application_name = \'%s\'' \
49+
% replica.name
50+
else:
51+
wait_lsn = 'SELECT pg_current_xlog_location() <= replay_location '\
52+
'FROM pg_stat_replication WHERE application_name = \'%s\'' \
53+
% replica.name
54+
4455
# Insert into master node
4556
node.psql('postgres', 'insert into abc values (3, 4)')
4657
# Wait until data syncronizes
47-
node.poll_query_until(
48-
'postgres',
49-
'SELECT pg_current_xlog_location() <= replay_location '
50-
'FROM pg_stat_replication WHERE application_name = \'%s\''
51-
% replica.name)
52-
# time.sleep(0.5)
58+
node.poll_query_until('postgres', wait_lsn)
5359
# Check that this record was exported to replica
5460
res = replica.execute('postgres', 'select * from abc')
5561
self.assertEqual(len(res), 2)
@@ -83,7 +89,7 @@ def test_users(self):
8389
self.assertEqual(value, six.b('1\n'))
8490

8591
def test_logging(self):
86-
regex = re.compile('\w+:\s{1}LOG:.*')
92+
regex = re.compile('.+?LOG:.*')
8793
logfile = tempfile.NamedTemporaryFile('w', delete=True)
8894

8995
log_conf = {

0 commit comments

Comments
 (0)