Skip to content

Commit

Permalink
test_config_fec_oper_mode: Set the fec_mode to align with the current…
Browse files Browse the repository at this point in the history
… configuration of the interface. (#16360)

* Configure the fec_mode that interface is already configured for

* Fix a backslash
  • Loading branch information
vvolam authored and mssonicbld committed Jan 15, 2025
1 parent dd6cb4f commit 55575ba
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions tests/platform_tests/test_intf_fec.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import pytest

from tests.common.helpers.assertions import pytest_assert
from tests.common.utilities import skip_release, wait_until

pytestmark = [
Expand Down Expand Up @@ -28,6 +29,15 @@ def is_supported_platform(duthost):
pytest.skip("DUT has platform {}, test is not supported".format(duthost.facts['platform']))


def get_fec_oper_mode(duthost, interface):
"""
@Return: FEC operational mode for a specific interface
"""
logging.info("Get output of '{} {}'".format("show interfaces fec status", interface))
fec_status = duthost.show_and_parse("show interfaces fec status {}".format(interface))
return fec_status[0].get('fec oper', '').lower()


def test_verify_fec_oper_mode(duthosts, enum_rand_one_per_hwsku_frontend_hostname,
enum_frontend_asic_index, conn_graph_facts):
"""
Expand All @@ -52,9 +62,7 @@ def test_verify_fec_oper_mode(duthosts, enum_rand_one_per_hwsku_frontend_hostnam

if presence == "present" and oper == "up" and speed in SUPPORTED_SPEEDS:
# Verify the FEC operational mode is valid
logging.info("Get output of '{} {}'".format("show interfaces fec status", intf['interface']))
fec_status = duthost.show_and_parse("show interfaces fec status {}".format(intf['interface']))
fec = fec_status[0].get('fec oper', '').lower()
fec = get_fec_oper_mode(duthost, intf['interface'])
if fec == "n/a":
pytest.fail("FEC status is N/A for interface {}".format(intf['interface']))

Expand Down Expand Up @@ -84,16 +92,18 @@ def test_config_fec_oper_mode(duthosts, enum_rand_one_per_hwsku_frontend_hostnam
if presence == "not present" or oper != "up" or speed not in SUPPORTED_SPEEDS:
continue

config_status = duthost.command("sudo config interface fec {} rs"
.format(intf['interface']))
fec_mode = get_fec_oper_mode(duthost, intf['interface'])
if fec_mode == "n/a":
pytest.fail("FEC status is N/A for interface {}".format(intf['interface']))

config_status = duthost.command("sudo config interface fec {} {}"
.format(intf['interface'], fec_mode))
if config_status:
wait_until(30, 2, 0, duthost.is_interface_status_up, intf["interface"])
pytest_assert(wait_until(30, 2, 0, duthost.is_interface_status_up, intf["interface"]),
"Interface {} did not come up after configuring FEC mode".format(intf["interface"]))
# Verify the FEC operational mode is restored
logging.info("Get output of '{} {}'".format("show interfaces fec status", intf['interface']))
fec_status = duthost.show_and_parse("show interfaces fec status {}".format(intf['interface']))
fec = fec_status[0].get('fec oper', '').lower()

if not (fec == "rs"):
post_fec = get_fec_oper_mode(duthost, intf['interface'])
if not (post_fec == fec_mode):
pytest.fail("FEC status is not restored for interface {}".format(intf['interface']))


Expand Down

0 comments on commit 55575ba

Please sign in to comment.