You've already forked pg_probackup
mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-09-16 09:26:30 +02:00
tests: check that log file do not gets rotated if '.rotation' file is missing or mangled
This commit is contained in:
@@ -88,17 +88,20 @@ class LogTest(ProbackupTest, unittest.TestCase):
|
|||||||
backup_dir, 'node',
|
backup_dir, 'node',
|
||||||
options=['--log-rotation-age=1d'])
|
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(
|
self.backup_node(
|
||||||
backup_dir, 'node', node,
|
backup_dir, 'node', node,
|
||||||
options=[
|
options=[
|
||||||
'--stream',
|
'--stream',
|
||||||
'--log-level-file=VERBOSE'])
|
'--log-level-file=VERBOSE'])
|
||||||
|
|
||||||
|
rotation_file_path = os.path.join(
|
||||||
|
backup_dir, 'log', 'pg_probackup.log.rotation')
|
||||||
|
|
||||||
|
log_file_path = os.path.join(
|
||||||
|
backup_dir, 'log', 'pg_probackup.log')
|
||||||
|
|
||||||
|
log_file_size = os.stat(log_file_path).st_size
|
||||||
|
|
||||||
self.assertTrue(os.path.isfile(rotation_file_path))
|
self.assertTrue(os.path.isfile(rotation_file_path))
|
||||||
|
|
||||||
# truncate .rotation file
|
# truncate .rotation file
|
||||||
@@ -111,9 +114,14 @@ class LogTest(ProbackupTest, unittest.TestCase):
|
|||||||
backup_dir, 'node', node,
|
backup_dir, 'node', node,
|
||||||
options=[
|
options=[
|
||||||
'--stream',
|
'--stream',
|
||||||
'--log-level-file=VERBOSE'],
|
'--log-level-file=LOG'],
|
||||||
return_id=False)
|
return_id=False)
|
||||||
|
|
||||||
|
# check that log file wasn`t rotated
|
||||||
|
self.assertGreater(
|
||||||
|
os.stat(log_file_path).st_size,
|
||||||
|
log_file_size)
|
||||||
|
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
'WARNING: cannot read creation timestamp from rotation file',
|
'WARNING: cannot read creation timestamp from rotation file',
|
||||||
output)
|
output)
|
||||||
@@ -122,9 +130,14 @@ class LogTest(ProbackupTest, unittest.TestCase):
|
|||||||
backup_dir, 'node', node,
|
backup_dir, 'node', node,
|
||||||
options=[
|
options=[
|
||||||
'--stream',
|
'--stream',
|
||||||
'--log-level-file=VERBOSE'],
|
'--log-level-file=LOG'],
|
||||||
return_id=False)
|
return_id=False)
|
||||||
|
|
||||||
|
# check that log file wasn`t rotated
|
||||||
|
self.assertGreater(
|
||||||
|
os.stat(log_file_path).st_size,
|
||||||
|
log_file_size)
|
||||||
|
|
||||||
self.assertNotIn(
|
self.assertNotIn(
|
||||||
'WARNING:',
|
'WARNING:',
|
||||||
output)
|
output)
|
||||||
@@ -149,9 +162,6 @@ class LogTest(ProbackupTest, unittest.TestCase):
|
|||||||
backup_dir, 'node',
|
backup_dir, 'node',
|
||||||
options=['--log-rotation-age=1d'])
|
options=['--log-rotation-age=1d'])
|
||||||
|
|
||||||
rotation_file_path = os.path.join(
|
|
||||||
backup_dir, 'log', 'pg_probackup.log.rotation')
|
|
||||||
|
|
||||||
|
|
||||||
self.backup_node(
|
self.backup_node(
|
||||||
backup_dir, 'node', node,
|
backup_dir, 'node', node,
|
||||||
@@ -159,6 +169,14 @@ class LogTest(ProbackupTest, unittest.TestCase):
|
|||||||
'--stream',
|
'--stream',
|
||||||
'--log-level-file=VERBOSE'])
|
'--log-level-file=VERBOSE'])
|
||||||
|
|
||||||
|
rotation_file_path = os.path.join(
|
||||||
|
backup_dir, 'log', 'pg_probackup.log.rotation')
|
||||||
|
|
||||||
|
log_file_path = os.path.join(
|
||||||
|
backup_dir, 'log', 'pg_probackup.log')
|
||||||
|
|
||||||
|
log_file_size = os.stat(log_file_path).st_size
|
||||||
|
|
||||||
self.assertTrue(os.path.isfile(rotation_file_path))
|
self.assertTrue(os.path.isfile(rotation_file_path))
|
||||||
|
|
||||||
# unlink .rotation file
|
# unlink .rotation file
|
||||||
@@ -168,9 +186,14 @@ class LogTest(ProbackupTest, unittest.TestCase):
|
|||||||
backup_dir, 'node', node,
|
backup_dir, 'node', node,
|
||||||
options=[
|
options=[
|
||||||
'--stream',
|
'--stream',
|
||||||
'--log-level-file=VERBOSE'],
|
'--log-level-file=LOG'],
|
||||||
return_id=False)
|
return_id=False)
|
||||||
|
|
||||||
|
# check that log file wasn`t rotated
|
||||||
|
self.assertGreater(
|
||||||
|
os.stat(log_file_path).st_size,
|
||||||
|
log_file_size)
|
||||||
|
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
'WARNING: missing rotation file:',
|
'WARNING: missing rotation file:',
|
||||||
output)
|
output)
|
||||||
@@ -188,6 +211,11 @@ class LogTest(ProbackupTest, unittest.TestCase):
|
|||||||
'WARNING:',
|
'WARNING:',
|
||||||
output)
|
output)
|
||||||
|
|
||||||
|
# check that log file wasn`t rotated
|
||||||
|
self.assertGreater(
|
||||||
|
os.stat(log_file_path).st_size,
|
||||||
|
log_file_size)
|
||||||
|
|
||||||
# Clean after yourself
|
# Clean after yourself
|
||||||
self.del_test_dir(module_name, fname)
|
self.del_test_dir(module_name, fname)
|
||||||
|
|
||||||
@@ -206,15 +234,20 @@ class LogTest(ProbackupTest, unittest.TestCase):
|
|||||||
backup_dir, 'node',
|
backup_dir, 'node',
|
||||||
options=['--log-rotation-age=1d'])
|
options=['--log-rotation-age=1d'])
|
||||||
|
|
||||||
rotation_file_path = os.path.join(
|
|
||||||
backup_dir, 'log', 'pg_probackup.log.rotation')
|
|
||||||
|
|
||||||
self.backup_node(
|
self.backup_node(
|
||||||
backup_dir, 'node', node,
|
backup_dir, 'node', node,
|
||||||
options=[
|
options=[
|
||||||
'--stream',
|
'--stream',
|
||||||
'--log-level-file=VERBOSE'])
|
'--log-level-file=VERBOSE'])
|
||||||
|
|
||||||
|
rotation_file_path = os.path.join(
|
||||||
|
backup_dir, 'log', 'pg_probackup.log.rotation')
|
||||||
|
|
||||||
|
log_file_path = os.path.join(
|
||||||
|
backup_dir, 'log', 'pg_probackup.log')
|
||||||
|
|
||||||
|
log_file_size = os.stat(log_file_path).st_size
|
||||||
|
|
||||||
self.assertTrue(os.path.isfile(rotation_file_path))
|
self.assertTrue(os.path.isfile(rotation_file_path))
|
||||||
|
|
||||||
# mangle .rotation file
|
# mangle .rotation file
|
||||||
@@ -227,9 +260,14 @@ class LogTest(ProbackupTest, unittest.TestCase):
|
|||||||
backup_dir, 'node', node,
|
backup_dir, 'node', node,
|
||||||
options=[
|
options=[
|
||||||
'--stream',
|
'--stream',
|
||||||
'--log-level-file=VERBOSE'],
|
'--log-level-file=LOG'],
|
||||||
return_id=False)
|
return_id=False)
|
||||||
|
|
||||||
|
# check that log file wasn`t rotated
|
||||||
|
self.assertGreater(
|
||||||
|
os.stat(log_file_path).st_size,
|
||||||
|
log_file_size)
|
||||||
|
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
'WARNING: rotation file "{0}" has wrong '
|
'WARNING: rotation file "{0}" has wrong '
|
||||||
'creation timestamp'.format(rotation_file_path),
|
'creation timestamp'.format(rotation_file_path),
|
||||||
@@ -241,12 +279,17 @@ class LogTest(ProbackupTest, unittest.TestCase):
|
|||||||
backup_dir, 'node', node,
|
backup_dir, 'node', node,
|
||||||
options=[
|
options=[
|
||||||
'--stream',
|
'--stream',
|
||||||
'--log-level-file=VERBOSE'],
|
'--log-level-file=LOG'],
|
||||||
return_id=False)
|
return_id=False)
|
||||||
|
|
||||||
self.assertNotIn(
|
self.assertNotIn(
|
||||||
'WARNING:',
|
'WARNING:',
|
||||||
output)
|
output)
|
||||||
|
|
||||||
|
# check that log file wasn`t rotated
|
||||||
|
self.assertGreater(
|
||||||
|
os.stat(log_file_path).st_size,
|
||||||
|
log_file_size)
|
||||||
|
|
||||||
# Clean after yourself
|
# Clean after yourself
|
||||||
self.del_test_dir(module_name, fname)
|
self.del_test_dir(module_name, fname)
|
||||||
|
Reference in New Issue
Block a user