diff --git a/tests/platform_tests/link_flap/conftest.py b/tests/platform_tests/link_flap/conftest.py index d6341065ddd..1c71b8708bc 100644 --- a/tests/platform_tests/link_flap/conftest.py +++ b/tests/platform_tests/link_flap/conftest.py @@ -9,7 +9,6 @@ import pytest from tests.platform_tests.link_flap.link_flap_utils import build_test_candidates -from tests.common.helpers.dut_ports import decode_dut_port_name def pytest_addoption(parser): """ @@ -26,23 +25,20 @@ def pytest_addoption(parser): @pytest.fixture() -def bring_up_fanout_interfaces(request, all_ports, duthosts, fanouthosts): +def bring_up_fanout_interfaces(request, duthosts, fanouthosts): """ Bring up outer interfaces on the DUT. Args: request: pytest request object - duthost: Fixture for interacting with the DUT. + duthosts: Fixture for interacting with the DUT list. fanouthosts: Fixture for interacting with the fanouts. """ yield if request.node.rep_call.failed: - dutname, portname = decode_dut_port_name(all_ports) - for dut in duthosts: - if dutname == 'unknown' or dutname == dut.hostname: - candidates = build_test_candidates(dut, fanouthosts, portname) - for _, fanout, fanout_port in candidates: - fanout.no_shutdown(fanout_port) + candidates = build_test_candidates(dut, fanouthosts, "all_ports") + for _, fanout, fanout_port in candidates: + fanout.no_shutdown(fanout_port) time.sleep(60) diff --git a/tests/platform_tests/link_flap/link_flap_utils.py b/tests/platform_tests/link_flap/link_flap_utils.py index d1a8fdc8256..b39a4291b88 100644 --- a/tests/platform_tests/link_flap/link_flap_utils.py +++ b/tests/platform_tests/link_flap/link_flap_utils.py @@ -80,7 +80,11 @@ def build_test_candidates(dut, fanouthosts, port, completeness_level=None): Args: dut: DUT host object fanouthosts: List of fanout switch instances. - port: port + port: port, when port == 'unknown' or 'all_ports' + candidate will be all ports. A warning will + be generated if the port == 'unknown'. + caller can use 'all_ports' explicitly to mute + the warning. completeness_level: Completeness level. Returns: @@ -89,13 +93,14 @@ def build_test_candidates(dut, fanouthosts, port, completeness_level=None): """ candidates = [] - if port != 'unknown': + if port not in [ 'unknown', 'all_ports' ]: status = __get_dut_if_status(dut, port) fanout, fanout_port = fanout_switch_port_lookup(fanouthosts, dut.hostname, port) __build_candidate_list(candidates, fanout, fanout_port, port, status) else: # Build the full list - logger.warning("Failed to get ports enumerated as parameter. Fall back to test all ports") + if port == 'unknown': + logger.warning("Failed to get ports enumerated as parameter. Fall back to test all ports") status = __get_dut_if_status(dut) for dut_port in status.keys(): diff --git a/tests/platform_tests/link_flap/test_cont_link_flap.py b/tests/platform_tests/link_flap/test_cont_link_flap.py index 8af3078c3af..6f6cdaa1f80 100644 --- a/tests/platform_tests/link_flap/test_cont_link_flap.py +++ b/tests/platform_tests/link_flap/test_cont_link_flap.py @@ -73,7 +73,7 @@ def test_cont_link_flap(self, request, duthost, fanouthosts, bring_up_fanout_int # Flap all interfaces one by one on Peer Device for iteration in range(3): logging.info("%d Iteration flap all interfaces one by one on Peer Device", iteration + 1) - candidates = build_test_candidates(duthost, fanouthosts, 'unknown') + candidates = build_test_candidates(duthost, fanouthosts, 'all_ports') if not candidates: pytest.skip("Didn't find any port that is admin up and present in the connection graph")