mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-02-09 14:33:17 +02:00
[Issue #313] added test coverage
This commit is contained in:
parent
d1106e5571
commit
6e8e948fd6
@ -1950,6 +1950,9 @@ class GDBobj(ProbackupTest):
|
||||
return True
|
||||
return False
|
||||
|
||||
def quit(self):
|
||||
self.proc.terminate()
|
||||
|
||||
# use for breakpoint, run, continue
|
||||
def _execute(self, cmd, running=True):
|
||||
output = []
|
||||
|
@ -9,7 +9,8 @@ import hashlib
|
||||
import shutil
|
||||
import json
|
||||
from shutil import copyfile
|
||||
from testgres import QueryException
|
||||
from testgres import QueryException, StartNodeException
|
||||
from stat import S_ISDIR
|
||||
|
||||
|
||||
module_name = 'restore'
|
||||
@ -3856,3 +3857,66 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
# @unittest.skip("skip")
|
||||
def test_restore_issue_313(self):
|
||||
"""
|
||||
Check that partially restored PostgreSQL instance cannot be started
|
||||
"""
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
node = self.make_simple_node(
|
||||
base_dir=os.path.join(module_name, fname, 'node'),
|
||||
set_replication=True,
|
||||
initdb_params=['--data-checksums'])
|
||||
|
||||
self.init_pb(backup_dir)
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
self.set_archiving(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
# FULL backup
|
||||
backup_id = self.backup_node(backup_dir, 'node', node)
|
||||
node.cleanup()
|
||||
|
||||
count = 0
|
||||
filelist = self.get_backup_filelist(backup_dir, 'node', backup_id)
|
||||
for file in filelist:
|
||||
# count only nondata files
|
||||
if int(filelist[file]['is_datafile']) == 0 and int(filelist[file]['size']) > 0:
|
||||
count += 1
|
||||
|
||||
node_restored = self.make_simple_node(
|
||||
base_dir=os.path.join(module_name, fname, 'node_restored'))
|
||||
node_restored.cleanup()
|
||||
self.restore_node(backup_dir, 'node', node_restored)
|
||||
|
||||
gdb = self.restore_node(backup_dir, 'node', node, gdb=True, options=['--progress'])
|
||||
gdb.verbose = False
|
||||
gdb.set_breakpoint('restore_non_data_file')
|
||||
gdb.run_until_break()
|
||||
gdb.continue_execution_until_break(count - 2)
|
||||
gdb.quit()
|
||||
|
||||
# emulate the user or HA taking care of PG configuration
|
||||
for fname in os.listdir(node_restored.data_dir):
|
||||
if fname.endswith('.conf'):
|
||||
os.rename(
|
||||
os.path.join(node_restored.data_dir, fname),
|
||||
os.path.join(node.data_dir, fname))
|
||||
|
||||
try:
|
||||
node.slow_start()
|
||||
# we should die here because exception is what we expect to happen
|
||||
self.assertEqual(
|
||||
1, 0,
|
||||
"Expecting Error because backup is not fully restored")
|
||||
except StartNodeException as e:
|
||||
self.assertIn(
|
||||
'Cannot start node',
|
||||
e.message,
|
||||
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
||||
repr(e.message), self.cmd))
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
Loading…
x
Reference in New Issue
Block a user