1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-11-25 09:01:48 +02:00

tests: fixes

This commit is contained in:
Grigory Smolkin 2019-10-21 13:46:48 +03:00
parent 3b2af9e83c
commit 5196fb25ec
3 changed files with 75 additions and 18 deletions

View File

@ -239,17 +239,19 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
backup_dir, 'node', node,
options=[
"--archive-timeout=60",
"--log-level-file=info"],
"--log-level-file=LOG"],
gdb=True)
gdb.set_breakpoint('pg_stop_backup')
gdb.run_until_break()
self.set_auto_conf(node, {'archive_command': "'exit 1'"})
self.set_auto_conf(node, {'archive_command': 'exit 1'})
node.reload()
gdb.continue_execution_until_exit()
sleep(1)
log_file = os.path.join(backup_dir, 'log', 'pg_probackup.log')
with open(log_file, 'r') as f:
log_content = f.read()
@ -1572,7 +1574,11 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
'--archive-user={0}'.format(self.user)
])
recovery_conf = os.path.join(node.data_dir, 'recovery.conf')
if self.get_version(node) >= self.version_to_num('12.0'):
recovery_conf = os.path.join(node.data_dir, 'probackup_recovery.conf')
else:
recovery_conf = os.path.join(node.data_dir, 'recovery.conf')
with open(recovery_conf, 'r') as f:
recovery_content = f.read()
@ -1643,7 +1649,11 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
'--archive-user={0}'.format(self.user)])
self.restore_node(backup_dir, 'node', node)
recovery_conf = os.path.join(node.data_dir, 'recovery.conf')
if self.get_version(node) >= self.version_to_num('12.0'):
recovery_conf = os.path.join(node.data_dir, 'probackup_recovery.conf')
else:
recovery_conf = os.path.join(node.data_dir, 'recovery.conf')
with open(recovery_conf, 'r') as f:
recovery_content = f.read()

View File

@ -2259,3 +2259,45 @@ class BackupTest(ProbackupTest, unittest.TestCase):
# Clean after yourself
self.del_test_dir(module_name, fname)
# @unittest.skip("skip")
def test_streaming_timeout(self):
"""
"""
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'],
pg_options={
'checkpoint_timeout': '1h',
'wal_sender_timeout': '5s'})
self.init_pb(backup_dir)
self.add_instance(backup_dir, 'node', node)
node.slow_start()
# FULL backup
gdb = self.backup_node(
backup_dir, 'node', node, gdb=True,
options=['--stream', '--log-level-file=LOG'])
gdb.set_breakpoint('pg_stop_backup')
gdb.run_until_break()
sleep(10)
gdb.continue_execution_until_error()
gdb._execute('detach')
sleep(2)
log_file_path = os.path.join(backup_dir, 'log', 'pg_probackup.log')
with open(log_file_path) as f:
log_content = f.read()
self.assertIn(
'could not receive data from WAL stream',
log_content)
# Clean after yourself
self.del_test_dir(module_name, fname)

View File

@ -1184,28 +1184,30 @@ class ProbackupTest(object):
):
self.set_auto_conf(
replica,
options={
'port': replica.port,
'hot_standby': 'on'})
replica,
options={
'port': replica.port,
'hot_standby': 'on'})
if self.get_version(replica) >= self.version_to_num('12.0'):
recovery_config = 'probackup_recovery.conf'
with open(os.path.join(replica.data_dir, "standby.signal"), 'w') as f:
f.flush()
f.close()
else:
recovery_config = 'recovery.conf'
replica.append_conf(recovery_config, 'standby_mode = on')
replica.append_conf(
recovery_config,
"primary_conninfo = 'user={0} port={1} application_name={2}"
" sslmode=prefer sslcompression=1'".format(
self.user, master.port, replica_name))
self.set_auto_conf(
replica,
{'primary_conninfo': 'user={0} port={1} application_name={2} '
' sslmode=prefer sslcompression=1'.format(
self.user, master.port, replica_name)})
else:
replica.append_conf('recovery.conf', 'standby_mode = on')
replica.append_conf(
'recovery.conf',
"primary_conninfo = 'user={0} port={1} application_name={2}"
" sslmode=prefer sslcompression=1'".format(
self.user, master.port, replica_name))
if synchronous:
self.set_auto_conf(
master,
options={
@ -1725,6 +1727,9 @@ class GDBobj(ProbackupTest):
return
if line.startswith('*stopped,reason="exited'):
return
if line.startswith(
'*stopped,reason="signal-received",signal-name="SIGABRT"'):
return
raise GdbException(
'Failed to continue execution until error.\n')