Skip to content

Commit eb97837

Browse files
committed
fixes for pgpro561
1 parent 8972d4f commit eb97837

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

tests/pgpro561.py

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def __init__(self, *args, **kwargs):
1919

2020
def test_pgpro561(self):
2121
"""
22-
make node with archiving, make backup,
23-
restore it to node1 and node2, compare timelines
24-
EXPECT TO FAIL
22+
EXPECTED TO FAIL
23+
make node with archiving, make stream backup, restore it to node1,
24+
check that archiving is not successful on node1
2525
"""
2626
fname = self.id().split('.')[3]
2727
master = self.make_simple_node(base_dir="tmp_dirs/pgpro561/{0}/master".format(fname),
@@ -32,37 +32,28 @@ def test_pgpro561(self):
3232
)
3333
master.start()
3434

35+
self.assertEqual(self.init_pb(master), six.b(""))
36+
id = self.backup_pb(master, backup_type='full', options=["--stream"])
37+
3538
node1 = self.make_simple_node(base_dir="tmp_dirs/pgpro561/{0}/node1".format(fname))
36-
node2 = self.make_simple_node(base_dir="tmp_dirs/pgpro561/{0}/node2".format(fname))
3739
node1.cleanup()
38-
node2.cleanup()
39-
40-
self.assertEqual(self.init_pb(master), six.b(""))
41-
self.backup_pb(master, backup_type='full')
4240

4341
master.psql(
4442
"postgres",
4543
"create table t_heap as select i as id, md5(i::text) as text, md5(repeat(i::text,10))::tsvector as tsvector from generate_series(0,256) i")
46-
# for i in idx_ptrack:
47-
# if idx_ptrack[i]['type'] == 'heap':
48-
# continue
49-
# master.psql("postgres", "create index {0} on {1} using {2}({3})".format(
50-
# i, idx_ptrack[i]['relation'], idx_ptrack[i]['type'], idx_ptrack[i]['column']))
51-
#before = master.execute("postgres", "SELECT * FROM t_heap")
5244

53-
id = self.backup_pb(master, backup_type='page')
45+
self.backup_pb(master, backup_type='page', options=["--stream"])
5446
self.restore_pb(backup_dir=self.backup_dir(master), data_dir=node1.data_dir)
5547
node1.append_conf('postgresql.auto.conf', 'port = {0}'.format(node1.port))
56-
57-
self.restore_pb(backup_dir=self.backup_dir(master), data_dir=node2.data_dir)
58-
node2.append_conf('postgresql.auto.conf', 'port = {0}'.format(node2.port))
59-
6048
node1.start({"-t": "600"})
61-
node2.start({"-t": "600"})
6249

50+
timeline_master = master.get_control_data()["Latest checkpoint's TimeLineID"]
6351
timeline_node1 = node1.get_control_data()["Latest checkpoint's TimeLineID"]
64-
timeline_node2 = node2.get_control_data()["Latest checkpoint's TimeLineID"]
65-
self.assertEqual(timeline_node1, timeline_node2,
66-
"Node1 and Node2 timelines are different.\nWhich means that Node2 applied wals archived by Master AND Node1.\nWhich means that Master and Node1 have common archive.\nTHIS IS BAD\nCheck archive directory in {0}".format(os.path.join(self.backup_dir(master), "wal")))
67-
# node1.pgbench_init(scale=5)
68-
# node2.pgbench_init(scale=5)
52+
self.assertEqual(timeline_master, timeline_node1, "Timelines on Master and Node1 should be equal. This is unexpected")
53+
54+
archive_command_master = master.safe_psql("postgres", "show archive_command")
55+
archive_command_node1 = node1.safe_psql("postgres", "show archive_command")
56+
self.assertEqual(archive_command_master, archive_command_node1, "Archive command on Master and Node should be equal. This is unexpected")
57+
58+
res = node1.safe_psql("postgres", "select last_failed_wal from pg_stat_get_archiver() where last_failed_wal is not NULL")
59+
self.assertEqual(res, six.b(""), 'Restored Node1 failed to archive segment {0} due to having the same archive command as Master'.format(res.rstrip()))

0 commit comments

Comments
 (0)