Skip to content

Commit da6cb87

Browse files
authored
Merge pull request #222 from kuzmindb/issue_188
Issue 188
2 parents 683e491 + cca2631 commit da6cb87

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

src/validate.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ pgBackupValidate(pgBackup *backup, pgRestoreParams *params)
120120
return;
121121
}
122122

123+
if (strcmp(backup->server_version, PG_MAJORVERSION) != 0)
124+
{
125+
elog(ERROR, "Backup was made with server version %s, but pg_probackup compiled "
126+
"with server version %s.",
127+
backup->server_version, PG_MAJORVERSION);
128+
}
129+
123130
// if (params && params->partial_db_list)
124131
// dbOid_exclude_list = get_dbOid_exclude_list(backup, files, params->partial_db_list,
125132
// params->partial_restore_type);

tests/validate.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,3 +3728,57 @@ def test_partial_validate_include(self):
37283728
# 716 if (read_len != MAXALIGN(header.compressed_size))
37293729
# -> 717 elog(ERROR, "cannot read block %u of \"%s\" read %lu of %d",
37303730
# 718 blknum, file->path, read_len, header.compressed_size);
3731+
3732+
3733+
# @unittest.skip("skip")
3734+
def test_not_validate_diffenent_pg_version(self):
3735+
"""Do not validate backup, if binary is compiled with different PG version"""
3736+
fname = self.id().split('.')[3]
3737+
node = self.make_simple_node(
3738+
base_dir=os.path.join(module_name, fname, 'node'),
3739+
initdb_params=['--data-checksums'])
3740+
3741+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
3742+
self.init_pb(backup_dir)
3743+
self.add_instance(backup_dir, 'node', node)
3744+
self.set_archiving(backup_dir, 'node', node)
3745+
node.slow_start()
3746+
3747+
backup_id = self.backup_node(backup_dir, 'node', node)
3748+
3749+
control_file = os.path.join(
3750+
backup_dir, "backups", "node", backup_id,
3751+
"backup.control")
3752+
3753+
pg_version = node.major_version
3754+
3755+
if pg_version.is_integer():
3756+
pg_version = int(pg_version)
3757+
3758+
fake_new_pg_version = pg_version + 1
3759+
3760+
with open(control_file, 'r') as f:
3761+
data = f.read();
3762+
3763+
data = data.replace(str(pg_version), str(fake_new_pg_version))
3764+
3765+
with open(control_file, 'w') as f:
3766+
f.write(data);
3767+
3768+
try:
3769+
self.validate_pb(backup_dir)
3770+
self.assertEqual(
3771+
1, 0,
3772+
"Expecting Error because validation is forbidden if server version of backup "
3773+
"is different from the server version of pg_probackup.\n Output: {0} \n CMD: {1}".format(
3774+
repr(self.output), self.cmd))
3775+
except ProbackupException as e:
3776+
self.assertIn(
3777+
"ERROR: Backup was made with server version",
3778+
e.message,
3779+
"\n Unexpected Error Message: {0}\n CMD: {1}".format(
3780+
repr(e.message), self.cmd))
3781+
3782+
# Clean after yourself
3783+
self.del_test_dir(module_name, fname)
3784+

0 commit comments

Comments
 (0)