From 60ac5480e9e5056299fccb544e7286def90149ee Mon Sep 17 00:00:00 2001 From: Tom Custodio Date: Mon, 12 Jul 2021 12:17:26 -0400 Subject: [PATCH] [arp] Allow use of discontiguous ports with ARP tests. --- tests/arp/conftest.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/arp/conftest.py b/tests/arp/conftest.py index 30a3cd94df21..bc8520cdaf16 100644 --- a/tests/arp/conftest.py +++ b/tests/arp/conftest.py @@ -50,9 +50,27 @@ 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)