Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions tests/platform_tests/link_flap/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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)
11 changes: 8 additions & 3 deletions tests/platform_tests/link_flap/link_flap_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion tests/platform_tests/link_flap/test_cont_link_flap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down