Skip to content

Commit c81a612

Browse files
author
Ilya Skvortsov
committed
new no-validate test added
1 parent 29639f7 commit c81a612

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tests/validate_test.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,3 +1659,62 @@ def test_validate_corrupted_full_1(self):
16591659

16601660
# Clean after yourself
16611661
self.del_test_dir(module_name, fname)
1662+
1663+
def test_file_size_corruption_no_validate(self):
1664+
1665+
fname = self.id().split('.')[3]
1666+
node = self.make_simple_node(
1667+
base_dir="{0}/{1}/node".format(module_name, fname),
1668+
# initdb_params=['--data-checksums'],
1669+
pg_options={'wal_level': 'replica'}
1670+
)
1671+
1672+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
1673+
1674+
self.init_pb(backup_dir)
1675+
self.add_instance(backup_dir, 'node', node)
1676+
self.set_archiving(backup_dir, 'node', node)
1677+
1678+
node.start()
1679+
1680+
node.safe_psql(
1681+
"postgres",
1682+
"create table t_heap as select 1 as id, md5(i::text) as text, "
1683+
"md5(repeat(i::text,10))::tsvector as tsvector "
1684+
"from generate_series(0,1000) i")
1685+
node.safe_psql(
1686+
"postgres",
1687+
"CHECKPOINT;")
1688+
1689+
heap_path = node.safe_psql(
1690+
"postgres",
1691+
"select pg_relation_filepath('t_heap')").rstrip()
1692+
heap_size = node.safe_psql(
1693+
"postgres",
1694+
"select pg_relation_size('t_heap')")
1695+
1696+
backup_id = self.backup_node(
1697+
backup_dir, 'node', node, backup_type="full",
1698+
options=["-j", "4"], async=False, gdb=False)
1699+
1700+
node.stop()
1701+
node.cleanup()
1702+
1703+
# Let`s do file corruption
1704+
with open(os.path.join(backup_dir, "backups", 'node', backup_id, "database", heap_path), "rb+", 0) as f:
1705+
f.truncate(int(heap_size) - 4096)
1706+
f.flush()
1707+
f.close
1708+
1709+
node.cleanup()
1710+
1711+
try:
1712+
self.restore_node(
1713+
backup_dir, 'node', node,
1714+
options=["--no-validate"])
1715+
except ProbackupException as e:
1716+
self.assertTrue("ERROR: Data files restoring failed" in e.message, repr(e.message))
1717+
print "\nExpected error: \n" + e.message
1718+
1719+
# Clean after yourself
1720+
self.del_test_dir(module_name, fname)

0 commit comments

Comments
 (0)