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

Commit64550a6

Browse files
committed
tests: added backup.BackupTest.test_basic_missing_dir_permissions and backup.BackupTest.test_basic_missing_file_permissions
1 parent4d5ed22 commit64550a6

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

‎tests/backup.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,3 +1281,87 @@ def test_drop_table(self):
12811281

12821282
# Clean after yourself
12831283
self.del_test_dir(module_name,fname)
1284+
1285+
# @unittest.skip("skip")
1286+
deftest_basic_missing_file_permissions(self):
1287+
""""""
1288+
fname=self.id().split('.')[3]
1289+
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
1290+
node=self.make_simple_node(
1291+
base_dir=os.path.join(module_name,fname,'node'),
1292+
set_replication=True,
1293+
initdb_params=['--data-checksums'])
1294+
1295+
self.init_pb(backup_dir)
1296+
self.add_instance(backup_dir,'node',node)
1297+
node.slow_start()
1298+
1299+
relative_path=node.safe_psql(
1300+
"postgres",
1301+
"select pg_relation_filepath('pg_class')").rstrip()
1302+
1303+
full_path=os.path.join(node.data_dir,relative_path)
1304+
1305+
os.chmod(full_path,000)
1306+
1307+
try:
1308+
# FULL backup
1309+
self.backup_node(
1310+
backup_dir,'node',node,options=['--stream'])
1311+
# we should die here because exception is what we expect to happen
1312+
self.assertEqual(
1313+
1,0,
1314+
"Expecting Error because of missing permissions"
1315+
"\n Output: {0}\n CMD: {1}".format(
1316+
repr(self.output),self.cmd))
1317+
exceptProbackupExceptionase:
1318+
self.assertIn(
1319+
'ERROR: cannot open file',
1320+
e.message,
1321+
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
1322+
repr(e.message),self.cmd))
1323+
1324+
os.chmod(full_path,700)
1325+
1326+
# Clean after yourself
1327+
self.del_test_dir(module_name,fname)
1328+
1329+
# @unittest.skip("skip")
1330+
deftest_basic_missing_dir_permissions(self):
1331+
""""""
1332+
fname=self.id().split('.')[3]
1333+
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
1334+
node=self.make_simple_node(
1335+
base_dir=os.path.join(module_name,fname,'node'),
1336+
set_replication=True,
1337+
initdb_params=['--data-checksums'])
1338+
1339+
self.init_pb(backup_dir)
1340+
self.add_instance(backup_dir,'node',node)
1341+
node.slow_start()
1342+
1343+
full_path=os.path.join(node.data_dir,'pg_twophase')
1344+
1345+
os.chmod(full_path,000)
1346+
1347+
try:
1348+
# FULL backup
1349+
self.backup_node(
1350+
backup_dir,'node',node,options=['--stream'])
1351+
# we should die here because exception is what we expect to happen
1352+
self.assertEqual(
1353+
1,0,
1354+
"Expecting Error because of missing permissions"
1355+
"\n Output: {0}\n CMD: {1}".format(
1356+
repr(self.output),self.cmd))
1357+
exceptProbackupExceptionase:
1358+
self.assertIn(
1359+
'ERROR: Cannot open directory',
1360+
e.message,
1361+
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
1362+
repr(e.message),self.cmd))
1363+
1364+
os.chmod(full_path,700)
1365+
1366+
# Clean after yourself
1367+
self.del_test_dir(module_name,fname)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp