diff options
author | adrianvillin <avillin@cisco.com> | 2023-11-08 15:17:14 +0100 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2023-11-08 20:36:49 +0000 |
commit | 098ee3aaf1747feb913a42ada4b61868a0d5f644 (patch) | |
tree | 452b08b1cbd9d2323a280f1541a034f66a39ac66 | |
parent | e59761f721f8a667a03e0c505b287bf69c47b532 (diff) |
tests: Fix http static test failing on retry
- test_http_static.py: If namespace creation fails, try to delete the namespace and create it again
- vpp_qemu_utils.py: Added "isinstance()" to "delete_namespace()" to match "create_namespace()"
Type: test
Change-Id: I88ff7a36f5d52816fee16283efba6af025496491
Signed-off-by: adrianvillin <avillin@cisco.com>
-rw-r--r-- | test/asf/test_http_static.py | 20 | ||||
-rw-r--r-- | test/vpp_qemu_utils.py | 6 |
2 files changed, 21 insertions, 5 deletions
diff --git a/test/asf/test_http_static.py b/test/asf/test_http_static.py index 1d87f4c75bd..18e8ba56a1e 100644 --- a/test/asf/test_http_static.py +++ b/test/asf/test_http_static.py @@ -28,7 +28,13 @@ class TestHttpStaticVapi(VppAsfTestCase): cls.temp2 = tempfile.NamedTemporaryFile() cls.temp2.write(b"Hello world2") - create_namespace("HttpStatic") + try: + create_namespace("HttpStatic") + except Exception: + cls.logger.warning("Unable to create a namespace, retrying.") + delete_namespace("HttpStatic") + create_namespace("HttpStatic") + create_host_interface("vppHost", "vppOut", "HttpStatic", "10.10.1.1/24") cls.vapi.cli("create host-interface name vppOut") @@ -37,7 +43,7 @@ class TestHttpStaticVapi(VppAsfTestCase): @classmethod def tearDownClass(cls): - delete_namespace(["HttpStatic"]) + delete_namespace("HttpStatic") delete_host_interfaces("vppHost") cls.temp.close() cls.temp2.close() @@ -95,7 +101,13 @@ class TestHttpStaticCli(VppAsfTestCase): cls.temp2 = tempfile.NamedTemporaryFile() cls.temp2.write(b"Hello world2") - create_namespace("HttpStatic2") + try: + create_namespace("HttpStatic2") + except Exception: + cls.logger.warning("Unable to create namespace, retrying.") + delete_namespace("HttpStatic2") + create_namespace("HttpStatic2") + create_host_interface("vppHost2", "vppOut2", "HttpStatic2", "10.10.1.1/24") cls.vapi.cli("create host-interface name vppOut2") @@ -104,7 +116,7 @@ class TestHttpStaticCli(VppAsfTestCase): @classmethod def tearDownClass(cls): - delete_namespace(["HttpStatic2"]) + delete_namespace("HttpStatic2") delete_host_interfaces("vppHost2") cls.temp.close() cls.temp2.close() diff --git a/test/vpp_qemu_utils.py b/test/vpp_qemu_utils.py index e7e21a01b73..3a8fdc8daf5 100644 --- a/test/vpp_qemu_utils.py +++ b/test/vpp_qemu_utils.py @@ -216,12 +216,16 @@ def disable_interface_gso(namespace, interface): raise Exception("Error disabling gso:", e.output) -def delete_namespace(namespaces): +def delete_namespace(ns): """delete one or more namespaces. arguments: namespaces -- a list of namespace names """ + if isinstance(ns, str): + namespaces = [ns] + else: + namespaces = ns try: for namespace in namespaces: result = subprocess.run( |