1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-04-18 12:33:33 +02:00

Issue 56: added logging.LogTest.test_truncated_rotation_file

This commit is contained in:
Grigory Smolkin 2019-04-18 16:10:31 +03:00
parent cb9134d067
commit e7c3031f7f

View File

@ -72,3 +72,50 @@ class LogTest(ProbackupTest, unittest.TestCase):
# Clean after yourself
self.del_test_dir(module_name, fname)
def test_truncated_rotation_file(self):
fname = self.id().split('.')[3]
node = self.make_simple_node(
base_dir=os.path.join(module_name, fname, 'node'),
initdb_params=['--data-checksums'])
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
self.init_pb(backup_dir)
self.add_instance(backup_dir, 'node', node)
node.slow_start()
self.set_config(
backup_dir, 'node',
options=['--log-rotation-age=1d'])
rotation_file_path = os.path.join(
backup_dir, 'log', 'pg_probackup.log.rotation')
# self.assertTrue(os.path.isfile(rotation_file_path))
self.backup_node(
backup_dir, 'node', node,
options=[
'--stream',
'--log-level-file=VERBOSE',
'--log-filename=pg_probackup.log'])
self.assertTrue(os.path.isfile(rotation_file_path))
# truncate .rotation file
with open(rotation_file_path, "rb+", 0) as f:
f.truncate()
f.flush()
f.close
self.backup_node(
backup_dir, 'node', node,
options=[
'--stream',
'--log-level-file=VERBOSE',
'--log-filename=pg_probackup.log'])
self.assertTrue(os.path.isfile(rotation_file_path))
# Clean after yourself
self.del_test_dir(module_name, fname)