|
| 1 | +import logging |
| 2 | +import pytest |
| 3 | + |
| 4 | +from tests.common.utilities import skip_release |
| 5 | + |
| 6 | +pytestmark = [ |
| 7 | + pytest.mark.disable_loganalyzer, # disable automatic loganalyzer |
| 8 | + pytest.mark.topology('any') |
| 9 | +] |
| 10 | + |
| 11 | +SUPPORTED_PLATFORMS = [ |
| 12 | + "mlnx_msn", |
| 13 | + "8101_32fh", |
| 14 | + "8111_32eh" |
| 15 | +] |
| 16 | + |
| 17 | +SUPPORTED_SPEEDS = [ |
| 18 | + "100G", "200G", "400G", "800G", "1600G" |
| 19 | +] |
| 20 | + |
| 21 | + |
| 22 | +def test_verify_fec_oper_mode(duthosts, enum_rand_one_per_hwsku_frontend_hostname, |
| 23 | + enum_frontend_asic_index, conn_graph_facts): |
| 24 | + """ |
| 25 | + @Summary: Verify the FEC operational mode is valid, for all the interfaces with |
| 26 | + SFP present, supported speeds and link is up using 'show interface status' |
| 27 | + """ |
| 28 | + duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] |
| 29 | + |
| 30 | + if any(platform in duthost.facts['platform'] for platform in SUPPORTED_PLATFORMS): |
| 31 | + # Not supported on 202305 and older releases |
| 32 | + skip_release(duthost, ["201811", "201911", "202012", "202205", "202211", "202305"]) |
| 33 | + else: |
| 34 | + pytest.skip("DUT has platform {}, test is not supported".format(duthost.facts['platform'])) |
| 35 | + |
| 36 | + logging.info("Get output of '{}'".format("show interface status")) |
| 37 | + intf_status = duthost.show_and_parse("show interface status") |
| 38 | + |
| 39 | + for intf in intf_status: |
| 40 | + sfp_presence = duthost.show_and_parse("sudo sfpshow presence -p {}" |
| 41 | + .format(intf['interface'])) |
| 42 | + if sfp_presence: |
| 43 | + presence = sfp_presence[0].get('presence', '').lower() |
| 44 | + oper = intf.get('oper', '').lower() |
| 45 | + speed = intf.get('speed', '') |
| 46 | + |
| 47 | + if presence == "present" and oper == "up" and speed in SUPPORTED_SPEEDS: |
| 48 | + # Verify the FEC operational mode is valid |
| 49 | + logging.info("Get output of '{} {}'".format("show interfaces fec status", intf['interface'])) |
| 50 | + fec_status = duthost.show_and_parse("show interfaces fec status {}".format(intf['interface'])) |
| 51 | + fec = fec_status[0].get('fec oper', '').lower() |
| 52 | + if fec == "n/a": |
| 53 | + pytest.fail("FEC status is N/A for interface {}".format(intf['interface'])) |
| 54 | + |
| 55 | + |
| 56 | +def test_config_fec_oper_mode(duthosts, enum_rand_one_per_hwsku_frontend_hostname, |
| 57 | + enum_frontend_asic_index, conn_graph_facts): |
| 58 | + """ |
| 59 | + @Summary: Configure the FEC operational mode for all the interfaces, then check |
| 60 | + FEC operational mode is retored to default FEC mode |
| 61 | + """ |
| 62 | + duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] |
| 63 | + |
| 64 | + if any(platform in duthost.facts['platform'] for platform in SUPPORTED_PLATFORMS): |
| 65 | + # Not supported on 202305 and older releases |
| 66 | + skip_release(duthost, ["201811", "201911", "202012", "202205", "202211", "202305"]) |
| 67 | + else: |
| 68 | + pytest.skip("DUT has platform {}, test is not supported".format(duthost.facts['platform'])) |
| 69 | + |
| 70 | + logging.info("Get output of '{}'".format("show interface status")) |
| 71 | + intf_status = duthost.show_and_parse("show interface status") |
| 72 | + |
| 73 | + for intf in intf_status: |
| 74 | + sfp_presence = duthost.show_and_parse("sudo sfpshow presence -p {}" |
| 75 | + .format(intf['interface'])) |
| 76 | + if sfp_presence: |
| 77 | + presence = sfp_presence[0].get('presence', '').lower() |
| 78 | + oper = intf.get('oper', '').lower() |
| 79 | + |
| 80 | + if presence == "not present" or oper != "up": |
| 81 | + continue |
| 82 | + |
| 83 | + config_status = duthost.command("sudo config interface fec {} rs" |
| 84 | + .format(intf['interface'])) |
| 85 | + if config_status: |
| 86 | + duthost.command("sleep 2") |
| 87 | + # Verify the FEC operational mode is restored |
| 88 | + logging.info("Get output of '{} {}'".format("show interfaces fec status", intf['interface'])) |
| 89 | + fec_status = duthost.show_and_parse("show interfaces fec status {}".format(intf['interface'])) |
| 90 | + fec = fec_status[0].get('fec oper', '').lower() |
| 91 | + |
| 92 | + if not (fec == "rs"): |
| 93 | + pytest.fail("FEC status is not restored for interface {}".format(intf['interface'])) |
0 commit comments