Skip to content

Commit 7be2e73

Browse files
authored
PBCKP-145: added check of unlogged table is restored as empty table (#490)
1 parent 0b5b37e commit 7be2e73

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

tests/exclude.py

+26-4
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,10 @@ def test_exclude_unlogged_tables_1(self):
203203
# @unittest.skip("skip")
204204
def test_exclude_unlogged_tables_2(self):
205205
"""
206-
make node, create unlogged, take FULL, check
207-
that unlogged was not backed up
206+
1. make node, create unlogged, take FULL, DELTA, PAGE,
207+
check that unlogged table files was not backed up
208+
2. restore FULL, DELTA, PAGE to empty db,
209+
ensure unlogged table exist and is epmty
208210
"""
209211
fname = self.id().split('.')[3]
210212
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@@ -220,6 +222,8 @@ def test_exclude_unlogged_tables_2(self):
220222
self.set_archiving(backup_dir, 'node', node)
221223
node.slow_start()
222224

225+
backup_ids = []
226+
223227
for backup_type in ['full', 'delta', 'page']:
224228

225229
if backup_type == 'full':
@@ -231,14 +235,16 @@ def test_exclude_unlogged_tables_2(self):
231235
'postgres',
232236
'insert into test select generate_series(0,20050000)::text')
233237

234-
rel_path = node.safe_psql(
238+
rel_path = node.execute(
235239
'postgres',
236-
"select pg_relation_filepath('test')").decode('utf-8').rstrip()
240+
"select pg_relation_filepath('test')")[0][0]
237241

238242
backup_id = self.backup_node(
239243
backup_dir, 'node', node,
240244
backup_type=backup_type, options=['--stream'])
241245

246+
backup_ids.append(backup_id)
247+
242248
filelist = self.get_backup_filelist(
243249
backup_dir, 'node', backup_id)
244250

@@ -258,9 +264,25 @@ def test_exclude_unlogged_tables_2(self):
258264
rel_path + '.3', filelist,
259265
"Unlogged table was not excluded")
260266

267+
# ensure restoring retrieves back only empty unlogged table
268+
for backup_id in backup_ids:
269+
node.stop()
270+
node.cleanup()
271+
272+
self.restore_node(backup_dir, 'node', node, backup_id=backup_id)
273+
274+
node.slow_start()
275+
276+
self.assertEqual(
277+
node.execute(
278+
'postgres',
279+
'select count(*) from test')[0][0],
280+
0)
281+
261282
# Clean after yourself
262283
self.del_test_dir(module_name, fname)
263284

285+
264286
# @unittest.skip("skip")
265287
def test_exclude_log_dir(self):
266288
"""

0 commit comments

Comments
 (0)