diff options
Diffstat (limited to 'test/asf/test_prom.py')
-rw-r--r-- | test/asf/test_prom.py | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/test/asf/test_prom.py b/test/asf/test_prom.py index f536fd19d34..ffb86a1d8d3 100644 --- a/test/asf/test_prom.py +++ b/test/asf/test_prom.py @@ -1,12 +1,13 @@ from config import config -from asfframework import VppAsfTestCase, VppTestRunner +from asfframework import VppAsfTestCase, VppTestRunner, get_testcase_dirname import unittest import subprocess +import os from vpp_qemu_utils import ( create_host_interface, - delete_host_interfaces, + delete_all_host_interfaces, create_namespace, - delete_namespace, + delete_all_namespaces, ) @@ -22,17 +23,36 @@ class TestProm(VppAsfTestCase): def setUpClass(cls): super(TestProm, cls).setUpClass() - create_namespace("HttpStaticProm") - create_host_interface("vppHost", "vppOut", "HttpStaticProm", "10.10.1.1/24") + cls.ns_history_name = ( + f"{config.tmp_dir}/{get_testcase_dirname(cls.__name__)}/history_ns.txt" + ) + cls.if_history_name = ( + f"{config.tmp_dir}/{get_testcase_dirname(cls.__name__)}/history_if.txt" + ) + + try: + # CleanUp + delete_all_namespaces(cls.ns_history_name) + delete_all_host_interfaces(cls.if_history_name) - 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") + cls.ns_name = create_namespace(cls.ns_history_name) + + cls.host_if_name, cls.vpp_if_name = create_host_interface( + cls.if_history_name, cls.ns_name, "10.10.1.1/24" + ) + except Exception as e: + cls.logger.warning(f"Unable to complete setup: {e}") + raise unittest.SkipTest("Skipping tests due to setup failure.") + + cls.vapi.cli(f"create host-interface name {cls.vpp_if_name}") + cls.vapi.cli(f"set int state host-{cls.vpp_if_name} up") + cls.vapi.cli(f"set int ip address host-{cls.vpp_if_name} 10.10.1.2/24") @classmethod def tearDownClass(cls): - delete_namespace(["HttpStaticProm"]) - delete_host_interfaces("vppHost") + delete_all_namespaces(cls.ns_history_name) + delete_all_host_interfaces(cls.if_history_name) + super(TestProm, cls).tearDownClass() def test_prom(self): @@ -46,7 +66,7 @@ class TestProm(VppAsfTestCase): "ip", "netns", "exec", - "HttpStaticProm", + self.ns_name, "curl", f"10.10.1.2/stats.prom", ], |