Skip to content

[Mellanox] Add new cases for eeprom#6649

Merged
liat-grozovik merged 4 commits intosonic-net:masterfrom
JibinBao:add_new_eeprom_case
Nov 9, 2022
Merged

[Mellanox] Add new cases for eeprom#6649
liat-grozovik merged 4 commits intosonic-net:masterfrom
JibinBao:add_new_eeprom_case

Conversation

@JibinBao
Copy link
Contributor

@JibinBao JibinBao commented Oct 28, 2022

Description of PR

Summary:
Fixes # (issue)

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 201911
  • 202012
  • 202205

Approach

What is the motivation for this PR?

Check the outputs are correct for "show interface transceiver eeprom -d", "sudo sfputil show eeprom -d".

  1. Check if all expected keys exist in the outputs
  2. When cable support dom, check the corresponding keys related to monitor exist, and the the corresponding value has the correct format

How did you do it?

Add new tests

How did you verify/test it?

Run script of test_check_sfp_eeprom.py

Any platform specific information?

Yes. Mellanox

Supported testbed topology if it's a new test case?

Any

Documentation

@azure-pipelines
Copy link

The pre-commit check detected issues in the files touched by this pull request.
The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame
author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/platform_tests/mellanox/test_check_sfp_eeprom.py:1:1: F401 'logging' imported but unused
tests/platform_tests/mellanox/test_check_sfp_eeprom.py:3:1: F401 're' imported but unused
tests/platform_tests/mellanox/test_check_sfp_eeprom.py:5:1: F401 'random' imported but unused
tests/platform_tests/mellanox/test_check_sfp_eeprom.py:7:1: F401 'tests.common.fixtures.conn_graph_facts.conn_graph_facts' imported but unused
tests/platform_tests/mellanox/test_check_sfp_eeprom.py:19:64: F811 redefinition of unused 'conn_graph_facts' from line 7
tests/platform_tests/mellanox/test_check_sfp_eeprom.py:50:121: E501 line too long (140 > 120 characters)
tests/platform_tests/mellanox/util.py:4:49: W605 invalid escape sequence 'd'
tests/platform_tests/mellanox/util.py:8:39: W605 invalid escape sequence '.'
tests/platform_tests/mellanox/util.py:20:121: E501 line too long (133 > 120 characters)
tests/platform_tests/mellanox/util.py:82:121: E501 line too long (138 > 120 characters)
tests/platform_tests/mellanox/util.py:187:121: E501 line too long (136 > 120 characters)
...
[truncated extra lines, please run pre-commit locally to view full check results]

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@JibinBao JibinBao changed the title Mellanox]Add new cases for eepromAdd new cases for eeprom [Mellanox]Add new cases for eepromAdd new cases for eeprom Oct 28, 2022
@azure-pipelines
Copy link

The pre-commit check detected issues in the files touched by this pull request.
The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame
author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/platform_tests/mellanox/test_check_sfp_eeprom.py:4:1: F401 'tests.common.fixtures.conn_graph_facts.conn_graph_facts' imported but unused
tests/platform_tests/mellanox/test_check_sfp_eeprom.py:16:64: F811 redefinition of unused 'conn_graph_facts' from line 4
tests/platform_tests/mellanox/util.py:204:121: E501 line too long (122 > 120 characters)
tests/platform_tests/mellanox/util.py:230:42: W605 invalid escape sequence '.'
tests/platform_tests/mellanox/util.py:231:41: W605 invalid escape sequence '.'
tests/platform_tests/mellanox/util.py:232:41: W605 invalid escape sequence '.'
tests/platform_tests/mellanox/util.py:233:40: W605 invalid escape sequence '.'

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@JibinBao JibinBao force-pushed the add_new_eeprom_case branch from 1002f19 to 04caa11 Compare October 28, 2022 09:33
@azure-pipelines
Copy link

The pre-commit check detected issues in the files touched by this pull request.
The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame
author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/platform_tests/mellanox/test_check_sfp_eeprom.py:4:1: F401 'tests.common.fixtures.conn_graph_facts.conn_graph_facts' imported but unused
tests/platform_tests/mellanox/test_check_sfp_eeprom.py:16:64: F811 redefinition of unused 'conn_graph_facts' from line 4

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@JibinBao
Copy link
Contributor Author

JibinBao commented Oct 28, 2022

The pre-commit check detected issues in the files touched by this pull request. The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results: trim trailing whitespace.................................................Passedfix end of files.........................................................Passedcheck yaml...........................................(no files to check)Skippedcheck for added large files..............................................Passedcheck python ast.........................................................Passedflake8...................................................................Failed- hook id: flake8- exit code: 1tests/platform_tests/mellanox/test_check_sfp_eeprom.py:4:1: F401 'tests.common.fixtures.conn_graph_facts.conn_graph_facts' imported but unusedtests/platform_tests/mellanox/test_check_sfp_eeprom.py:16:64: F811 redefinition of unused 'conn_graph_facts' from line 4

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

For this pre-commit issue, I am not sure how to resolve it. Maybe the pep8 check rule need to do some modification? Because conn_graph_facts is a fixture Actually it has been used by test case.

@liat-grozovik liat-grozovik changed the title [Mellanox]Add new cases for eepromAdd new cases for eeprom [Mellanox] Add new cases for eeprom Oct 30, 2022
@JibinBao
Copy link
Contributor Author

@nhe-NV

@liat-grozovik
Copy link
Collaborator

@Junchao-Mellanox could you please help to review?

second_layer_dict = {}
previous_key = ""
top_key = ""
for line in sfp_eeprom_info.split("\n"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we parse those SFP which has no EEPROM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. for this case, case will raise failure

key, dom_monitor_data[key], pattern)


