1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-07-17 07:22:20 +02:00

issue 188: add test

This commit is contained in:
Dmitriy Kuzmin
2020-05-21 00:27:33 +10:00
parent 8b46ef5d4b
commit 09a78d29db

View File

@ -3728,3 +3728,57 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
# 716 if (read_len != MAXALIGN(header.compressed_size))
# -> 717 elog(ERROR, "cannot read block %u of \"%s\" read %lu of %d",
# 718 blknum, file->path, read_len, header.compressed_size);
# @unittest.skip("skip")
def test_not_validate_diffenent_pg_version(self):
"""Do not validate backup, if binary is compiled with different PG version"""
fname = self.id().split('.')[3]
node = self.make_simple_node(
base_dir=os.path.join(module_name, fname, 'node'),
initdb_params=['--data-checksums'])
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
self.init_pb(backup_dir)
self.add_instance(backup_dir, 'node', node)
self.set_archiving(backup_dir, 'node', node)
node.slow_start()
backup_id = self.backup_node(backup_dir, 'node', node)
control_file = os.path.join(
backup_dir, "backups", "node", backup_id,
"backup.control")
pg_version = node.major_version
if pg_version.is_integer():
pg_version = int(pg_version)
fake_new_pg_version = pg_version + 1
with open(control_file, 'r') as f:
data = f.read();
data = data.replace(str(pg_version), str(fake_new_pg_version))
with open(control_file, 'w') as f:
f.write(data);
try:
self.validate_pb(backup_dir)
self.assertEqual(
1, 0,
"Expecting Error because validation is forbidden if server version of backup "
"is different from the server version of pg_probackup.\n Output: {0} \n CMD: {1}".format(
repr(self.output), self.cmd))
except ProbackupException as e:
self.assertIn(
"ERROR: Backup was made with server version",
e.message,
"\n Unexpected Error Message: {0}\n CMD: {1}".format(
repr(e.message), self.cmd))
# Clean after yourself
self.del_test_dir(module_name, fname)