From d6e6b2de04631e6ca0a4eb0339580ab0ecedd464 Mon Sep 17 00:00:00 2001 From: Ori Trabelsi Date: Fri, 26 Sep 2025 00:16:45 +0300 Subject: [PATCH] Handle v6 only for mtu test. run test for v4 or v6 only if exists. --- .../roles/test/files/ptftests/py3/mtu_test.py | 24 +++++++++++++++---- tests/ipfwd/test_mtu.py | 16 ++++++------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/ansible/roles/test/files/ptftests/py3/mtu_test.py b/ansible/roles/test/files/ptftests/py3/mtu_test.py index b33ffc638d..4edca2f4da 100644 --- a/ansible/roles/test/files/ptftests/py3/mtu_test.py +++ b/ansible/roles/test/files/ptftests/py3/mtu_test.py @@ -210,7 +210,23 @@ def runTest(self): """ self.pktlen = self.testbed_mtu - self.check_icmp_mtu() - self.check_icmp_mtu(ipv4=False) - self.check_ip_mtu() - self.check_ip_mtu(ipv4=False) + ipv4_available = ( + self.src_host_ip is not None + and self.src_router_ip is not None + and self.dst_host_ip is not None + ) + ipv6_available = ( + self.src_host_ipv6 is not None + and self.src_router_ipv6 is not None + and self.dst_host_ipv6 is not None + ) + if not ipv4_available and not ipv6_available: + raise Exception("Neither IPv4 nor IPv6 addresses are available for MTU testing") + if ipv4_available: + logging.info("Running IPv4 MTU tests") + self.check_icmp_mtu() + self.check_ip_mtu() + if ipv6_available: + logging.info("Running IPv6 MTU tests") + self.check_icmp_mtu(ipv4=False) + self.check_ip_mtu(ipv4=False) diff --git a/tests/ipfwd/test_mtu.py b/tests/ipfwd/test_mtu.py index b8351a3bd5..fcb765f950 100644 --- a/tests/ipfwd/test_mtu.py +++ b/tests/ipfwd/test_mtu.py @@ -28,14 +28,14 @@ def test_mtu(tbinfo, ptfhost, mtu, gather_facts): params={"testbed_type": testbed_type, "router_mac": gather_facts['src_router_mac'], "testbed_mtu": mtu, - "src_host_ip": gather_facts['src_host_ipv4'], - "src_router_ip": gather_facts['src_router_ipv4'], - "dst_host_ip": gather_facts['dst_host_ipv4'], - "src_host_ipv6": gather_facts['src_host_ipv6'], - "src_router_ipv6": gather_facts['src_router_ipv6'], - "dst_host_ipv6": gather_facts['dst_host_ipv6'], - "src_ptf_port_list": gather_facts['src_port_ids'], - "dst_ptf_port_list": gather_facts['dst_port_ids'], + "src_host_ip": gather_facts.get('src_host_ipv4'), + "src_router_ip": gather_facts.get('src_router_ipv4'), + "dst_host_ip": gather_facts.get('dst_host_ipv4'), + "src_host_ipv6": gather_facts.get('src_host_ipv6'), + "src_router_ipv6": gather_facts.get('src_router_ipv6'), + "dst_host_ipv6": gather_facts.get('dst_host_ipv6'), + "src_ptf_port_list": gather_facts.get('src_port_ids'), + "dst_ptf_port_list": gather_facts.get('dst_port_ids'), "kvm_support": True }, log_file=log_file,