@@ -147,10 +147,9 @@ def test_incremental_backup_without_full(self):
147147 "without valid full backup.\n Output: {0} \n CMD: {1}" .format (
148148 repr (self .output ), self .cmd ))
149149 except ProbackupException as e :
150- self .assertIn (
151- "ERROR: Valid backup on current timeline 1 is not found. "
152- "Create new FULL backup before an incremental one." ,
153- e .message ,
150+ self .assertTrue (
151+ "WARNING: Valid backup on current timeline 1 is not found" in e .message and
152+ "ERROR: Create new full backup before an incremental one" in e .message ,
154153 "\n Unexpected Error Message: {0}\n CMD: {1}" .format (
155154 repr (e .message ), self .cmd ))
156155
@@ -165,17 +164,20 @@ def test_incremental_backup_without_full(self):
165164 "without valid full backup.\n Output: {0} \n CMD: {1}" .format (
166165 repr (self .output ), self .cmd ))
167166 except ProbackupException as e :
168- self .assertIn (
169- "ERROR: Valid backup on current timeline 1 is not found. "
170- "Create new FULL backup before an incremental one." ,
171- e .message ,
167+ self .assertTrue (
168+ "WARNING: Valid backup on current timeline 1 is not found" in e .message and
169+ "ERROR: Create new full backup before an incremental one" in e .message ,
172170 "\n Unexpected Error Message: {0}\n CMD: {1}" .format (
173171 repr (e .message ), self .cmd ))
174172
175173 self .assertEqual (
176174 self .show_pb (backup_dir , 'node' )[0 ]['status' ],
177175 "ERROR" )
178176
177+ self .assertEqual (
178+ self .show_pb (backup_dir , 'node' )[1 ]['status' ],
179+ "ERROR" )
180+
179181 # Clean after yourself
180182 self .del_test_dir (module_name , fname )
181183
@@ -315,10 +317,8 @@ def test_ptrack_threads_stream(self):
315317 self .del_test_dir (module_name , fname )
316318
317319 # @unittest.skip("skip")
318- def test_page_corruption_heal_via_ptrack_1 (self ):
320+ def test_page_detect_corruption (self ):
319321 """make node, corrupt some page, check that backup failed"""
320- if not self .ptrack :
321- return unittest .skip ('Skipped because ptrack support is disabled' )
322322
323323 fname = self .id ().split ('.' )[3 ]
324324 node = self .make_simple_node (
@@ -380,98 +380,6 @@ def test_page_corruption_heal_via_ptrack_1(self):
380380 # Clean after yourself
381381 self .del_test_dir (module_name , fname )
382382
383- # @unittest.skip("skip")
384- def test_page_corruption_heal_via_ptrack_2 (self ):
385- """make node, corrupt some page, check that backup failed"""
386- if not self .ptrack :
387- return unittest .skip ('Skipped because ptrack support is disabled' )
388-
389- fname = self .id ().split ('.' )[3 ]
390- node = self .make_simple_node (
391- base_dir = os .path .join (module_name , fname , 'node' ),
392- set_replication = True ,
393- ptrack_enable = True ,
394- initdb_params = ['--data-checksums' ])
395-
396- backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
397-
398- self .init_pb (backup_dir )
399- self .add_instance (backup_dir , 'node' , node )
400- node .slow_start ()
401-
402- if node .major_version >= 12 :
403- node .safe_psql (
404- "postgres" ,
405- "CREATE EXTENSION ptrack WITH SCHEMA pg_catalog" )
406-
407- self .backup_node (
408- backup_dir , 'node' , node , backup_type = "full" ,
409- options = ["-j" , "4" , "--stream" ])
410-
411- node .safe_psql (
412- "postgres" ,
413- "create table t_heap as select 1 as id, md5(i::text) as text, "
414- "md5(repeat(i::text,10))::tsvector as tsvector "
415- "from generate_series(0,1000) i" )
416- node .safe_psql (
417- "postgres" ,
418- "CHECKPOINT;" )
419-
420- heap_path = node .safe_psql (
421- "postgres" ,
422- "select pg_relation_filepath('t_heap')" ).rstrip ()
423- node .stop ()
424-
425- with open (os .path .join (node .data_dir , heap_path ), "rb+" , 0 ) as f :
426- f .seek (9000 )
427- f .write (b"bla" )
428- f .flush ()
429- f .close
430- node .slow_start ()
431-
432- try :
433- self .backup_node (
434- backup_dir , 'node' , node , backup_type = "full" ,
435- options = ["-j" , "4" , "--stream" , '--log-level-console=LOG' ])
436- # we should die here because exception is what we expect to happen
437- self .assertEqual (
438- 1 , 0 ,
439- "Expecting Error because of page "
440- "corruption in PostgreSQL instance.\n "
441- " Output: {0} \n CMD: {1}" .format (
442- repr (self .output ), self .cmd ))
443- except ProbackupException as e :
444- if self .remote :
445- self .assertTrue (
446- "WARNING: File" in e .message and
447- "try to fetch via shared buffer" in e .message and
448- "WARNING: page verification failed, "
449- "calculated checksum" in e .message and
450- "ERROR: query failed: "
451- "ERROR: invalid page in block" in e .message and
452- "query was: SELECT pg_catalog.pg_ptrack_get_block" in e .message ,
453- "\n Unexpected Error Message: {0}\n CMD: {1}" .format (
454- repr (e .message ), self .cmd ))
455- else :
456- self .assertTrue (
457- "LOG: File" in e .message and
458- "blknum" in e .message and
459- "have wrong checksum" in e .message and
460- "try to fetch via shared buffer" in e .message and
461- "WARNING: page verification failed, "
462- "calculated checksum" in e .message and
463- "ERROR: query failed: "
464- "ERROR: invalid page in block" in e .message and
465- "query was: SELECT pg_catalog.pg_ptrack_get_block" in e .message ,
466- "\n Unexpected Error Message: {0}\n CMD: {1}" .format (
467- repr (e .message ), self .cmd ))
468-
469- self .assertTrue (
470- self .show_pb (backup_dir , 'node' )[1 ]['status' ] == 'ERROR' ,
471- "Backup Status should be ERROR" )
472-
473- # Clean after yourself
474- self .del_test_dir (module_name , fname )
475383
476384 # @unittest.skip("skip")
477385 def test_backup_detect_corruption (self ):
@@ -495,6 +403,10 @@ def test_backup_detect_corruption(self):
495403 "postgres" ,
496404 "create extension ptrack" )
497405
406+ self .backup_node (
407+ backup_dir , 'node' , node ,
408+ backup_type = "full" , options = ["-j" , "4" , "--stream" ])
409+
498410 node .safe_psql (
499411 "postgres" ,
500412 "create table t_heap as select 1 as id, md5(i::text) as text, "
@@ -529,10 +441,6 @@ def test_backup_detect_corruption(self):
529441
530442 node .slow_start ()
531443
532- # self.backup_node(
533- # backup_dir, 'node', node,
534- # backup_type="full", options=["-j", "4", "--stream"])
535-
536444 try :
537445 self .backup_node (
538446 backup_dir , 'node' , node ,
@@ -608,12 +516,11 @@ def test_backup_detect_corruption(self):
608516 "\n Output: {0} \n CMD: {1}" .format (
609517 repr (self .output ), self .cmd ))
610518 except ProbackupException as e :
611- self .assertTrue (
612- 'WARNING: page verification failed, '
613- 'calculated checksum' in e .message and
614- 'ERROR: query failed: ERROR: '
615- 'invalid page in block 1 of relation' in e .message and
616- 'ERROR: Data files transferring failed' in e .message ,
519+ self .assertIn (
520+ 'ERROR: Corruption detected in file "{0}", block 1: '
521+ 'page verification failed, calculated checksum' .format (
522+ heap_fullpath ),
523+ e .message ,
617524 '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
618525 repr (e .message ), self .cmd ))
619526
0 commit comments