@@ -1437,6 +1437,107 @@ def test_archive_catalog(self):
1437
1437
self .assertEqual (timeline_2 ['parent-tli' ], 1 )
1438
1438
self .assertEqual (timeline_1 ['parent-tli' ], 0 )
1439
1439
1440
+ self .del_test_dir (module_name , fname )
1441
+
1442
+ # @unittest.expectedFailure
1443
+ # @unittest.skip("skip")
1444
+ def test_archive_catalog_1 (self ):
1445
+ """
1446
+ double segment - compressed and not
1447
+ """
1448
+ fname = self .id ().split ('.' )[3 ]
1449
+ backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
1450
+ node = self .make_simple_node (
1451
+ base_dir = os .path .join (module_name , fname , 'node' ),
1452
+ set_replication = True ,
1453
+ initdb_params = ['--data-checksums' ],
1454
+ pg_options = {
1455
+ 'archive_timeout' : '30s' ,
1456
+ 'checkpoint_timeout' : '30s' ,
1457
+ 'autovacuum' : 'off' })
1458
+
1459
+ self .init_pb (backup_dir )
1460
+ self .add_instance (backup_dir , 'node' , node )
1461
+ self .set_archiving (backup_dir , 'node' , node , compress = True )
1462
+
1463
+ node .slow_start ()
1464
+
1465
+ # FULL
1466
+ self .backup_node (backup_dir , 'node' , node )
1467
+ node .pgbench_init (scale = 2 )
1468
+
1469
+ wals_dir = os .path .join (backup_dir , 'wal' , 'node' )
1470
+ original_file = os .path .join (wals_dir , '000000010000000000000001.gz' )
1471
+ tmp_file = os .path .join (wals_dir , '000000010000000000000001' )
1472
+
1473
+ with gzip .open (original_file , 'rb' ) as f_in , open (tmp_file , 'wb' ) as f_out :
1474
+ shutil .copyfileobj (f_in , f_out )
1475
+
1476
+ os .rename (
1477
+ os .path .join (wals_dir , '000000010000000000000001' ),
1478
+ os .path .join (wals_dir , '000000010000000000000002' ))
1479
+
1480
+ show = self .show_archive (backup_dir )
1481
+
1482
+ for instance in show :
1483
+ timelines = instance ['timelines' ]
1484
+
1485
+ # sanity
1486
+ for timeline in timelines :
1487
+ self .assertEqual (timeline ['min-segno' ], '0000000000000001' )
1488
+ self .assertEqual (timeline ['status' ], 'OK' )
1489
+
1490
+ self .del_test_dir (module_name , fname )
1491
+
1492
+ # @unittest.expectedFailure
1493
+ # @unittest.skip("skip")
1494
+ def test_archive_catalog_2 (self ):
1495
+ """
1496
+ double segment - compressed and not
1497
+ """
1498
+ fname = self .id ().split ('.' )[3 ]
1499
+ backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
1500
+ node = self .make_simple_node (
1501
+ base_dir = os .path .join (module_name , fname , 'node' ),
1502
+ set_replication = True ,
1503
+ initdb_params = ['--data-checksums' ],
1504
+ pg_options = {
1505
+ 'archive_timeout' : '30s' ,
1506
+ 'checkpoint_timeout' : '30s' ,
1507
+ 'autovacuum' : 'off' })
1508
+
1509
+ self .init_pb (backup_dir )
1510
+ self .add_instance (backup_dir , 'node' , node )
1511
+ self .set_archiving (backup_dir , 'node' , node , compress = True )
1512
+
1513
+ node .slow_start ()
1514
+
1515
+ # FULL
1516
+ self .backup_node (backup_dir , 'node' , node )
1517
+ node .pgbench_init (scale = 2 )
1518
+
1519
+ wals_dir = os .path .join (backup_dir , 'wal' , 'node' )
1520
+ original_file = os .path .join (wals_dir , '000000010000000000000001.gz' )
1521
+ tmp_file = os .path .join (wals_dir , '000000010000000000000001' )
1522
+
1523
+ with gzip .open (original_file , 'rb' ) as f_in , open (tmp_file , 'wb' ) as f_out :
1524
+ shutil .copyfileobj (f_in , f_out )
1525
+
1526
+ os .rename (
1527
+ os .path .join (wals_dir , '000000010000000000000001' ),
1528
+ os .path .join (wals_dir , '000000010000000000000002' ))
1529
+
1530
+ os .remove (original_file )
1531
+
1532
+ show = self .show_archive (backup_dir )
1533
+
1534
+ for instance in show :
1535
+ timelines = instance ['timelines' ]
1536
+
1537
+ # sanity
1538
+ for timeline in timelines :
1539
+ self .assertEqual (timeline ['min-segno' ], '0000000000000002' )
1540
+ self .assertEqual (timeline ['status' ], 'OK' )
1440
1541
1441
1542
self .del_test_dir (module_name , fname )
1442
1543
0 commit comments