@@ -19,9 +19,9 @@ def __init__(self, *args, **kwargs):
19
19
20
20
def test_pgpro561 (self ):
21
21
"""
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
25
25
"""
26
26
fname = self .id ().split ('.' )[3 ]
27
27
master = self .make_simple_node (base_dir = "tmp_dirs/pgpro561/{0}/master" .format (fname ),
@@ -32,37 +32,28 @@ def test_pgpro561(self):
32
32
)
33
33
master .start ()
34
34
35
+ self .assertEqual (self .init_pb (master ),six .b ("" ))
36
+ id = self .backup_pb (master ,backup_type = 'full' ,options = ["--stream" ])
37
+
35
38
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 ))
37
39
node1 .cleanup ()
38
- node2 .cleanup ()
39
-
40
- self .assertEqual (self .init_pb (master ),six .b ("" ))
41
- self .backup_pb (master ,backup_type = 'full' )
42
40
43
41
master .psql (
44
42
"postgres" ,
45
43
"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")
52
44
53
- id = self .backup_pb (master ,backup_type = 'page' )
45
+ self .backup_pb (master ,backup_type = 'page' , options = [ "--stream" ] )
54
46
self .restore_pb (backup_dir = self .backup_dir (master ),data_dir = node1 .data_dir )
55
47
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
-
60
48
node1 .start ({"-t" :"600" })
61
- node2 .start ({"-t" :"600" })
62
49
50
+ timeline_master = master .get_control_data ()["Latest checkpoint's TimeLineID" ]
63
51
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.\n Which means that Node2 applied wals archived by Master AND Node1.\n Which means that Master and Node1 have common archive.\n THIS IS BAD\n Check 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 ()))