-
Notifications
You must be signed in to change notification settings - Fork 1k
Converting legacy platform tests for a T2 chassis, adding validation of values to tests, and refactor test_sfp into smaller tests #2965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
870916e
Converting legacy platform tests for a T2 chassis and adding validati…
sanmalho-git bd2bd63
Fixing lgtm warnings.
sanmalho-git 5c55487
Incorporating review comments
sanmalho-git c546432
Added sfpshow command validation to test_sfp.py
sanmalho-git 3197fa4
Refactoring test_sfp platform test multiple smaller tests per module
sanmalho-git 3ec552e
Changes to use str.format syntax as per review comments
sanmalho-git b722eb6
Changes to use str.format
sanmalho-git 24fd7b3
Fixed lgtm alert
sanmalho-git File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
This file contains hidden or 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,26 @@ | ||
| import pytest | ||
| import logging | ||
| import os | ||
| from tests.common.plugins.loganalyzer.loganalyzer import LogAnalyzer | ||
|
|
||
| ans_host = None | ||
|
|
||
|
|
||
| def teardown_module(): | ||
| logging.info("remove script to retrieve port mapping") | ||
| file_path = os.path.join('/usr/share/sonic/device', ans_host.facts['platform'], 'plugins/getportmap.py') | ||
| ans_host.file(path=file_path, state='absent') | ||
|
|
||
|
|
||
| @pytest.fixture(autouse=True) | ||
| def disable_analyzer_for_mellanox(duthost): | ||
| if duthost.facts["asic_type"] in ["mellanox"]: | ||
| loganalyzer = LogAnalyzer(ansible_host=duthost, marker_prefix='sfp_cfg') | ||
| loganalyzer.load_common_config() | ||
|
|
||
| loganalyzer.ignore_regex.append("kernel.*Eeprom query failed*") | ||
| marker = loganalyzer.init() | ||
| yield | ||
|
|
||
| if duthost.facts["asic_type"] in ["mellanox"]: | ||
| loganalyzer.analyze(marker) |
This file contains hidden or 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,56 @@ | ||
| """ | ||
| Check SFP status using sfpshow. | ||
|
|
||
| This script covers test case 'Check SFP status and configure SFP' in the SONiC platform test plan: | ||
| https://github.com/Azure/SONiC/blob/master/doc/pmon/sonic_platform_test_plan.md | ||
| """ | ||
|
|
||
| import logging | ||
| import pytest | ||
|
|
||
| from util import parse_eeprom | ||
| from util import parse_output | ||
| from util import get_dev_conn | ||
|
|
||
| cmd_sfp_presence = "sudo sfpshow presence" | ||
| cmd_sfp_eeprom = "sudo sfpshow eeprom" | ||
|
|
||
|
|
||
| pytestmark = [ | ||
| pytest.mark.disable_loganalyzer, # disable automatic loganalyzer | ||
| pytest.mark.topology('any') | ||
| ] | ||
|
|
||
|
|
||
| def test_check_sfp_presence(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_frontend_asic_index, conn_graph_facts): | ||
| """ | ||
| @summary: Check SFP presence using 'sfputil show presence' | ||
| """ | ||
| duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] | ||
| global ans_host | ||
| ans_host = duthost | ||
| portmap, dev_conn = get_dev_conn(duthost, conn_graph_facts, enum_frontend_asic_index) | ||
|
|
||
| logging.info("Check output of '%s'" % cmd_sfp_presence) | ||
| sfp_presence = duthost.command(cmd_sfp_presence) | ||
| parsed_presence = parse_output(sfp_presence["stdout_lines"][2:]) | ||
| for intf in dev_conn: | ||
| assert intf in parsed_presence, "Interface is not in output of '%s'" % cmd_sfp_presence | ||
|
sanmalho-git marked this conversation as resolved.
Outdated
|
||
| assert parsed_presence[intf] == "Present", "Interface presence is not 'Present'" | ||
|
|
||
|
|
||
| def test_check_sfpshow_eeprom(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_frontend_asic_index, conn_graph_facts): | ||
| """ | ||
| @summary: Check SFP presence using 'sfputil show presence' | ||
| """ | ||
| duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] | ||
| global ans_host | ||
| ans_host = duthost | ||
| portmap, dev_conn = get_dev_conn(duthost, conn_graph_facts, enum_frontend_asic_index) | ||
|
|
||
| logging.info("Check output of '%s'" % cmd_sfp_eeprom) | ||
|
sanmalho-git marked this conversation as resolved.
Outdated
|
||
| sfp_eeprom = duthost.command(cmd_sfp_eeprom) | ||
| parsed_eeprom = parse_eeprom(sfp_eeprom["stdout_lines"]) | ||
| for intf in dev_conn: | ||
| assert intf in parsed_eeprom, "Interface is not in output of 'sfputil show eeprom'" | ||
| assert parsed_eeprom[intf] == "SFP EEPROM detected" | ||
This file contains hidden or 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
This file contains hidden or 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,55 @@ | ||
| """ | ||
| Check SFP status using 'show interface transciever'. | ||
|
|
||
| This script covers test case 'Check SFP status and configure SFP' in the SONiC platform test plan: | ||
| https://github.com/Azure/SONiC/blob/master/doc/pmon/sonic_platform_test_plan.md | ||
| """ | ||
|
|
||
| import logging | ||
| import pytest | ||
|
|
||
| from util import parse_eeprom | ||
| from util import parse_output | ||
| from util import get_dev_conn | ||
|
|
||
| cmd_sfp_presence = "show interface transceiver presence" | ||
| cmd_sfp_eeprom = "show interface transceiver eeprom" | ||
|
|
||
| pytestmark = [ | ||
| pytest.mark.disable_loganalyzer, # disable automatic loganalyzer | ||
| pytest.mark.topology('any') | ||
| ] | ||
|
|
||
|
|
||
| def test_check_sfp_presence(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_frontend_asic_index, conn_graph_facts): | ||
| """ | ||
| @summary: Check SFP presence using 'sfputil show presence' | ||
| """ | ||
| duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] | ||
| global ans_host | ||
| ans_host = duthost | ||
| portmap, dev_conn = get_dev_conn(duthost, conn_graph_facts, enum_frontend_asic_index) | ||
|
|
||
| logging.info("Check output of '%s'" % cmd_sfp_presence) | ||
|
sanmalho-git marked this conversation as resolved.
Outdated
|
||
| sfp_presence = duthost.command(cmd_sfp_presence) | ||
| parsed_presence = parse_output(sfp_presence["stdout_lines"][2:]) | ||
| for intf in dev_conn: | ||
| assert intf in parsed_presence, "Interface is not in output of '%s'" % cmd_sfp_presence | ||
|
sanmalho-git marked this conversation as resolved.
Outdated
|
||
| assert parsed_presence[intf] == "Present", "Interface presence is not 'Present'" | ||
|
|
||
|
|
||
| def test_check_sfpshow_eeprom(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_frontend_asic_index, conn_graph_facts): | ||
| """ | ||
| @summary: Check SFP presence using 'sfputil show presence' | ||
| """ | ||
| duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] | ||
| global ans_host | ||
| ans_host = duthost | ||
| portmap, dev_conn = get_dev_conn(duthost, conn_graph_facts, enum_frontend_asic_index) | ||
|
|
||
| logging.info("Check output of '%s'" % cmd_sfp_eeprom) | ||
|
sanmalho-git marked this conversation as resolved.
Outdated
|
||
| sfp_eeprom = duthost.command(cmd_sfp_eeprom) | ||
| parsed_eeprom = parse_eeprom(sfp_eeprom["stdout_lines"]) | ||
| for intf in dev_conn: | ||
| assert intf in parsed_eeprom, "Interface is not in output of 'sfputil show eeprom'" | ||
| assert parsed_eeprom[intf] == "SFP EEPROM detected" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.