Skip to content

Commit 000172a

Browse files
authored
Manual cherry-pick PR:Handle v6 only for mtu test#20824 (sonic-net#920)
run test for v4 or v6 only if exists.
1 parent 673ae53 commit 000172a

2 files changed

Lines changed: 28 additions & 12 deletions

File tree

ansible/roles/test/files/ptftests/py3/mtu_test.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,23 @@ def runTest(self):
210210
"""
211211

212212
self.pktlen = self.testbed_mtu
213-
self.check_icmp_mtu()
214-
self.check_icmp_mtu(ipv4=False)
215-
self.check_ip_mtu()
216-
self.check_ip_mtu(ipv4=False)
213+
ipv4_available = (
214+
self.src_host_ip is not None
215+
and self.src_router_ip is not None
216+
and self.dst_host_ip is not None
217+
)
218+
ipv6_available = (
219+
self.src_host_ipv6 is not None
220+
and self.src_router_ipv6 is not None
221+
and self.dst_host_ipv6 is not None
222+
)
223+
if not ipv4_available and not ipv6_available:
224+
raise Exception("Neither IPv4 nor IPv6 addresses are available for MTU testing")
225+
if ipv4_available:
226+
logging.info("Running IPv4 MTU tests")
227+
self.check_icmp_mtu()
228+
self.check_ip_mtu()
229+
if ipv6_available:
230+
logging.info("Running IPv6 MTU tests")
231+
self.check_icmp_mtu(ipv4=False)
232+
self.check_ip_mtu(ipv4=False)

tests/ipfwd/test_mtu.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ def test_mtu(tbinfo, ptfhost, mtu, gather_facts):
2828
params={"testbed_type": testbed_type,
2929
"router_mac": gather_facts['src_router_mac'],
3030
"testbed_mtu": mtu,
31-
"src_host_ip": gather_facts['src_host_ipv4'],
32-
"src_router_ip": gather_facts['src_router_ipv4'],
33-
"dst_host_ip": gather_facts['dst_host_ipv4'],
34-
"src_host_ipv6": gather_facts['src_host_ipv6'],
35-
"src_router_ipv6": gather_facts['src_router_ipv6'],
36-
"dst_host_ipv6": gather_facts['dst_host_ipv6'],
37-
"src_ptf_port_list": gather_facts['src_port_ids'],
38-
"dst_ptf_port_list": gather_facts['dst_port_ids'],
31+
"src_host_ip": gather_facts.get('src_host_ipv4'),
32+
"src_router_ip": gather_facts.get('src_router_ipv4'),
33+
"dst_host_ip": gather_facts.get('dst_host_ipv4'),
34+
"src_host_ipv6": gather_facts.get('src_host_ipv6'),
35+
"src_router_ipv6": gather_facts.get('src_router_ipv6'),
36+
"dst_host_ipv6": gather_facts.get('dst_host_ipv6'),
37+
"src_ptf_port_list": gather_facts.get('src_port_ids'),
38+
"dst_ptf_port_list": gather_facts.get('dst_port_ids'),
3939
"kvm_support": True
4040
},
4141
log_file=log_file,

0 commit comments

Comments
 (0)