forked from sonic-net/sonic-mgmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sonic-mgmt: Add FEC check test case. (sonic-net#12397)
* Add test_intf_fec.py * Add more supported platforms and fix the indentation * Add more information on Cisco platforms * Fix a trailing whitespace * Address review comment. Add a check for speed and sfp presence as well. * Add config FEC test * Use "show interfaces fec status" command to retrieve FEC operational mode
- Loading branch information
Showing
1 changed file
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import logging | ||
import pytest | ||
|
||
from tests.common.utilities import skip_release | ||
|
||
pytestmark = [ | ||
pytest.mark.disable_loganalyzer, # disable automatic loganalyzer | ||
pytest.mark.topology('any') | ||
] | ||
|
||
SUPPORTED_PLATFORMS = [ | ||
"mlnx_msn", | ||
"8101_32fh", | ||
"8111_32eh" | ||
] | ||
|
||
SUPPORTED_SPEEDS = [ | ||
"100G", "200G", "400G", "800G", "1600G" | ||
] | ||
|
||
|
||
def test_verify_fec_oper_mode(duthosts, enum_rand_one_per_hwsku_frontend_hostname, | ||
enum_frontend_asic_index, conn_graph_facts): | ||
""" | ||
@Summary: Verify the FEC operational mode is valid, for all the interfaces with | ||
SFP present, supported speeds and link is up using 'show interface status' | ||
""" | ||
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] | ||
|
||
if any(platform in duthost.facts['platform'] for platform in SUPPORTED_PLATFORMS): | ||
# Not supported on 202305 and older releases | ||
skip_release(duthost, ["201811", "201911", "202012", "202205", "202211", "202305"]) | ||
else: | ||
pytest.skip("DUT has platform {}, test is not supported".format(duthost.facts['platform'])) | ||
|
||
logging.info("Get output of '{}'".format("show interface status")) | ||
intf_status = duthost.show_and_parse("show interface status") | ||
|
||
for intf in intf_status: | ||
sfp_presence = duthost.show_and_parse("sudo sfpshow presence -p {}" | ||
.format(intf['interface'])) | ||
if sfp_presence: | ||
presence = sfp_presence[0].get('presence', '').lower() | ||
oper = intf.get('oper', '').lower() | ||
speed = intf.get('speed', '') | ||
|
||
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() | ||
if fec == "n/a": | ||
pytest.fail("FEC status is N/A for interface {}".format(intf['interface'])) | ||
|
||
|
||
def test_config_fec_oper_mode(duthosts, enum_rand_one_per_hwsku_frontend_hostname, | ||
enum_frontend_asic_index, conn_graph_facts): | ||
""" | ||
@Summary: Configure the FEC operational mode for all the interfaces, then check | ||
FEC operational mode is retored to default FEC mode | ||
""" | ||
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] | ||
|
||
if any(platform in duthost.facts['platform'] for platform in SUPPORTED_PLATFORMS): | ||
# Not supported on 202305 and older releases | ||
skip_release(duthost, ["201811", "201911", "202012", "202205", "202211", "202305"]) | ||
else: | ||
pytest.skip("DUT has platform {}, test is not supported".format(duthost.facts['platform'])) | ||
|
||
logging.info("Get output of '{}'".format("show interface status")) | ||
intf_status = duthost.show_and_parse("show interface status") | ||
|
||
for intf in intf_status: | ||
sfp_presence = duthost.show_and_parse("sudo sfpshow presence -p {}" | ||
.format(intf['interface'])) | ||
if sfp_presence: | ||
presence = sfp_presence[0].get('presence', '').lower() | ||
oper = intf.get('oper', '').lower() | ||
|
||
if presence == "not present" or oper != "up": | ||
continue | ||
|
||
config_status = duthost.command("sudo config interface fec {} rs" | ||
.format(intf['interface'])) | ||
if config_status: | ||
duthost.command("sleep 2") | ||
# 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"): | ||
pytest.fail("FEC status is not restored for interface {}".format(intf['interface'])) |