1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-12-04 10:44:46 +02:00

tests: check that log file do not gets rotated if '.rotation' file is missing or mangled

This commit is contained in:
Grigory Smolkin 2019-04-19 18:42:07 +03:00
parent c93e732864
commit ea50f4e9cf

View File

@ -88,17 +88,20 @@ class LogTest(ProbackupTest, unittest.TestCase):
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'])
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))
# truncate .rotation file
@ -111,9 +114,14 @@ class LogTest(ProbackupTest, unittest.TestCase):
backup_dir, 'node', node,
options=[
'--stream',
'--log-level-file=VERBOSE'],
'--log-level-file=LOG'],
return_id=False)
# check that log file wasn`t rotated
self.assertGreater(
os.stat(log_file_path).st_size,
log_file_size)
self.assertIn(
'WARNING: cannot read creation timestamp from rotation file',
output)
@ -122,9 +130,14 @@ class LogTest(ProbackupTest, unittest.TestCase):
backup_dir, 'node', node,
options=[
'--stream',
'--log-level-file=VERBOSE'],
'--log-level-file=LOG'],
return_id=False)
# check that log file wasn`t rotated
self.assertGreater(
os.stat(log_file_path).st_size,
log_file_size)
self.assertNotIn(
'WARNING:',
output)
@ -149,9 +162,6 @@ class LogTest(ProbackupTest, unittest.TestCase):
backup_dir, 'node',
options=['--log-rotation-age=1d'])
rotation_file_path = os.path.join(
backup_dir, 'log', 'pg_probackup.log.rotation')
self.backup_node(
backup_dir, 'node', node,
@ -159,6 +169,14 @@ class LogTest(ProbackupTest, unittest.TestCase):
'--stream',
'--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))
# unlink .rotation file
@ -168,9 +186,14 @@ class LogTest(ProbackupTest, unittest.TestCase):
backup_dir, 'node', node,
options=[
'--stream',
'--log-level-file=VERBOSE'],
'--log-level-file=LOG'],
return_id=False)
# check that log file wasn`t rotated
self.assertGreater(
os.stat(log_file_path).st_size,
log_file_size)
self.assertIn(
'WARNING: missing rotation file:',
output)
@ -188,6 +211,11 @@ class LogTest(ProbackupTest, unittest.TestCase):
'WARNING:',
output)
# check that log file wasn`t rotated
self.assertGreater(
os.stat(log_file_path).st_size,
log_file_size)
# Clean after yourself
self.del_test_dir(module_name, fname)
@ -206,15 +234,20 @@ class LogTest(ProbackupTest, unittest.TestCase):
backup_dir, 'node',
options=['--log-rotation-age=1d'])
rotation_file_path = os.path.join(
backup_dir, 'log', 'pg_probackup.log.rotation')
self.backup_node(
backup_dir, 'node', node,
options=[
'--stream',
'--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))
# mangle .rotation file
@ -227,9 +260,14 @@ class LogTest(ProbackupTest, unittest.TestCase):
backup_dir, 'node', node,
options=[
'--stream',
'--log-level-file=VERBOSE'],
'--log-level-file=LOG'],
return_id=False)
# check that log file wasn`t rotated
self.assertGreater(
os.stat(log_file_path).st_size,
log_file_size)
self.assertIn(
'WARNING: rotation file "{0}" has wrong '
'creation timestamp'.format(rotation_file_path),
@ -241,12 +279,17 @@ class LogTest(ProbackupTest, unittest.TestCase):
backup_dir, 'node', node,
options=[
'--stream',
'--log-level-file=VERBOSE'],
'--log-level-file=LOG'],
return_id=False)
self.assertNotIn(
'WARNING:',
output)
# check that log file wasn`t rotated
self.assertGreater(
os.stat(log_file_path).st_size,
log_file_size)
# Clean after yourself
self.del_test_dir(module_name, fname)