diff options
author | Daniil Baturin <daniil@vyos.io> | 2024-11-08 17:32:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-08 17:32:45 +0000 |
commit | ff82bd5cfd1719c31f8169309566e5c8e8d43571 (patch) | |
tree | d9bdf5902d2a90eb338080469d346600fd0df809 /smoketest/scripts | |
parent | a975403041cdff799faf0f07690c539633ac38a7 (diff) | |
parent | 9ba81b263f4e0dd7b5dbf2e766702eedff96538b (diff) | |
download | vyos-1x-current.tar.gz vyos-1x-current.zip |
syslog: T6858: bugfix remote syslog using TCP
Diffstat (limited to 'smoketest/scripts')
-rwxr-xr-x | smoketest/scripts/cli/test_system_syslog.py | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/smoketest/scripts/cli/test_system_syslog.py b/smoketest/scripts/cli/test_system_syslog.py index c802ceeeb..a86711119 100755 --- a/smoketest/scripts/cli/test_system_syslog.py +++ b/smoketest/scripts/cli/test_system_syslog.py @@ -20,8 +20,8 @@ import unittest from base_vyostest_shim import VyOSUnitTestSHIM from vyos.utils.file import read_file -from vyos.utils.process import cmd 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' @@ -80,20 +80,22 @@ class TestRSYSLOGService(VyOSUnitTestSHIM.TestCase): self.assertTrue(process_named_running(PROCESS_NAME)) def test_syslog_global(self): - self.cli_set(['system', 'host-name', 'vyos']) - self.cli_set(['system', 'domain-name', 'example.local']) + hostname = 'vyos123' + domainname = 'example.local' + self.cli_set(['system', 'host-name', hostname]) + self.cli_set(['system', 'domain-name', domainname]) self.cli_set(base_path + ['global', 'marker', 'interval', '600']) self.cli_set(base_path + ['global', 'preserve-fqdn']) self.cli_set(base_path + ['global', 'facility', 'kern', 'level', 'err']) self.cli_commit() - config = cmd(f'sudo cat {RSYSLOG_CONF}') + config = read_file(RSYSLOG_CONF) expected = [ '$MarkMessagePeriod 600', '$PreserveFQDN on', 'kern.err', - '$LocalHostName vyos.example.local', + f'$LocalHostName {hostname}.{domainname}', ] for e in expected: @@ -101,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) |