aboutsummaryrefslogtreecommitdiffstats
path: root/test/asf/test_prom.py
diff options
context:
space:
mode:
authorIvan Ivanets <iivanets@cisco.com>2024-10-31 18:55:27 +0000
committerDave Wallace <dwallacelf@gmail.com>2024-11-19 16:52:48 +0000
commit9765e2763545fbf2879456d53557fab849534765 (patch)
tree41312b92e3a5c71c78509e5b1158119d2dfc559e /test/asf/test_prom.py
parenta2bc88bb694302fa6e2e65fca737ca3dd3b0854e (diff)
tests: vpp_qemu_utils with concurrency handling
Type: test Enhance vpp_qemu_utils functions with mutex locking, handle namespace and host interface existence, unique namespace/interface name, error handling and retries, check error code explicitly. Change-Id: I1ea66eeefbc1fee9b58e8b9886f4dd6fd8d33444 Signed-off-by: Ivan Ivanets <iivanets@cisco.com>
Diffstat (limited to 'test/asf/test_prom.py')
-rw-r--r--test/asf/test_prom.py42
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",
],