@@ -324,7 +324,6 @@ def test_page_detect_corruption(self):
324324 node = self .make_simple_node (
325325 base_dir = os .path .join (module_name , fname , 'node' ),
326326 set_replication = True ,
327- ptrack_enable = True ,
328327 initdb_params = ['--data-checksums' ])
329328
330329 backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
@@ -356,26 +355,32 @@ def test_page_detect_corruption(self):
356355 "postgres" ,
357356 "select pg_relation_filepath('t_heap')" ).rstrip ()
358357
359- with open (os .path .join (node .data_dir , heap_path ), "rb+" , 0 ) as f :
358+ path = os .path .join (node .data_dir , heap_path )
359+ with open (path , "rb+" , 0 ) as f :
360360 f .seek (9000 )
361361 f .write (b"bla" )
362362 f .flush ()
363363 f .close
364364
365- self .backup_node (
366- backup_dir , 'node' , node , backup_type = "full" ,
367- options = ["-j" , "4" , "--stream" , "--log-level-file=VERBOSE" ])
368-
369- # open log file and check
370- with open (os .path .join (backup_dir , 'log' , 'pg_probackup.log' )) as f :
371- log_content = f .read ()
372- self .assertIn ('block 1, try to fetch via shared buffer' , log_content )
373- self .assertIn ('SELECT pg_catalog.pg_ptrack_get_block' , log_content )
374- f .close
365+ try :
366+ self .backup_node (
367+ backup_dir , 'node' , node , backup_type = "full" ,
368+ options = ["-j" , "4" , "--stream" , "--log-level-file=VERBOSE" ])
369+ self .assertEqual (
370+ 1 , 0 ,
371+ "Expecting Error because data file is corrupted"
372+ "\n Output: {0} \n CMD: {1}" .format (
373+ repr (self .output ), self .cmd ))
374+ except ProbackupException as e :
375+ self .assertTrue (
376+ 'ERROR: Corruption detected in file "{0}", '
377+ 'block 1: page verification failed, calculated checksum' .format (path ),
378+ e .message )
375379
376- self .assertTrue (
377- self .show_pb (backup_dir , 'node' )[1 ]['status' ] == 'OK' ,
378- "Backup Status should be OK" )
380+ self .assertEqual (
381+ self .show_pb (backup_dir , 'node' )[1 ]['status' ],
382+ 'ERROR' ,
383+ "Backup Status should be ERROR" )
379384
380385 # Clean after yourself
381386 self .del_test_dir (module_name , fname )
@@ -453,8 +458,8 @@ def test_backup_detect_corruption(self):
453458 repr (self .output ), self .cmd ))
454459 except ProbackupException as e :
455460 self .assertIn (
456- " ERROR: Corruption detected in file ' {0}' , block 1: "
457- " page verification failed, calculated checksum" .format (
461+ ' ERROR: Corruption detected in file " {0}" , block 1: '
462+ ' page verification failed, calculated checksum' .format (
458463 heap_fullpath ),
459464 e .message ,
460465 '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
@@ -474,8 +479,8 @@ def test_backup_detect_corruption(self):
474479 repr (self .output ), self .cmd ))
475480 except ProbackupException as e :
476481 self .assertIn (
477- " ERROR: Corruption detected in file ' {0}' , block 1: "
478- " page verification failed, calculated checksum" .format (
482+ ' ERROR: Corruption detected in file " {0}" , block 1: '
483+ ' page verification failed, calculated checksum' .format (
479484 heap_fullpath ),
480485 e .message ,
481486 '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
@@ -495,8 +500,8 @@ def test_backup_detect_corruption(self):
495500 repr (self .output ), self .cmd ))
496501 except ProbackupException as e :
497502 self .assertIn (
498- " ERROR: Corruption detected in file ' {0}' , block 1: "
499- " page verification failed, calculated checksum" .format (
503+ ' ERROR: Corruption detected in file " {0}" , block 1: '
504+ ' page verification failed, calculated checksum' .format (
500505 heap_fullpath ),
501506 e .message ,
502507 '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
@@ -598,8 +603,8 @@ def test_backup_detect_invalid_block_header(self):
598603 repr (self .output ), self .cmd ))
599604 except ProbackupException as e :
600605 self .assertIn (
601- " ERROR: Corruption detected in file ' {0}' , block 1: "
602- " page header invalid, pd_lower" .format (heap_fullpath ),
606+ ' ERROR: Corruption detected in file " {0}" , block 1: '
607+ ' page header invalid, pd_lower' .format (heap_fullpath ),
603608 e .message ,
604609 '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
605610 repr (e .message ), self .cmd ))
@@ -618,8 +623,8 @@ def test_backup_detect_invalid_block_header(self):
618623 repr (self .output ), self .cmd ))
619624 except ProbackupException as e :
620625 self .assertIn (
621- " ERROR: Corruption detected in file ' {0}' , block 1: "
622- " page header invalid, pd_lower" .format (heap_fullpath ),
626+ ' ERROR: Corruption detected in file " {0}" , block 1: '
627+ ' page header invalid, pd_lower' .format (heap_fullpath ),
623628 e .message ,
624629 '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
625630 repr (e .message ), self .cmd ))
@@ -638,8 +643,8 @@ def test_backup_detect_invalid_block_header(self):
638643 repr (self .output ), self .cmd ))
639644 except ProbackupException as e :
640645 self .assertIn (
641- " ERROR: Corruption detected in file ' {0}' , block 1: "
642- " page header invalid, pd_lower" .format (heap_fullpath ),
646+ ' ERROR: Corruption detected in file " {0}" , block 1: '
647+ ' page header invalid, pd_lower' .format (heap_fullpath ),
643648 e .message ,
644649 '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
645650 repr (e .message ), self .cmd ))
@@ -741,8 +746,8 @@ def test_backup_detect_missing_permissions(self):
741746 repr (self .output ), self .cmd ))
742747 except ProbackupException as e :
743748 self .assertIn (
744- " ERROR: Corruption detected in file ' {0}' , block 1: "
745- " page header invalid, pd_lower" .format (heap_fullpath ),
749+ ' ERROR: Corruption detected in file " {0}" , block 1: '
750+ ' page header invalid, pd_lower' .format (heap_fullpath ),
746751 e .message ,
747752 '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
748753 repr (e .message ), self .cmd ))
@@ -761,8 +766,8 @@ def test_backup_detect_missing_permissions(self):
761766 repr (self .output ), self .cmd ))
762767 except ProbackupException as e :
763768 self .assertIn (
764- " ERROR: Corruption detected in file ' {0}' , block 1: "
765- " page header invalid, pd_lower" .format (heap_fullpath ),
769+ ' ERROR: Corruption detected in file " {0}" , block 1: '
770+ ' page header invalid, pd_lower' .format (heap_fullpath ),
766771 e .message ,
767772 '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
768773 repr (e .message ), self .cmd ))
@@ -781,8 +786,8 @@ def test_backup_detect_missing_permissions(self):
781786 repr (self .output ), self .cmd ))
782787 except ProbackupException as e :
783788 self .assertIn (
784- " ERROR: Corruption detected in file ' {0}' , block 1: "
785- " page header invalid, pd_lower" .format (heap_fullpath ),
789+ ' ERROR: Corruption detected in file " {0}" , block 1: '
790+ ' page header invalid, pd_lower' .format (heap_fullpath ),
786791 e .message ,
787792 '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
788793 repr (e .message ), self .cmd ))
@@ -1385,8 +1390,8 @@ def test_drop_rel_during_backup_delta(self):
13851390 with open (os .path .join (backup_dir , 'log' , 'pg_probackup.log' )) as f :
13861391 log_content = f .read ()
13871392 self .assertTrue (
1388- " LOG: File ' {0}' is not found" .format (absolute_path ) in log_content ,
1389- " File ' {0}' should be deleted but it`s not" .format (absolute_path ))
1393+ ' LOG: File " {0}" is not found' .format (absolute_path ) in log_content ,
1394+ ' File " {0}" should be deleted but it`s not' .format (absolute_path ))
13901395
13911396 node .cleanup ()
13921397 self .restore_node (backup_dir , 'node' , node , options = ["-j" , "4" ])
0 commit comments