diff options
author | Christian Breunig <christian@breunig.cc> | 2024-06-28 14:47:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-28 14:47:37 +0200 |
commit | f36271bd2f91aa6cf0bc0176160d3a2abfb9a21f (patch) | |
tree | a8fe21633e1698e65676b6c9f0e0a7f963a8f83e /smoketest/scripts | |
parent | 12fcf6c5ef2e5678b0b88c34d6c031435d85ec68 (diff) | |
parent | 3365eb7ab99fa9a259fe440eb51e82fc0a0a4dc6 (diff) | |
download | vyos-1x-f36271bd2f91aa6cf0bc0176160d3a2abfb9a21f.tar.gz vyos-1x-f36271bd2f91aa6cf0bc0176160d3a2abfb9a21f.zip |
Merge pull request #3720 from sever-sever/T6477
T6477: Add telegraf loki output plugin
Diffstat (limited to 'smoketest/scripts')
-rwxr-xr-x | smoketest/scripts/cli/test_service_monitoring_telegraf.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_service_monitoring_telegraf.py b/smoketest/scripts/cli/test_service_monitoring_telegraf.py index 3374411f5..886b88683 100755 --- a/smoketest/scripts/cli/test_service_monitoring_telegraf.py +++ b/smoketest/scripts/cli/test_service_monitoring_telegraf.py @@ -17,6 +17,7 @@ import unittest from base_vyostest_shim import VyOSUnitTestSHIM +from vyos.configsession import ConfigSessionError from vyos.utils.process import process_named_running from vyos.utils.file import read_file @@ -63,5 +64,33 @@ class TestMonitoringTelegraf(VyOSUnitTestSHIM.TestCase): for input in inputs: self.assertIn(input, config) + def test_02_loki(self): + label = 'r123' + loki_url = 'http://localhost' + port = '3100' + loki_username = 'VyOS' + loki_password = 'PassW0Rd_VyOS' + + self.cli_set(base_path + ['loki', 'url', loki_url]) + self.cli_set(base_path + ['loki', 'port', port]) + self.cli_set(base_path + ['loki', 'metric-name-label', label]) + + self.cli_set(base_path + ['loki', 'authentication', 'username', loki_username]) + # password not set + with self.assertRaises(ConfigSessionError): + self.cli_commit() + self.cli_set(base_path + ['loki', 'authentication', 'password', loki_password]) + + # commit changes + self.cli_commit() + + config = read_file(TELEGRAF_CONF) + self.assertIn(f'[[outputs.loki]]', config) + self.assertIn(f'domain = "{loki_url}:{port}"', config) + self.assertIn(f'metric_name_label = "{label}"', config) + self.assertIn(f'username = "{loki_username}"', config) + self.assertIn(f'password = "{loki_password}"', config) + + if __name__ == '__main__': unittest.main(verbosity=2) |