@@ -21,14 +21,18 @@ def test_replica_switchover(self):
2121 over the course of several switchovers
2222 https://www.postgresql.org/message-id/54b059d4-2b48-13a4-6f43-95a087c92367%40postgrespro.ru
2323 """
24-
2524fname = self .id ().split ('.' )[3 ]
2625backup_dir = os .path .join (self .tmp_path ,module_name ,fname ,'backup' )
2726node1 = self .make_simple_node (
2827base_dir = os .path .join (module_name ,fname ,'node1' ),
2928set_replication = True ,
3029initdb_params = ['--data-checksums' ])
3130
31+ if self .get_version (node1 )< self .version_to_num ('9.6.0' ):
32+ self .del_test_dir (module_name ,fname )
33+ return unittest .skip (
34+ 'Skipped because backup from replica is not supported in PG 9.5' )
35+
3236self .init_pb (backup_dir )
3337self .add_instance (backup_dir ,'node1' ,node1 )
3438
@@ -287,6 +291,16 @@ def test_replica_archive_page_backup(self):
287291
288292self .wait_until_replica_catch_with_master (master ,replica )
289293
294+ master .pgbench_init (scale = 5 )
295+ # Continuous making some changes on master,
296+ # because WAL archiving on replica in idle DB in PostgreSQL is broken:
297+ # replica will not archive the previous WAL until it receives new records in the next WAL file,
298+ # this "lazy" archiving can be seen in src/backend/replication/walreceiver.c:XLogWalRcvWrite()
299+ # (see !XLByteInSeg checking and XLogArchiveNotify() calling).
300+ pgbench = master .pgbench (
301+ stdout = subprocess .PIPE ,stderr = subprocess .STDOUT ,
302+ options = ['-T' ,'3' ,'-c' ,'1' ,'--no-vacuum' ])
303+
290304backup_id = self .backup_node (
291305backup_dir ,'replica' ,replica ,
292306options = [
@@ -295,6 +309,9 @@ def test_replica_archive_page_backup(self):
295309'--master-db=postgres' ,
296310'--master-port={0}' .format (master .port )])
297311
312+ pgbench .wait ()
313+ pgbench .stdout .close ()
314+
298315self .validate_pb (backup_dir ,'replica' )
299316self .assertEqual (
300317'OK' ,self .show_pb (backup_dir ,'replica' ,backup_id )['status' ])
@@ -317,8 +334,6 @@ def test_replica_archive_page_backup(self):
317334# Change data on master, make PAGE backup from replica,
318335# restore taken backup and check that restored data equal
319336# to original data
320- master .pgbench_init (scale = 5 )
321-
322337pgbench = master .pgbench (
323338options = ['-T' ,'30' ,'-c' ,'2' ,'--no-vacuum' ])
324339
@@ -535,6 +550,11 @@ def test_replica_promote(self):
535550 start backup from replica, during backup promote replica
536551 check that backup is failed
537552 """
553+ if not self .gdb :
554+ self .skipTest (
555+ "Specify PGPROBACKUP_GDB and build without "
556+ "optimizations for run this test"
557+ )
538558fname = self .id ().split ('.' )[3 ]
539559backup_dir = os .path .join (self .tmp_path ,module_name ,fname ,'backup' )
540560master = self .make_simple_node (
@@ -706,6 +726,7 @@ def test_replica_stop_lsn_null_offset(self):
706726output )
707727
708728# Clean after yourself
729+ gdb_checkpointer .kill ()
709730self .del_test_dir (module_name ,fname )
710731
711732# @unittest.skip("skip")
@@ -1085,6 +1106,7 @@ def test_replica_toast(self):
10851106self .compare_pgdata (pgdata ,pgdata_restored )
10861107
10871108# Clean after yourself
1109+ gdb_checkpointer .kill ()
10881110self .del_test_dir (module_name ,fname )
10891111
10901112# @unittest.skip("skip")
@@ -1313,6 +1335,11 @@ def test_replica_promote_archive_delta(self):
13131335'checkpoint_timeout' :'30s' ,
13141336'archive_timeout' :'30s' })
13151337
1338+ if self .get_version (node1 )< self .version_to_num ('9.6.0' ):
1339+ self .del_test_dir (module_name ,fname )
1340+ return unittest .skip (
1341+ 'Skipped because backup from replica is not supported in PG 9.5' )
1342+
13161343self .init_pb (backup_dir )
13171344self .add_instance (backup_dir ,'node' ,node1 )
13181345self .set_config (
@@ -1433,6 +1460,11 @@ def test_replica_promote_archive_page(self):
14331460'checkpoint_timeout' :'30s' ,
14341461'archive_timeout' :'30s' })
14351462
1463+ if self .get_version (node1 )< self .version_to_num ('9.6.0' ):
1464+ self .del_test_dir (module_name ,fname )
1465+ return unittest .skip (
1466+ 'Skipped because backup from replica is not supported in PG 9.5' )
1467+
14361468self .init_pb (backup_dir )
14371469self .add_instance (backup_dir ,'node' ,node1 )
14381470self .set_archiving (backup_dir ,'node' ,node1 )
@@ -1550,6 +1582,11 @@ def test_parent_choosing(self):
15501582set_replication = True ,
15511583initdb_params = ['--data-checksums' ])
15521584
1585+ if self .get_version (master )< self .version_to_num ('9.6.0' ):
1586+ self .del_test_dir (module_name ,fname )
1587+ return unittest .skip (
1588+ 'Skipped because backup from replica is not supported in PG 9.5' )
1589+
15531590self .init_pb (backup_dir )
15541591self .add_instance (backup_dir ,'master' ,master )
15551592