diff options
author | Christian Breunig <christian@breunig.cc> | 2024-11-07 22:05:00 +0100 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2024-11-07 22:11:27 +0100 |
commit | 9ba81b263f4e0dd7b5dbf2e766702eedff96538b (patch) | |
tree | 3cacefe0e1f050410fab4b0a69508b3e12770ee1 /smoketest | |
parent | 12f9bdf93aa248309fae16883c27f69de4cdc338 (diff) | |
download | vyos-1x-9ba81b263f4e0dd7b5dbf2e766702eedff96538b.tar.gz vyos-1x-9ba81b263f4e0dd7b5dbf2e766702eedff96538b.zip |
syslog: T6858: bugfix remote syslog using TCP
Commit 042be39cc ("syslog: T5367: add format option to include timezone in
message") added an invalid, outer if-statement when rendering the rsyslog
configuration option for TCP.
Remote hosts only got added when the format option "octet-counting" was defined
in addition to the TCP protocol. This has been fix and now TCP transport is
decoupled from octet-counting mode.
Diffstat (limited to 'smoketest')
-rwxr-xr-x | smoketest/scripts/cli/test_system_syslog.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_system_syslog.py b/smoketest/scripts/cli/test_system_syslog.py index d9e16eef8..a86711119 100755 --- a/smoketest/scripts/cli/test_system_syslog.py +++ b/smoketest/scripts/cli/test_system_syslog.py @@ -21,6 +21,7 @@ from base_vyostest_shim import VyOSUnitTestSHIM from vyos.utils.file import read_file from vyos.utils.process import process_named_running +from vyos.xml_ref import default_value PROCESS_NAME = 'rsyslogd' RSYSLOG_CONF = '/etc/rsyslog.d/00-vyos.conf' @@ -102,6 +103,29 @@ class TestRSYSLOGService(VyOSUnitTestSHIM.TestCase): # Check for running process self.assertTrue(process_named_running(PROCESS_NAME)) + def test_syslog_remote(self): + rhost = '169.254.0.1' + default_port = default_value(base_path + ['host', rhost, 'port']) + + self.cli_set(base_path + ['global', 'facility', 'all', 'level', 'info']) + self.cli_set(base_path + ['global', 'facility', 'local7', 'level', 'debug']) + self.cli_set(base_path + ['host', rhost, 'facility', 'all', 'level', 'all']) + self.cli_set(base_path + ['host', rhost, 'protocol', 'tcp']) + + self.cli_commit() + + config = read_file(RSYSLOG_CONF) + self.assertIn(f'*.* @@{rhost}:{default_port}', config) + + # Change default port and enable "octet-counting" mode + port = '10514' + self.cli_set(base_path + ['host', rhost, 'port', port]) + self.cli_set(base_path + ['host', rhost, 'format', 'octet-counted']) + self.cli_commit() + + config = read_file(RSYSLOG_CONF) + self.assertIn(f'*.* @@(o){rhost}:{port}', config) + if __name__ == '__main__': unittest.main(verbosity=2) |