1212from testgres import QueryException
1313
1414
15- module_name = 'restore '
15+ module_name = 'incr_restore '
1616
1717
1818class IncrRestoreTest (ProbackupTest , unittest .TestCase ):
@@ -967,7 +967,7 @@ def test_incr_lsn_restore_backward(self):
967967 print (self .restore_node (
968968 backup_dir , 'node' , node , backup_id = full_id ,
969969 options = [
970- "-j" , "4" , '--incremental-mode=lsn' ,
970+ "-j" , "4" , '--incremental-mode=lsn' , '--log-level-file=VERBOSE' ,
971971 '--recovery-target=immediate' , '--recovery-target-action=pause' ]))
972972
973973 pgdata_restored = self .pgdata_content (node .data_dir )
@@ -1310,9 +1310,9 @@ def test_incr_checksum_long_xact(self):
13101310
13111311 node .stop ()
13121312
1313- print ( self .restore_node (
1313+ self .restore_node (
13141314 backup_dir , 'node' , node , backup_id = full_id ,
1315- options = ["-j" , "4" , '--incremental-mode=checksum' ]))
1315+ options = ["-j" , "4" , '--incremental-mode=checksum' ])
13161316
13171317 node .slow_start ()
13181318
@@ -1452,9 +1452,9 @@ def test_incr_lsn_long_xact_2(self):
14521452 backup_dir , 'node' , node ,
14531453 backup_type = "delta" , options = ["-j" , "4" , "--stream" ])
14541454
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))"))
14581458
14591459 con .commit ()
14601460
@@ -1463,26 +1463,24 @@ def test_incr_lsn_long_xact_2(self):
14631463 'postgres' ,
14641464 'select * from t1' )
14651465
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))"))
14711469
14721470 con2 .commit ()
14731471 node .safe_psql (
14741472 'postgres' ,
14751473 'select * from t1' )
14761474
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))"))
14801478
14811479 node .stop ()
14821480
1483- print ( self .restore_node (
1481+ self .restore_node (
14841482 backup_dir , 'node' , node , backup_id = full_id ,
1485- options = ["-j" , "4" , '--incremental-mode=lsn' ]))
1483+ options = ["-j" , "4" , '--incremental-mode=lsn' ])
14861484
14871485 node .slow_start ()
14881486
@@ -1494,5 +1492,160 @@ def test_incr_lsn_long_xact_2(self):
14941492
14951493 # Clean after yourself
14961494 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+
14971650# check that MinRecPoint and BackupStartLsn are correctly used in case of --incrementa-lsn
14981651# incremental restore + partial restore.
0 commit comments