12
12
from testgres import QueryException
13
13
14
14
15
- module_name = 'restore '
15
+ module_name = 'incr_restore '
16
16
17
17
18
18
class IncrRestoreTest (ProbackupTest , unittest .TestCase ):
@@ -967,7 +967,7 @@ def test_incr_lsn_restore_backward(self):
967
967
print (self .restore_node (
968
968
backup_dir , 'node' , node , backup_id = full_id ,
969
969
options = [
970
- "-j" , "4" , '--incremental-mode=lsn' ,
970
+ "-j" , "4" , '--incremental-mode=lsn' , '--log-level-file=VERBOSE' ,
971
971
'--recovery-target=immediate' , '--recovery-target-action=pause' ]))
972
972
973
973
pgdata_restored = self .pgdata_content (node .data_dir )
@@ -1310,9 +1310,9 @@ def test_incr_checksum_long_xact(self):
1310
1310
1311
1311
node .stop ()
1312
1312
1313
- print ( self .restore_node (
1313
+ self .restore_node (
1314
1314
backup_dir , 'node' , node , backup_id = full_id ,
1315
- options = ["-j" , "4" , '--incremental-mode=checksum' ]))
1315
+ options = ["-j" , "4" , '--incremental-mode=checksum' ])
1316
1316
1317
1317
node .slow_start ()
1318
1318
@@ -1452,9 +1452,9 @@ def test_incr_lsn_long_xact_2(self):
1452
1452
backup_dir , 'node' , node ,
1453
1453
backup_type = "delta" , options = ["-j" , "4" , "--stream" ])
1454
1454
1455
- print (node .safe_psql (
1456
- 'postgres' ,
1457
- "select * from page_header(get_raw_page('t1', 0))" ))
1455
+ # print(node.safe_psql(
1456
+ # 'postgres',
1457
+ # "select * from page_header(get_raw_page('t1', 0))"))
1458
1458
1459
1459
con .commit ()
1460
1460
@@ -1463,26 +1463,24 @@ def test_incr_lsn_long_xact_2(self):
1463
1463
'postgres' ,
1464
1464
'select * from t1' )
1465
1465
1466
- print (node .safe_psql (
1467
- 'postgres' ,
1468
- "select * from page_header(get_raw_page('t1', 0))" ))
1469
-
1470
- print ("HELLO" )
1466
+ # print(node.safe_psql(
1467
+ # 'postgres',
1468
+ # "select * from page_header(get_raw_page('t1', 0))"))
1471
1469
1472
1470
con2 .commit ()
1473
1471
node .safe_psql (
1474
1472
'postgres' ,
1475
1473
'select * from t1' )
1476
1474
1477
- print (node .safe_psql (
1478
- 'postgres' ,
1479
- "select * from page_header(get_raw_page('t1', 0))" ))
1475
+ # print(node.safe_psql(
1476
+ # 'postgres',
1477
+ # "select * from page_header(get_raw_page('t1', 0))"))
1480
1478
1481
1479
node .stop ()
1482
1480
1483
- print ( self .restore_node (
1481
+ self .restore_node (
1484
1482
backup_dir , 'node' , node , backup_id = full_id ,
1485
- options = ["-j" , "4" , '--incremental-mode=lsn' ]))
1483
+ options = ["-j" , "4" , '--incremental-mode=lsn' ])
1486
1484
1487
1485
node .slow_start ()
1488
1486
@@ -1494,5 +1492,160 @@ def test_incr_lsn_long_xact_2(self):
1494
1492
1495
1493
# Clean after yourself
1496
1494
self .del_test_dir (module_name , fname )
1495
+
1496
+ # @unittest.skip("skip")
1497
+ # @unittest.expectedFailure
1498
+ def test_incr_restore_zero_size_file_checksum (self ):
1499
+ """
1500
+ """
1501
+ fname = self .id ().split ('.' )[3 ]
1502
+ node = self .make_simple_node (
1503
+ base_dir = os .path .join (module_name , fname , 'node' ),
1504
+ set_replication = True ,
1505
+ initdb_params = ['--data-checksums' ],
1506
+ pg_options = {'autovacuum' : 'off' })
1507
+
1508
+ backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
1509
+ self .init_pb (backup_dir )
1510
+ self .add_instance (backup_dir , 'node' , node )
1511
+ node .slow_start ()
1512
+
1513
+ fullpath = os .path .join (node .data_dir , 'simple_file' )
1514
+ with open (fullpath , "w" , 0 ) as f :
1515
+ f .flush ()
1516
+ f .close
1517
+
1518
+ # FULL backup
1519
+ id1 = self .backup_node (
1520
+ backup_dir , 'node' , node ,
1521
+ options = ["-j" , "4" , "--stream" ])
1522
+
1523
+ pgdata1 = self .pgdata_content (node .data_dir )
1524
+
1525
+ with open (fullpath , "rb+" , 0 ) as f :
1526
+ f .seek (9000 )
1527
+ f .write (b"bla" )
1528
+ f .flush ()
1529
+ f .close
1530
+
1531
+ id2 = self .backup_node (
1532
+ backup_dir , 'node' , node ,
1533
+ backup_type = "delta" , options = ["-j" , "4" , "--stream" ])
1534
+ pgdata2 = self .pgdata_content (node .data_dir )
1535
+
1536
+ with open (fullpath , "w" ) as f :
1537
+ f .close ()
1538
+
1539
+ id3 = self .backup_node (
1540
+ backup_dir , 'node' , node ,
1541
+ backup_type = "delta" , options = ["-j" , "4" , "--stream" ])
1542
+ pgdata3 = self .pgdata_content (node .data_dir )
1543
+
1544
+ node .stop ()
1545
+
1546
+ print (self .restore_node (
1547
+ backup_dir , 'node' , node , backup_id = id1 ,
1548
+ options = ["-j" , "4" , '-I' , 'checksum' ]))
1549
+
1550
+ pgdata_restored = self .pgdata_content (node .data_dir )
1551
+ self .compare_pgdata (pgdata1 , pgdata_restored )
1552
+
1553
+ self .restore_node (
1554
+ backup_dir , 'node' , node , backup_id = id2 ,
1555
+ options = ["-j" , "4" , '-I' , 'checksum' ])
1556
+
1557
+ pgdata_restored = self .pgdata_content (node .data_dir )
1558
+ self .compare_pgdata (pgdata2 , pgdata_restored )
1559
+
1560
+ self .restore_node (
1561
+ backup_dir , 'node' , node , backup_id = id3 ,
1562
+ options = ["-j" , "4" , '-I' , 'checksum' ])
1563
+
1564
+ pgdata_restored = self .pgdata_content (node .data_dir )
1565
+ self .compare_pgdata (pgdata3 , pgdata_restored )
1566
+
1567
+ # Clean after yourself
1568
+ self .del_test_dir (module_name , fname )
1569
+
1570
+ # @unittest.skip("skip")
1571
+ # @unittest.expectedFailure
1572
+ def test_incr_restore_zero_size_file_lsn (self ):
1573
+ """
1574
+ """
1575
+ fname = self .id ().split ('.' )[3 ]
1576
+ node = self .make_simple_node (
1577
+ base_dir = os .path .join (module_name , fname , 'node' ),
1578
+ set_replication = True ,
1579
+ initdb_params = ['--data-checksums' ],
1580
+ pg_options = {'autovacuum' : 'off' })
1581
+
1582
+ backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
1583
+ self .init_pb (backup_dir )
1584
+ self .add_instance (backup_dir , 'node' , node )
1585
+ node .slow_start ()
1586
+
1587
+ fullpath = os .path .join (node .data_dir , 'simple_file' )
1588
+ with open (fullpath , "w" , 0 ) as f :
1589
+ f .flush ()
1590
+ f .close
1591
+
1592
+ # FULL backup
1593
+ id1 = self .backup_node (
1594
+ backup_dir , 'node' , node ,
1595
+ options = ["-j" , "4" , "--stream" ])
1596
+
1597
+ pgdata1 = self .pgdata_content (node .data_dir )
1598
+
1599
+ with open (fullpath , "rb+" , 0 ) as f :
1600
+ f .seek (9000 )
1601
+ f .write (b"bla" )
1602
+ f .flush ()
1603
+ f .close
1604
+
1605
+ id2 = self .backup_node (
1606
+ backup_dir , 'node' , node ,
1607
+ backup_type = "delta" , options = ["-j" , "4" , "--stream" ])
1608
+ pgdata2 = self .pgdata_content (node .data_dir )
1609
+
1610
+ with open (fullpath , "w" ) as f :
1611
+ f .close ()
1612
+
1613
+ id3 = self .backup_node (
1614
+ backup_dir , 'node' , node ,
1615
+ backup_type = "delta" , options = ["-j" , "4" , "--stream" ])
1616
+ pgdata3 = self .pgdata_content (node .data_dir )
1617
+
1618
+ node .stop ()
1619
+
1620
+ print (self .restore_node (
1621
+ backup_dir , 'node' , node , backup_id = id1 ,
1622
+ options = ["-j" , "4" , '-I' , 'checksum' ]))
1623
+
1624
+ pgdata_restored = self .pgdata_content (node .data_dir )
1625
+ self .compare_pgdata (pgdata1 , pgdata_restored )
1626
+
1627
+ node .slow_start ()
1628
+ node .stop ()
1629
+
1630
+ self .restore_node (
1631
+ backup_dir , 'node' , node , backup_id = id2 ,
1632
+ options = ["-j" , "4" , '-I' , 'checksum' ])
1633
+
1634
+ pgdata_restored = self .pgdata_content (node .data_dir )
1635
+ self .compare_pgdata (pgdata2 , pgdata_restored )
1636
+
1637
+ node .slow_start ()
1638
+ node .stop ()
1639
+
1640
+ self .restore_node (
1641
+ backup_dir , 'node' , node , backup_id = id3 ,
1642
+ options = ["-j" , "4" , '-I' , 'checksum' ])
1643
+
1644
+ pgdata_restored = self .pgdata_content (node .data_dir )
1645
+ self .compare_pgdata (pgdata3 , pgdata_restored )
1646
+
1647
+ # Clean after yourself
1648
+ self .del_test_dir (module_name , fname )
1649
+
1497
1650
# check that MinRecPoint and BackupStartLsn are correctly used in case of --incrementa-lsn
1498
1651
# incremental restore + partial restore.
0 commit comments