def is_support_dom(duthost, port_index):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is better to use ethtool -m sfp{index}. Part of the data of "show interface transceiver eeprom -d" comes from sfp.get_transceiver_bulk_status. So, using sfp.get_transceiver_bulk_status to test "show interface transceiver eeprom -d" may not find real issues.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe can use mlxlink/ethtool to check whether relevant fields are valid.

return sfp_eeprom_info_dict


def check_sfp_eeprom_info(duthost, sfp_eeprom_info, is_support_dom, show_eeprom_cmd):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please consider using compare the output of show eeprom command with ethtool/mlxlink output?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for a specific field, the output from ethtool/mlxlink could have some differences with the SONiC CLI output, no easy way to directly compare of them. only the Vendor OUI, Vendor Name, Vendor SN.. are the same and can be compared directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will use mlxlink tool to check if it supports dom.

"""
bulk_status_str = get_transceiver_bulk_status(duthost, port_index)
bulk_status_str = bulk_status_str.replace('-inf', '\'-inf\'')
bulk_status_dict = eval(bulk_status_str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest use literal_eval instead of eval

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@Junchao-Mellanox
Copy link
Contributor

Junchao-Mellanox commented Nov 4, 2022

I am not sure about the scope of this PR. A few general comments:

  1. "show interface transceiver eeprom" does not cover everything, will you consider verify the value in STATE DB?
  2. Will you consider platform API level verification? Like sfp.get_transceiver_info, sfp.get_transceiver_dom_threshold...
  3. Will you add case to verify EEPROM writing? For example, Y cable.

@JibinBao
Copy link
Contributor Author

JibinBao commented Nov 4, 2022

I am not sure about the scope of this PR. A few general comments:

  1. "show interface transceiver eeprom" does not cover everything, will you consider verify the value in STATE DB?
  2. Will you consider platform API level verification? Like sfp.get_transceiver_info, sfp.get_transceiver_dom_threshold...
  3. Will you add case to verify EEPROM writing? For example, Y cable.

As what we discussed at the beginning, the PR doesn't include these scopes, we just check the two cmds' outputs. If needed, we can add one task to add them.

@wangxin
Copy link
Collaborator

wangxin commented Nov 7, 2022

This PR added 2 new files, can you ensure that the new files can pass the pre-commit check? Thanks! @JibinBao

@JibinBao
Copy link
Contributor Author

JibinBao commented Nov 7, 2022

This PR added 2 new files, can you ensure that the new files can pass the pre-commit check? Thanks! @JibinBao

Sure. There is only one issue in which fixture is used, but pep8 checks it is not imported. I will update it.

@azure-pipelines
Copy link

The pre-commit check detected issues in the files touched by this pull request.
The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame
author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing tests/platform_tests/mellanox/util.py

check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/platform_tests/mellanox/test_check_sfp_eeprom.py:16:64: F811 redefinition of unused 'conn_graph_facts' from line 4

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@JibinBao JibinBao force-pushed the add_new_eeprom_case branch from ee2c8e6 to 32e9aa9 Compare November 7, 2022 10:06
@azure-pipelines
Copy link

The pre-commit check detected issues in the files touched by this pull request.
The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame
author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing tests/platform_tests/mellanox/util.py

check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/platform_tests/mellanox/test_check_sfp_eeprom.py:16:64: F811 redefinition of unused 'conn_graph_facts' from line 4

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@JibinBao JibinBao force-pushed the add_new_eeprom_case branch from 32e9aa9 to 78cb479 Compare November 7, 2022 10:24
@azure-pipelines
Copy link

The pre-commit check detected issues in the files touched by this pull request.
The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame
author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing tests/platform_tests/mellanox/util.py

check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Passed

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

…er_bulk_status for branches apart from 202012
@JibinBao JibinBao force-pushed the add_new_eeprom_case branch from 78cb479 to 95661bf Compare November 7, 2022 10:32
@azure-pipelines
Copy link

The pre-commit check detected issues in the files touched by this pull request.
The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame
author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing tests/platform_tests/mellanox/test_check_sfp_eeprom.py
Fixing tests/platform_tests/mellanox/util.py

check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Passed

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@JibinBao
Copy link
Contributor Author

JibinBao commented Nov 9, 2022

/azpw run Azure.sonic-mgmt

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-mgmt

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liat-grozovik liat-grozovik merged commit 49a1417 into sonic-net:master Nov 9, 2022
wangxin pushed a commit that referenced this pull request Nov 11, 2022
- What is the motivation for this PR?
Check the outputs are correct for "show interface transceiver eeprom -d", "sudo sfputil show eeprom -d".

Check if all expected keys exist in the outputs
When cable support dom, check the corresponding keys related to monitor exist, and the the corresponding value has the correct format

-  How did you do it?
Add new tests

- How did you verify/test it?
Run script of test_check_sfp_eeprom.py

- Any platform specific information?
Yes. Mellanox

- Supported testbed topology if it's a new test case?
Any
wangxin pushed a commit that referenced this pull request Nov 11, 2022
- What is the motivation for this PR?
Check the outputs are correct for "show interface transceiver eeprom -d", "sudo sfputil show eeprom -d".

Check if all expected keys exist in the outputs
When cable support dom, check the corresponding keys related to monitor exist, and the the corresponding value has the correct format

-  How did you do it?
Add new tests

- How did you verify/test it?
Run script of test_check_sfp_eeprom.py

- Any platform specific information?
Yes. Mellanox

- Supported testbed topology if it's a new test case?
Any
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants