diff options
author | zsdc <taras@vyos.io> | 2021-12-13 20:05:25 +0200 |
---|---|---|
committer | zsdc <taras@vyos.io> | 2021-12-13 21:45:47 +0200 |
commit | 945ab070b72ebd9f5ccfe0052ed138a93b83b297 (patch) | |
tree | 9e3c40eba1190f9e8edff9fb9c1219b18cc91fc0 /smoketest/scripts | |
parent | a22ba14999a38217155a7a999f61e855d813cc41 (diff) | |
download | vyos-1x-945ab070b72ebd9f5ccfe0052ed138a93b83b297.tar.gz vyos-1x-945ab070b72ebd9f5ccfe0052ed138a93b83b297.zip |
logs: T3774: Added new CLI item
Added the ability to control the `/var/log/messages` rotation.
Renamed the option `maxsize` to `max-size`.
Diffstat (limited to 'smoketest/scripts')
-rwxr-xr-x | smoketest/scripts/cli/test_system_logs.py | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/smoketest/scripts/cli/test_system_logs.py b/smoketest/scripts/cli/test_system_logs.py index bb23dcb1d..0c11c4663 100755 --- a/smoketest/scripts/cli/test_system_logs.py +++ b/smoketest/scripts/cli/test_system_logs.py @@ -19,11 +19,14 @@ import unittest from base_vyostest_shim import VyOSUnitTestSHIM from vyos.util import read_file -# path to logrotate config for atop +# path to logrotate configs logrotate_atop_file = '/etc/logrotate.d/vyos-atop' +logrotate_rsyslog_file = '/etc/logrotate.d/vyos-rsyslog' # default values default_atop_maxsize = '10M' default_atop_rotate = '10' +default_rsyslog_size = '1M' +default_rsyslog_rotate = '10' base_path = ['system', 'logs'] @@ -64,13 +67,18 @@ class TestSystemLogs(VyOSUnitTestSHIM.TestCase): self.cli_commit() # read the config file and check content - logrotate_config = logrotate_config_parse(logrotate_atop_file) - self.assertEqual(logrotate_config['maxsize'], default_atop_maxsize) - self.assertEqual(logrotate_config['rotate'], default_atop_rotate) + logrotate_config_atop = logrotate_config_parse(logrotate_atop_file) + logrotate_config_rsyslog = logrotate_config_parse( + logrotate_rsyslog_file) + self.assertEqual(logrotate_config_atop['maxsize'], default_atop_maxsize) + self.assertEqual(logrotate_config_atop['rotate'], default_atop_rotate) + self.assertEqual(logrotate_config_rsyslog['size'], default_rsyslog_size) + self.assertEqual(logrotate_config_rsyslog['rotate'], + default_rsyslog_rotate) def test_logs_atop_maxsize(self): # test for maxsize option - self.cli_set(base_path + ['logrotate', 'atop', 'maxsize', '50']) + self.cli_set(base_path + ['logrotate', 'atop', 'max-size', '50']) self.cli_commit() # read the config file and check content @@ -86,6 +94,24 @@ class TestSystemLogs(VyOSUnitTestSHIM.TestCase): logrotate_config = logrotate_config_parse(logrotate_atop_file) self.assertEqual(logrotate_config['rotate'], '50') + def test_logs_rsyslog_size(self): + # test for size option + self.cli_set(base_path + ['logrotate', 'messages', 'max-size', '50']) + self.cli_commit() + + # read the config file and check content + logrotate_config = logrotate_config_parse(logrotate_rsyslog_file) + self.assertEqual(logrotate_config['size'], '50M') + + def test_logs_rsyslog_rotate(self): + # test for rotate option + self.cli_set(base_path + ['logrotate', 'messages', 'rotate', '50']) + self.cli_commit() + + # read the config file and check content + logrotate_config = logrotate_config_parse(logrotate_rsyslog_file) + self.assertEqual(logrotate_config['rotate'], '50') + if __name__ == '__main__': unittest.main(verbosity=2, failfast=True) |