Skip to content

Commit 5e618d4

Browse files
committed
tests: added retention.RetentionTest.test_failed_merge_redundancy_retention
1 parent 8c570b5 commit 5e618d4

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

tests/retention.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,3 +1501,99 @@ def test_wal_purge_victim(self):
15011501

15021502
# Clean after yourself
15031503
self.del_test_dir(module_name, fname)
1504+
1505+
# @unittest.skip("skip")
1506+
def test_failed_merge_redundancy_retention(self):
1507+
"""
1508+
Check that retention purge works correctly with MERGING backups
1509+
"""
1510+
fname = self.id().split('.')[3]
1511+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
1512+
node = self.make_simple_node(
1513+
base_dir=os.path.join(
1514+
module_name, fname, 'node'),
1515+
set_replication=True,
1516+
initdb_params=['--data-checksums'])
1517+
1518+
self.init_pb(backup_dir)
1519+
self.add_instance(backup_dir, 'node', node)
1520+
self.set_archiving(backup_dir, 'node', node)
1521+
node.slow_start()
1522+
1523+
# FULL1 backup
1524+
full_id = self.backup_node(backup_dir, 'node', node)
1525+
1526+
# DELTA BACKUP
1527+
delta_id = self.backup_node(
1528+
backup_dir, 'node', node, backup_type='delta')
1529+
1530+
# DELTA BACKUP
1531+
self.backup_node(
1532+
backup_dir, 'node', node, backup_type='delta')
1533+
1534+
# DELTA BACKUP
1535+
self.backup_node(
1536+
backup_dir, 'node', node, backup_type='delta')
1537+
1538+
# FULL2 backup
1539+
self.backup_node(backup_dir, 'node', node)
1540+
1541+
# DELTA BACKUP
1542+
self.backup_node(
1543+
backup_dir, 'node', node, backup_type='delta')
1544+
1545+
# DELTA BACKUP
1546+
self.backup_node(
1547+
backup_dir, 'node', node, backup_type='delta')
1548+
1549+
# FULL3 backup
1550+
self.backup_node(backup_dir, 'node', node)
1551+
1552+
# DELTA BACKUP
1553+
self.backup_node(
1554+
backup_dir, 'node', node, backup_type='delta')
1555+
1556+
# DELTA BACKUP
1557+
self.backup_node(
1558+
backup_dir, 'node', node, backup_type='delta')
1559+
1560+
self.set_config(
1561+
backup_dir, 'node', options=['--retention-redundancy=2'])
1562+
1563+
self.set_config(
1564+
backup_dir, 'node', options=['--retention-window=2'])
1565+
1566+
# create pair of MERGING backup as a result of failed merge
1567+
gdb = self.merge_backup(
1568+
backup_dir, 'node', delta_id, gdb=True)
1569+
gdb.set_breakpoint('copy_file')
1570+
gdb.run_until_break()
1571+
gdb.continue_execution_until_break(2)
1572+
gdb._execute('signal SIGKILL')
1573+
1574+
# "expire" first full backup
1575+
backups = os.path.join(backup_dir, 'backups', 'node')
1576+
with open(
1577+
os.path.join(
1578+
backups, full_id, "backup.control"), "a") as conf:
1579+
conf.write("recovery_time='{:%Y-%m-%d %H:%M:%S}'\n".format(
1580+
datetime.now() - timedelta(days=3)))
1581+
1582+
# run retention merge
1583+
self.delete_expired(
1584+
backup_dir, 'node', options=['--delete-expired'])
1585+
1586+
self.assertEqual(
1587+
'MERGING',
1588+
self.show_pb(backup_dir, 'node', full_id)['status'],
1589+
'Backup STATUS should be "MERGING"')
1590+
1591+
self.assertEqual(
1592+
'MERGING',
1593+
self.show_pb(backup_dir, 'node', delta_id)['status'],
1594+
'Backup STATUS should be "MERGING"')
1595+
1596+
self.assertEqual(len(self.show_pb(backup_dir, 'node')), 10)
1597+
1598+
# Clean after yourself
1599+
self.del_test_dir(module_name, fname)

0 commit comments

Comments
 (0)