@@ -2485,23 +2485,13 @@ def test_archive_empty_history_file(self):
2485
2485
node = self .make_simple_node (
2486
2486
base_dir = os .path .join (module_name , fname , 'node' ),
2487
2487
set_replication = True ,
2488
- initdb_params = ['--data-checksums' ],
2489
- pg_options = {
2490
- 'archive_timeout' : '30s' ,
2491
- 'checkpoint_timeout' : '30s' ,
2492
- 'autovacuum' : 'off' })
2493
-
2494
- if self .get_version (node ) < self .version_to_num ('9.6.0' ):
2495
- self .del_test_dir (module_name , fname )
2496
- return unittest .skip (
2497
- 'Skipped because backup from replica is not supported in PG 9.5' )
2488
+ initdb_params = ['--data-checksums' ])
2498
2489
2499
2490
self .init_pb (backup_dir )
2500
2491
self .add_instance (backup_dir , 'node' , node )
2501
2492
self .set_archiving (backup_dir , 'node' , node )
2502
2493
2503
2494
node .slow_start ()
2504
-
2505
2495
node .pgbench_init (scale = 5 )
2506
2496
2507
2497
# FULL
@@ -2516,7 +2506,6 @@ def test_archive_empty_history_file(self):
2516
2506
'--recovery-target=latest' ,
2517
2507
'--recovery-target-action=promote' ])
2518
2508
2519
- # '--recovery-target-timeline=2',
2520
2509
# Node in timeline 2
2521
2510
node .slow_start ()
2522
2511
@@ -2545,22 +2534,35 @@ def test_archive_empty_history_file(self):
2545
2534
2546
2535
# Node in timeline 4
2547
2536
node .slow_start ()
2548
- node .pgbench_init (scale = 1 )
2537
+ node .pgbench_init (scale = 5 )
2549
2538
2550
2539
# Truncate history files
2551
- for tli in range (2 , 4 ):
2540
+ for tli in range (2 , 5 ):
2552
2541
file = os .path .join (
2553
2542
backup_dir , 'wal' , 'node' , '0000000{0}.history' .format (tli ))
2554
2543
with open (file , "w+" ) as f :
2555
2544
f .truncate ()
2556
2545
2557
- show = self .show_archive (backup_dir , 'node' )
2546
+ timelines = self .show_archive (backup_dir , 'node' , options = [ '--log-level-file=INFO' ] )
2558
2547
2559
- timelines = show ['timelines' ]
2548
+ # check that all timelines has zero switchpoint
2549
+ for timeline in timelines :
2550
+ self .assertEqual (timeline ['switchpoint' ], '0/0' )
2560
2551
2561
- # check that all timelines are ok
2562
- for timeline in replica_timelines :
2563
- print (timeline )
2552
+ log_file = os .path .join (backup_dir , 'log' , 'pg_probackup.log' )
2553
+ with open (log_file , 'r' ) as f :
2554
+ log_content = f .read ()
2555
+ wal_dir = os .path .join (backup_dir , 'wal' , 'node' )
2556
+
2557
+ self .assertIn (
2558
+ 'WARNING: History file is corrupted: "{0}"' .format (os .path .join (wal_dir , '00000002.history' )),
2559
+ log_content )
2560
+ self .assertIn (
2561
+ 'WARNING: History file is corrupted: "{0}"' .format (os .path .join (wal_dir , '00000003.history' )),
2562
+ log_content )
2563
+ self .assertIn (
2564
+ 'WARNING: History file is corrupted: "{0}"' .format (os .path .join (wal_dir , '00000004.history' )),
2565
+ log_content )
2564
2566
2565
2567
self .del_test_dir (module_name , fname )
2566
2568
0 commit comments