1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2026-06-21 01:34:15 +02:00

fix init tests

This commit is contained in:
Yura Sokolov
2022-12-23 08:41:53 +03:00
parent a394ea3a5d
commit d8c41ae1eb
4 changed files with 12 additions and 33 deletions
+1 -1
View File
@@ -111,7 +111,7 @@ do_add_instance(InstanceState *instanceState, InstanceConfig *instance)
if ($haserr(err))
ft_logerr(FT_FATAL, $errmsg(err), "Check instance");
if (exists)
elog(ERROR, "Instance '%s' %s directory alredy exists: '%s'",
elog(ERROR, "Instance '%s' %s directory already exists: '%s'",
instanceState->instance_name, paths[i][0], paths[i][1]);
}
}
+3 -3
View File
@@ -532,11 +532,11 @@ pbk_main(int argc, char *argv[])
instanceState->instance_backup_subdir_path);
// TODO: redundant message, should we get rid of it?
elog(ERROR, "Instance '%s' does not exist in this backup catalog",
instance_name);
elog(ERROR, "-B, --backup-path must be a path to directory");
}
if (!exists)
elog(ERROR, "-B, --backup-path must be a path to directory");
elog(ERROR, "Instance '%s' does not exist in this backup catalog",
instance_name);
}
}
+1 -1
View File
@@ -2477,7 +2477,7 @@ pioLocalDrive_pioIsDirEmpty(VSelf, path_t path, err_i* err)
return false;
}
while ((dent = readdir(dir)) != NULL)
for (errno=0;(dent = readdir(dir)) != NULL;errno=0)
{
if (strcmp(dent->d_name, ".") == 0)
continue;
+7 -28
View File
@@ -115,35 +115,14 @@ class InitTest(ProbackupTest, unittest.TestCase):
dir_backups = os.path.join(backup_dir, 'backups', 'node')
dir_wal = os.path.join(backup_dir, 'wal', 'node')
try:
self.add_instance(backup_dir, 'node', node)
# we should die here because exception is what we expect to happen
self.assertEqual(
1, 0,
"Expecting Error because page backup should not be possible "
"\n Output: {0} \n CMD: {1}".format(
repr(self.output), self.cmd))
except ProbackupException as e:
self.assertIn(
"ERROR: Instance 'node' WAL archive directory already exists: ",
e.message,
"\n Unexpected Error Message: {0}\n CMD: {1}".format(
repr(e.message), self.cmd))
with open(os.path.join(dir_wal, "0000"), 'w'):
pass
try:
with self.assertRaisesRegex(ProbackupException, r"'node'.*WAL.*already exists"):
self.add_instance(backup_dir, 'node', node)
with self.assertRaisesRegex(ProbackupException, r"'node'.*WAL.*already exists"):
self.add_instance(backup_dir, 'node', node)
# we should die here because exception is what we expect to happen
self.assertEqual(
1, 0,
"Expecting Error because page backup should not be possible "
"\n Output: {0} \n CMD: {1}".format(
repr(self.output), self.cmd))
except ProbackupException as e:
self.assertIn(
"ERROR: Instance 'node' WAL archive directory already exists: ",
e.message,
"\n Unexpected Error Message: {0}\n CMD: {1}".format(
repr(e.message), self.cmd))
def test_init_backup_catalog_no_access(self):
""" Test pg_probackup init -B backup_dir to a dir with no read access. """
@@ -153,7 +132,7 @@ class InitTest(ProbackupTest, unittest.TestCase):
os.makedirs(no_access_dir)
os.chmod(no_access_dir, stat.S_IREAD)
expected = 'ERROR: cannot open backup catalog directory "{0}": Permission denied'.format(backup_dir)
expected = 'ERROR: cannot open backup catalog directory.*{0}.*Permission denied'.format(backup_dir)
with self.assertRaisesRegex(ProbackupException, expected):
self.init_pb(backup_dir)