summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authoradrianvillin <avillin@cisco.com>2023-12-05 11:47:00 +0100
committerDave Wallace <dwallacelf@gmail.com>2024-04-09 16:17:29 +0000
commitbfbe7a8c9a8b830619c532381f30681c563f6ad9 (patch)
tree1f29ed2b6d81d908c62609765453094e3b44f538 /test
parentbf89b81779e8d27be9a0b43ce75b6e5fe34af31a (diff)
tests: Added a simple prom(etheus exporter) plugin test
Type: test Change-Id: Ibceabc411f09d80cc23be6f2e7c8abd56d4c4ac2 Signed-off-by: adrianvillin <avillin@cisco.com>
Diffstat (limited to 'test')
-rw-r--r--test/asf/test_prom.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/asf/test_prom.py b/test/asf/test_prom.py
new file mode 100644
index 00000000000..3f8fb4c7a44
--- /dev/null
+++ b/test/asf/test_prom.py
@@ -0,0 +1,58 @@
+from config import config
+from asfframework import VppAsfTestCase, VppTestRunner
+import unittest
+import subprocess
+from vpp_qemu_utils import (
+ create_host_interface,
+ delete_host_interfaces,
+ create_namespace,
+ delete_namespace,
+)
+
+
+@unittest.skipIf(
+ "http_static" in config.excluded_plugins, "Exclude HTTP Static Server plugin tests"
+)
+@unittest.skipIf("prom" in config.excluded_plugins, "Exclude Prometheus plugin tests")
+@unittest.skipIf(config.skip_netns_tests, "netns not available or disabled from cli")
+class TestProm(VppAsfTestCase):
+ """Prometheus plugin test"""
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestProm, cls).setUpClass()
+
+ create_namespace("HttpStaticProm")
+ create_host_interface("vppHost", "vppOut", "HttpStaticProm", "10.10.1.1/24")
+
+ cls.vapi.cli("create host-interface name vppOut")
+ cls.vapi.cli("set int state host-vppOut up")
+ cls.vapi.cli("set int ip address host-vppOut 10.10.1.2/24")
+
+ @classmethod
+ def tearDownClass(cls):
+ delete_namespace(["HttpStaticProm"])
+ delete_host_interfaces("vppHost")
+ super(TestProm, cls).tearDownClass()
+
+ def test_prom(self):
+ """Enable HTTP Static server and prometheus exporter, get stats"""
+ self.vapi.cli("http static server uri tcp://0.0.0.0/80 url-handlers")
+ self.vapi.cli("prom enable")
+
+ process = subprocess.run(
+ [
+ "ip",
+ "netns",
+ "exec",
+ "HttpStaticProm",
+ "curl",
+ f"10.10.1.2/stats.prom",
+ ],
+ capture_output=True,
+ )
+ self.assertIn(b"TYPE", process.stdout)
+
+
+if __name__ == "__main__":
+ unittest.main(testRunner=VppTestRunner)