Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9ec6357

Browse files
committed
tests: fix ptrack_cluster
1 parent ff31602 commit 9ec6357

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

tests/ptrack_cluster.py

+21-12
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ def test_ptrack_cluster_on_btree_replica(self):
218218
master.safe_psql('postgres', 'vacuum t_heap')
219219
master.safe_psql('postgres', 'checkpoint')
220220

221+
self.backup_node(
222+
backup_dir, 'replica', replica, options=[
223+
'-j10', '--stream', '--master-host=localhost',
224+
'--master-db=postgres', '--master-port={0}'.format(
225+
master.port)])
226+
221227
for i in idx_ptrack:
222228
# get size of heap and indexes. size calculated in pages
223229
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
@@ -227,16 +233,19 @@ def test_ptrack_cluster_on_btree_replica(self):
227233
idx_ptrack[i]['old_pages'] = self.get_md5_per_page_for_fork(
228234
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
229235

230-
self.backup_node(
231-
backup_dir, 'replica', replica, options=[
232-
'-j10', '--stream', '--master-host=localhost',
233-
'--master-db=postgres', '--master-port={0}'.format(
234-
master.port)])
235-
236236
master.safe_psql('postgres', 'delete from t_heap where id%2 = 1')
237237
master.safe_psql('postgres', 'cluster t_heap using t_btree')
238238
master.safe_psql('postgres', 'checkpoint')
239239

240+
# Sync master and replica
241+
lsn = master.safe_psql(
242+
'postgres', 'SELECT pg_catalog.pg_current_wal_lsn()').rstrip()
243+
replica.poll_query_until(
244+
"postgres",
245+
"SELECT '{0}'::pg_lsn <= pg_last_wal_replay_lsn()".format(
246+
lsn))
247+
replica.safe_psql('postgres', 'checkpoint')
248+
240249
# CHECK PTRACK SANITY
241250
success = True
242251
for i in idx_ptrack:
@@ -322,6 +331,12 @@ def test_ptrack_cluster_on_gist_replica(self):
322331
lsn))
323332
replica.safe_psql('postgres', 'checkpoint')
324333

334+
self.backup_node(
335+
backup_dir, 'replica', replica, options=[
336+
'-j10', '--stream', '--master-host=localhost',
337+
'--master-db=postgres', '--master-port={0}'.format(
338+
master.port)])
339+
325340
for i in idx_ptrack:
326341
# get size of heap and indexes. size calculated in pages
327342
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
@@ -331,12 +346,6 @@ def test_ptrack_cluster_on_gist_replica(self):
331346
idx_ptrack[i]['old_pages'] = self.get_md5_per_page_for_fork(
332347
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
333348

334-
self.backup_node(
335-
backup_dir, 'replica', replica, options=[
336-
'-j10', '--stream', '--master-host=localhost',
337-
'--master-db=postgres', '--master-port={0}'.format(
338-
master.port)])
339-
340349
master.safe_psql('postgres', 'delete from t_heap where id%2 = 1')
341350
master.safe_psql('postgres', 'cluster t_heap using t_gist')
342351
master.safe_psql('postgres', 'checkpoint')

0 commit comments

Comments
 (0)