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
25 changes: 0 additions & 25 deletions tests/platform_tests/link_flap/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
Teardowns used by the link flap tests.
"""

import time

import pytest

from tests.platform_tests.link_flap.link_flap_utils import build_test_candidates

def pytest_addoption(parser):
"""
Adds options to pytest that are used by the Link flap tests.
Expand All @@ -23,22 +17,3 @@ def pytest_addoption(parser):
help="Orchagent CPU threshold",
)


@pytest.fixture()
def bring_up_fanout_interfaces(request, duthosts, fanouthosts):
"""
Bring up outer interfaces on the DUT.

Args:
request: pytest request object
duthosts: Fixture for interacting with the DUT list.
fanouthosts: Fixture for interacting with the fanouts.
"""
yield
if request.node.rep_call.failed:
for dut in duthosts:
candidates = build_test_candidates(dut, fanouthosts, "all_ports")
for _, fanout, fanout_port in candidates:
fanout.no_shutdown(fanout_port)

time.sleep(60)
26 changes: 17 additions & 9 deletions tests/platform_tests/link_flap/link_flap_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,24 @@ def toggle_one_link(dut, dut_port, fanout, fanout_port, watch=False):
pytest_assert(__check_if_status(dut, dut_port, 'up', verbose=True), "Fail: dut port {}: link operational down".format(dut_port))

logger.info("Shutting down fanout switch %s port %s connecting to %s", fanout.hostname, fanout_port, dut_port)
fanout.shutdown(fanout_port)
pytest_assert(wait_until(30, 1, __check_if_status, dut, dut_port, 'down', True), "dut port {} didn't go down as expected".format(dut_port))

if watch:
time.sleep(1)
watch_system_status(dut)

logger.info("Bring up fanout switch %s port %s connecting to %s", fanout.hostname, fanout_port, dut_port)
fanout.no_shutdown(fanout_port)
pytest_assert(wait_until(30, 1, __check_if_status, dut, dut_port, 'up', True), "dut port {} didn't go up as expected".format(dut_port))
need_recovery = True
try:
fanout.shutdown(fanout_port)
pytest_assert(wait_until(30, 1, __check_if_status, dut, dut_port, 'down', True), "dut port {} didn't go down as expected".format(dut_port))

if watch:
time.sleep(1)
watch_system_status(dut)

logger.info("Bring up fanout switch %s port %s connecting to %s", fanout.hostname, fanout_port, dut_port)
fanout.no_shutdown(fanout_port)
need_recovery = False
pytest_assert(wait_until(30, 1, __check_if_status, dut, dut_port, 'up', True), "dut port {} didn't go up as expected".format(dut_port))
finally:
if need_recovery:
fanout.no_shutdown(fanout_port)
wait_until(30, 1, __check_if_status, dut, dut_port, 'up', True)


def watch_system_status(dut):
Expand Down
7 changes: 3 additions & 4 deletions tests/platform_tests/link_flap/test_cont_link_flap.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import time
import pytest

from tests.common.helpers.assertions import pytest_assert
from tests.common.helpers.assertions import pytest_assert, pytest_require
from tests.common import port_toggle
from tests.platform_tests.link_flap.link_flap_utils import build_test_candidates, toggle_one_link, check_orch_cpu_utilization, check_bgp_routes
from tests.common.utilities import wait_until
Expand All @@ -26,7 +26,7 @@ class TestContLinkFlap(object):
TestContLinkFlap class for continuous link flap
"""

def test_cont_link_flap(self, request, duthost, fanouthosts, bring_up_fanout_interfaces, bring_up_dut_interfaces):
def test_cont_link_flap(self, request, duthost, fanouthosts, bring_up_dut_interfaces):
"""
Validates that continuous link flap works as expected

Expand Down Expand Up @@ -75,8 +75,7 @@ def test_cont_link_flap(self, request, duthost, fanouthosts, bring_up_fanout_int
logging.info("%d Iteration flap all interfaces one by one on Peer Device", iteration + 1)
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")
pytest_require(candidates, "Didn't find any port that is admin up and present in the connection graph")

for dut_port, fanout, fanout_port in candidates:
toggle_one_link(duthost, dut_port, fanout, fanout_port, watch=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/platform_tests/link_flap/test_link_flap.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def run_link_flap_test(self, dut, fanouthosts, port):


@pytest.mark.platform('physical')
def test_link_flap(request, duthosts, enum_dut_portname, fanouthosts, bring_up_fanout_interfaces):
def test_link_flap(request, duthosts, enum_dut_portname, fanouthosts):
"""
Validates that link flap works as expected
"""
Expand Down