Skip to content

Commit b1975e3

Browse files
committed
tests: added archive.ArchiveTest.test_archive_catalog_1 and archive.ArchiveTest.test_archive_catalog_2
1 parent eb9b234 commit b1975e3

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

tests/archive.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,107 @@ def test_archive_catalog(self):
14371437
self.assertEqual(timeline_2['parent-tli'], 1)
14381438
self.assertEqual(timeline_1['parent-tli'], 0)
14391439

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')
14401541

14411542
self.del_test_dir(module_name, fname)
14421543

0 commit comments

Comments
 (0)