Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit20b9685

Browse files
author
Sofia Kopikova
committed
[PBCKP-159] fix false directory init, add test to init.py
Tags: pg_probackup
1 parent0b5b37e commit20b9685

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

‎src/init.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ do_init(CatalogState *catalogState)
3131
elog(ERROR,"cannot open backup catalog directory \"%s\": %s",
3232
catalogState->catalog_path,strerror(errno_tmp));
3333
}
34+
elseif (results==1)
35+
{
36+
/* Check whether we have all(rwx) rights for directory */
37+
if (access(catalogState->catalog_path,R_OK |W_OK |X_OK)==-1)
38+
{
39+
interrno_tmp=errno;
40+
elog(ERROR,"cannot access backup catalog directory \"%s\": %s",
41+
catalogState->catalog_path,strerror(errno_tmp));
42+
}
43+
}
3444

3545
/* create backup catalog root directory */
3646
dir_create_dir(catalogState->catalog_path,DIR_PERMISSION, false);

‎tests/init.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
importos
2+
importstat# for chmod
23
importunittest
34
from .helpers.ptrack_helpersimportdir_files,ProbackupTest,ProbackupException
45
importshutil
@@ -86,6 +87,29 @@ def test_already_exist(self):
8687

8788
# Clean after yourself
8889
self.del_test_dir(module_name,fname)
90+
91+
# @unittest.skip("skip")
92+
deftest_no_rights_for_directory(self):
93+
"""Failure with backup catalog existed and empty but user has no writing permissions"""
94+
fname=self.id().split(".")[3]
95+
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
96+
os.mkdir(backup_dir)
97+
os.chmod(backup_dir,stat.S_IREAD)# set read-only flag for current user
98+
assertos.access(backup_dir,os.R_OK)andnotos.access(backup_dir,os.W_OK)
99+
node=self.make_simple_node(base_dir=os.path.join(module_name,fname,'node'))
100+
self.init_pb(backup_dir)
101+
try:
102+
self.show_pb(backup_dir,'node')
103+
self.assertEqual(1,0,'Expecting Error due to initialization in empty directory with no rithts for writing. Output: {0}\n CMD: {1}'.format(
104+
repr(self.output),self.cmd))
105+
exceptProbackupExceptionase:
106+
self.assertIn(
107+
"ERROR: Instance 'node' does not exist in this backup catalog",
108+
e.message,
109+
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message),self.cmd))
110+
111+
# Clean after yourself
112+
self.del_test_dir(module_name,fname)
89113

90114
# @unittest.skip("skip")
91115
deftest_abs_path(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp