Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c92e10d

Browse files
committed
tests: added validate.ValidateTest.test_validate_corrupt_tablespace_map
1 parent bcb3a04 commit c92e10d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/validate.py

+40
Original file line numberDiff line numberDiff line change
@@ -3391,6 +3391,46 @@ def test_validation_after_backup(self):
33913391
# Clean after yourself
33923392
self.del_test_dir(module_name, fname)
33933393

3394+
# @unittest.expectedFailure
3395+
# @unittest.skip("skip")
3396+
def test_validate_corrupt_tablespace_map(self):
3397+
"""
3398+
Check that corruption in tablespace_map is detected
3399+
"""
3400+
fname = self.id().split('.')[3]
3401+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
3402+
node = self.make_simple_node(
3403+
base_dir=os.path.join(module_name, fname, 'node'),
3404+
set_replication=True,
3405+
initdb_params=['--data-checksums'])
3406+
3407+
self.init_pb(backup_dir)
3408+
self.add_instance(backup_dir, 'node', node)
3409+
node.slow_start()
3410+
3411+
self.create_tblspace_in_node(node, 'external_dir')
3412+
3413+
node.safe_psql(
3414+
'postgres',
3415+
'CREATE TABLE t_heap(a int) TABLESPACE "external_dir"')
3416+
3417+
# FULL backup
3418+
backup_id = self.backup_node(
3419+
backup_dir, 'node', node, options=['--stream'])
3420+
3421+
tablespace_map = os.path.join(
3422+
backup_dir, 'backups', 'node',
3423+
backup_id, 'database', 'tablespace_map')
3424+
3425+
# Corrupt tablespace_map file in FULL backup
3426+
with open(tablespace_map, "rb+", 0) as f:
3427+
f.seek(84)
3428+
f.write(b"blah")
3429+
f.flush()
3430+
f.close
3431+
3432+
self.validate_pb(backup_dir, 'node', backup_id=backup_id)
3433+
33943434
# validate empty backup list
33953435
# page from future during validate
33963436
# page from future during backup

0 commit comments

Comments
 (0)