Skip to content

Commit f6b8264

Browse files
committed
PGPRO-1376 tests: new test case added
1 parent f133f29 commit f6b8264

File tree

2 files changed

+54
-5
lines changed

2 files changed

+54
-5
lines changed

tests/backup_test.py

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,20 +442,58 @@ def test_tablespace_in_pgdata_pgpro_1376(self):
442442
tblspc_path=(os.path.join(node.data_dir, 'pg_clog', '100500'))
443443
)
444444

445+
self.create_tblspace_in_node(
446+
node, 'tblspace2',
447+
tblspc_path=(os.path.join(node.data_dir))
448+
)
449+
450+
node.safe_psql(
451+
"postgres",
452+
"create table t_heap1 tablespace tblspace1 as select 1 as id, "
453+
"md5(i::text) as text, "
454+
"md5(repeat(i::text,10))::tsvector as tsvector "
455+
"from generate_series(0,1000) i")
456+
445457
node.safe_psql(
446458
"postgres",
447-
"create table t_heap tablespace tblspace1 as select 1 as id, "
459+
"create table t_heap2 tablespace tblspace2 as select 1 as id, "
448460
"md5(i::text) as text, "
449461
"md5(repeat(i::text,10))::tsvector as tsvector "
450462
"from generate_series(0,1000) i")
451463

464+
try:
465+
self.backup_node(
466+
backup_dir, 'node', node, backup_type="full",
467+
options=["-j", "4", "--stream"])
468+
# we should die here because exception is what we expect to happen
469+
self.assertEqual(
470+
1, 0,
471+
"Expecting Error because of too many levels "
472+
"of symbolic linking\n"
473+
" Output: {0} \n CMD: {1}".format(
474+
repr(self.output), self.cmd))
475+
except ProbackupException as e:
476+
self.assertTrue(
477+
'Too many levels of symbolic links' in e.message,
478+
"\n Unexpected Error Message: {0}\n CMD: {1}".format(
479+
repr(e.message), self.cmd))
480+
481+
node.safe_psql(
482+
"postgres",
483+
"drop table t_heap2")
484+
node.safe_psql(
485+
"postgres",
486+
"drop tablespace tblspace2")
487+
452488
self.backup_node(
453-
backup_dir, 'node', node, backup_type="full",
454-
options=["-j", "4", "--stream"])
489+
backup_dir, 'node', node, backup_type="full",
490+
options=["-j", "4", "--stream"])
491+
492+
pgdata = self.pgdata_content(node.data_dir)
455493

456494
relfilenode = node.safe_psql(
457495
"postgres",
458-
"select 't_heap'::regclass::oid"
496+
"select 't_heap1'::regclass::oid"
459497
).rstrip()
460498

461499
list = []
@@ -475,3 +513,12 @@ def test_tablespace_in_pgdata_pgpro_1376(self):
475513
"Following file copied twice by backup:\n {0}".format(
476514
message)
477515
)
516+
517+
node.cleanup()
518+
519+
self.restore_node(
520+
backup_dir, 'node', node, options=["-j", "4"])
521+
522+
if self.paranoia:
523+
pgdata_restored = self.pgdata_content(node.data_dir)
524+
self.compare_pgdata(pgdata, pgdata_restored)

tests/helpers/ptrack_helpers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ def create_tblspace_in_node(self, node, tblspc_name, tblspc_path=None, cfs=False
259259
tblspc_name, tblspc_path)
260260
if cfs:
261261
cmd += " with (compression=true)"
262-
os.makedirs(tblspc_path)
262+
263+
if not os.path.exists(tblspc_path):
264+
os.makedirs(tblspc_path)
263265
res = node.safe_psql("postgres", cmd)
264266
# Check that tablespace was successfully created
265267
# self.assertEqual(

0 commit comments

Comments
 (0)