@@ -411,61 +411,9 @@ def test_arhive_push_file_exists_overwrite(self):
411411# Clean after yourself
412412self .del_test_dir (module_name ,fname )
413413
414- # @unittest.skip("skip")
415- def test_arhive_push_partial_file_exists (self ):
416- """Archive-push if file exists"""
417- fname = self .id ().split ('.' )[3 ]
418- backup_dir = os .path .join (self .tmp_path ,module_name ,fname ,'backup' )
419- node = self .make_simple_node (
420- base_dir = os .path .join (module_name ,fname ,'node' ),
421- set_replication = True ,
422- initdb_params = ['--data-checksums' ])
423-
424- self .init_pb (backup_dir )
425- self .add_instance (backup_dir ,'node' ,node )
426- self .set_archiving (backup_dir ,'node' ,node )
427-
428- node .slow_start ()
429- node .safe_psql (
430- "postgres" ,
431- "create table t_heap as select i as id, md5(i::text) as text, "
432- "md5(repeat(i::text,10))::tsvector as tsvector "
433- "from generate_series(0,100500) i" )
434-
435- filename = node .safe_psql (
436- "postgres" ,
437- "SELECT file_name "
438- "FROM pg_walfile_name_offset(pg_current_wal_flush_lsn());" ).rstrip ()
439-
440- wals_dir = os .path .join (backup_dir ,'wal' ,'node' )
441- if self .archive_compress :
442- filename = filename + '.gz' + '.partial'
443- file = os .path .join (wals_dir ,filename )
444- else :
445- filename = filename + '.partial'
446- file = os .path .join (wals_dir ,filename )
447-
448- with open (file ,'a' )as f :
449- f .write (b"blablablaadssaaaaaaaaaaaaaaa" )
450- f .flush ()
451- f .close ()
452-
453- self .switch_wal_segment (node )
454- sleep (15 )
455-
456- log_file = os .path .join (node .logs_dir ,'postgresql.log' )
457- with open (log_file ,'r' )as f :
458- log_content = f .read ()
459- self .assertIn (
460- 'Reusing stale destination temporary WAL file' ,
461- log_content )
462-
463- # Clean after yourself
464- self .del_test_dir (module_name ,fname )
465-
466414# @unittest.skip("skip")
467415def test_archive_push_partial_file_exists (self ):
468- """Archive-push if file exists"""
416+ """Archive-push ifstale .partial file exists"""
469417fname = self .id ().split ('.' )[3 ]
470418backup_dir = os .path .join (self .tmp_path ,module_name ,fname ,'backup' )
471419node = self .make_simple_node (
@@ -479,20 +427,23 @@ def test_archive_push_partial_file_exists(self):
479427
480428node .slow_start ()
481429
430+ # this backup is needed only for validation to xid
431+ self .backup_node (backup_dir ,'node' ,node )
432+
482433node .safe_psql (
483434"postgres" ,
484- "create table t1()" )
485- self .switch_wal_segment (node )
435+ "create table t1(a int)" )
486436
487- node .safe_psql (
437+ xid = node .safe_psql (
488438"postgres" ,
489- "create table t2()" )
439+ "INSERT INTO t1 VALUES (1) RETURNING (xmin)" ). rstrip ( )
490440
491441filename_orig = node .safe_psql (
492442"postgres" ,
493443"SELECT file_name "
494444"FROM pg_walfile_name_offset(pg_current_wal_flush_lsn());" ).rstrip ()
495445
446+ # form up path to next .partial WAL segment
496447wals_dir = os .path .join (backup_dir ,'wal' ,'node' )
497448if self .archive_compress :
498449filename = filename_orig + '.gz' + '.partial'
@@ -502,7 +453,7 @@ def test_archive_push_partial_file_exists(self):
502453file = os .path .join (wals_dir ,filename )
503454
504455with open (file ,'a' )as f :
505- f .write (b"blablablaadssaaaaaaaaaaaaaaa " )
456+ f .write (b"blahblah " )
506457f .flush ()
507458f .close ()
508459
@@ -517,6 +468,10 @@ def test_archive_push_partial_file_exists(self):
517468
518469self .assertTrue (os .path .isfile (file ))
519470
471+ self .validate_pb (
472+ backup_dir ,'node' ,
473+ options = ['--recovery-target-xid={0}' .format (xid )])
474+
520475# log_file = os.path.join(node.logs_dir, 'postgresql.log')
521476# with open(log_file, 'r') as f:
522477# log_content = f.read()
@@ -529,7 +484,7 @@ def test_archive_push_partial_file_exists(self):
529484
530485# @unittest.skip("skip")
531486def test_archive_push_partial_file_exists_not_stale (self ):
532- """Archive-push if file exists"""
487+ """Archive-push if.partial file exists and it is not stale """
533488fname = self .id ().split ('.' )[3 ]
534489backup_dir = os .path .join (self .tmp_path ,module_name ,fname ,'backup' )
535490node = self .make_simple_node (
@@ -557,6 +512,7 @@ def test_archive_push_partial_file_exists_not_stale(self):
557512"SELECT file_name "
558513"FROM pg_walfile_name_offset(pg_current_wal_flush_lsn());" ).rstrip ()
559514
515+ # form up path to next .partial WAL segment
560516wals_dir = os .path .join (backup_dir ,'wal' ,'node' )
561517if self .archive_compress :
562518filename = filename_orig + '.gz' + '.partial'