@@ -424,6 +424,60 @@ def test_page_corruption_heal_via_ptrack_2(self):
424
424
# Clean after yourself
425
425
self .del_test_dir (module_name , fname )
426
426
427
+ # @unittest.skip("skip")
428
+ def test_backup_detect_corruption (self ):
429
+ """make node, corrupt some page, check that backup failed"""
430
+ fname = self .id ().split ('.' )[3 ]
431
+ node = self .make_simple_node (
432
+ base_dir = os .path .join (module_name , fname , 'node' ),
433
+ set_replication = True ,
434
+ initdb_params = ['--data-checksums' ])
435
+
436
+ backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
437
+
438
+ self .init_pb (backup_dir )
439
+ self .add_instance (backup_dir , 'node' , node )
440
+ node .slow_start ()
441
+
442
+ node .safe_psql (
443
+ "postgres" ,
444
+ "create table t_heap as select 1 as id, md5(i::text) as text, "
445
+ "md5(repeat(i::text,10))::tsvector as tsvector "
446
+ "from generate_series(0,1000) i" )
447
+ node .safe_psql (
448
+ "postgres" ,
449
+ "CHECKPOINT;" )
450
+
451
+ heap_path = node .safe_psql (
452
+ "postgres" ,
453
+ "select pg_relation_filepath('t_heap')" ).rstrip ()
454
+
455
+ with open (os .path .join (node .data_dir , heap_path ), "rb+" , 0 ) as f :
456
+ f .seek (9000 )
457
+ f .write (b"bla" )
458
+ f .flush ()
459
+ f .close
460
+
461
+ try :
462
+ self .backup_node (
463
+ backup_dir , 'node' , node ,
464
+ backup_type = "full" , options = ["-j" , "4" , "--stream" ])
465
+ # we should die here because exception is what we expect to happen
466
+ self .assertEqual (
467
+ 1 , 0 ,
468
+ "Expecting Error because tablespace mapping is incorrect"
469
+ "\n Output: {0} \n CMD: {1}" .format (
470
+ repr (self .output ), self .cmd ))
471
+ except ProbackupException as e :
472
+ self .assertIn (
473
+ 'Insert correct message' ,
474
+ e .message ,
475
+ '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
476
+ repr (e .message ), self .cmd ))
477
+
478
+ # Clean after yourself
479
+ self .del_test_dir (module_name , fname )
480
+
427
481
# @unittest.skip("skip")
428
482
def test_tablespace_in_pgdata_pgpro_1376 (self ):
429
483
"""PGPRO-1376 """
0 commit comments