From c7d9a4dd44ceb68198df20de7849a44a38e3c6df Mon Sep 17 00:00:00 2001 From: Tom Custodio Date: Mon, 12 Jul 2021 12:17:26 -0400 Subject: [PATCH 1/2] [arp] Allow use of discontiguous ports with ARP tests. --- tests/arp/conftest.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/arp/conftest.py b/tests/arp/conftest.py index 60988902d24..4f6c6bbb63e 100644 --- a/tests/arp/conftest.py +++ b/tests/arp/conftest.py @@ -92,9 +92,28 @@ def intfs_for_test(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_fro intf1 = ports_for_test[0] intf2 = ports_for_test[1] else: - # Select port index 0 & 1 two interfaces for testing - intf1 = ports[0] - intf2 = ports[1] + # Select first 2 ports that are admin 'up' + if duthost.is_multi_asic: + intf_status = duthost.show_interface(command='status', namespace=asic.namespace)['ansible_facts'][ + 'int_status'] + else: + intf_status = duthost.show_interface(command='status')['ansible_facts']['int_status'] + + intf1 = None + intf2 = None + for a_port in ports: + if intf_status[a_port]['admin_state'] == 'up': + if intf1 is None: + intf1 = a_port + elif intf2 is None: + intf2 = a_port + else: + break + + if intf1 is None or intf2 is None: + pytest.skip("Not enough interfaces on this host/asic (%s/%s) to support test." % (duthost.hostname, + asic.asic_index)) + po1 = get_po(mg_facts, intf1) po2 = get_po(mg_facts, intf2) From b11d1ea7fa18433504198012c0a8b846f4eb4f60 Mon Sep 17 00:00:00 2001 From: tcustodi Date: Fri, 11 Feb 2022 09:43:26 -0500 Subject: [PATCH 2/2] Addressing review comments --- tests/arp/conftest.py | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/tests/arp/conftest.py b/tests/arp/conftest.py index 4f6c6bbb63e..8c7033e85e3 100644 --- a/tests/arp/conftest.py +++ b/tests/arp/conftest.py @@ -92,29 +92,23 @@ def intfs_for_test(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_fro intf1 = ports_for_test[0] intf2 = ports_for_test[1] else: - # Select first 2 ports that are admin 'up' - if duthost.is_multi_asic: - intf_status = duthost.show_interface(command='status', namespace=asic.namespace)['ansible_facts'][ - 'int_status'] - else: - intf_status = duthost.show_interface(command='status')['ansible_facts']['int_status'] - - intf1 = None - intf2 = None - for a_port in ports: - if intf_status[a_port]['admin_state'] == 'up': - if intf1 is None: - intf1 = a_port - elif intf2 is None: - intf2 = a_port - else: - break - - if intf1 is None or intf2 is None: - pytest.skip("Not enough interfaces on this host/asic (%s/%s) to support test." % (duthost.hostname, - asic.asic_index)) - - + # Select first 2 ports that are admin 'up' + intf_status = asic.show_interface(command='status')['ansible_facts']['int_status'] + + intf1 = None + intf2 = None + for a_port in ports: + if intf_status[a_port]['admin_state'] == 'up': + if intf1 is None: + intf1 = a_port + elif intf2 is None: + intf2 = a_port + else: + break + + if intf1 is None or intf2 is None: + pytest.skip("Not enough interfaces on this host/asic (%s/%s) to support test." % (duthost.hostname, + asic.asic_index)) po1 = get_po(mg_facts, intf1) po2 = get_po(mg_facts, intf2)