Skip to content
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

[xcvrd] Add bitmap support for SFP error event #184

Merged
merged 11 commits into from
Jun 22, 2021

Conversation

Junchao-Mellanox
Copy link
Collaborator

Description

Support SFP error bitmap.

Motivation and Context

Currently, SONiC use a single value to represent SFP error, however, multiple SFP errors could exist at the same time. This PR is aimed to support it

How Has This Been Tested?

  1. New unit test case is added to cover the change
  2. Manual test

Additional Information (Optional)

@lgtm-com
Copy link

lgtm-com bot commented May 13, 2021

This pull request introduces 1 alert when merging 5ad1246 into 807b304 - view on LGTM.com

new alerts:

  • 1 for Unused import

Junchao Chen and others added 2 commits May 17, 2021 08:43
sonic-xcvrd/tests/test_xcvrd.py Outdated Show resolved Hide resolved
sonic-xcvrd/tests/test_xcvrd.py Show resolved Hide resolved
@Junchao-Mellanox Junchao-Mellanox requested a review from jleveque May 19, 2021 02:11
@Junchao-Mellanox Junchao-Mellanox marked this pull request as draft May 27, 2021 02:07
stephenxs and others added 3 commits June 4, 2021 08:40
In case there is an error returned by platform API
- Translate the error bitmap to error description for generic errors
- Fetch the error description from sfp_error dict or via calling platform API get_error_description for vendor specific errors
- Adjust unit test cases

Signed-off-by: Stephen Sun <[email protected]>
Signed-off-by: Stephen Sun <[email protected]>
Enhanced - Handle the error status returned by platform APIs
@Junchao-Mellanox Junchao-Mellanox marked this pull request as ready for review June 10, 2021 01:36
@jleveque
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@stephenxs
Copy link
Collaborator

In order to have this PR passed CI, we need to merge sonic-net/sonic-platform-common#194 and then advance the submodule head for it. It references some definitions like SFP_ERROR_DESCRIPTION_BLOCKING which are defined there.

2021-06-11T22:03:53.0398651Z =================================== FAILURES ===================================
2021-06-11T22:03:53.0399461Z _______________ TestXcvrdScript.test_detect_port_in_error_status _______________
2021-06-11T22:03:53.0399857Z 
2021-06-11T22:03:53.0400714Z self = <tests.test_xcvrd.TestXcvrdScript object at 0x7fc5961cea50>
2021-06-11T22:03:53.0401084Z 
2021-06-11T22:03:53.0401598Z     def test_detect_port_in_error_status(self):
2021-06-11T22:03:53.0402206Z         class MockTable:
2021-06-11T22:03:53.0402786Z             def get(self, key):
2021-06-11T22:03:53.0403305Z                 pass
2021-06-11T22:03:53.0403736Z     
2021-06-11T22:03:53.0404180Z         status_tbl = MockTable()
2021-06-11T22:03:53.0405776Z         status_tbl.get = MagicMock(return_value=(True, {'error': 'N/A'}))
2021-06-11T22:03:53.0406569Z >       assert not detect_port_in_error_status(None, status_tbl)
2021-06-11T22:03:53.0406913Z 
2021-06-11T22:03:53.0407370Z tests/test_xcvrd.py:326: 
2021-06-11T22:03:53.0408023Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2021-06-11T22:03:53.0408410Z 
2021-06-11T22:03:53.0408841Z logical_port_name = None
2021-06-11T22:03:53.0409434Z status_tbl = <tests.test_xcvrd.MockTable instance at 0x7fc596c0a320>
2021-06-11T22:03:53.0409817Z 
2021-06-11T22:03:53.0410397Z     def detect_port_in_error_status(logical_port_name, status_tbl):
2021-06-11T22:03:53.0411119Z         rec, fvp = status_tbl.get(logical_port_name)
2021-06-11T22:03:53.0411684Z         if rec:
2021-06-11T22:03:53.0412179Z             status_dict = dict(fvp)
2021-06-11T22:03:53.0413086Z             error = status_dict.get('error')
2021-06-11T22:03:53.0413762Z >           return SfpBase.SFP_ERROR_DESCRIPTION_BLOCKING in error
2021-06-11T22:03:53.0415015Z E           AttributeError: type object 'SfpBase' has no attribute 'SFP_ERROR_DESCRIPTION_BLOCKING'
2021-06-11T22:03:53.0415493Z 
2021-06-11T22:03:53.0416035Z xcvrd/xcvrd_utilities/sfp_status_helper.py:35: AttributeError
2021-06-11T22:03:53.0417208Z ---------- generated xml file: /__w/1/s/sonic-xcvrd/test-results.xml -----------
2021-06-11T22:03:53.0417626Z 
2021-06-11T22:03:53.0418544Z ---------- coverage: platform linux2, python 2.7.16-final-0 ----------
2021-06-11T22:03:53.0419294Z Name                                         Stmts   Miss  Cover
2021-06-11T22:03:53.0420322Z ----------------------------------------------------------------
2021-06-11T22:03:53.0421049Z xcvrd/__init__.py                                0      0   100%
2021-06-11T22:03:53.0421738Z xcvrd/xcvrd.py                                 824    566    31%
2021-06-11T22:03:53.0422892Z xcvrd/xcvrd_utilities/__init__.py                0      0   100%
2021-06-11T22:03:53.0423781Z xcvrd/xcvrd_utilities/sfp_status_helper.py      25      9    64%
2021-06-11T22:03:53.0424490Z xcvrd/xcvrd_utilities/y_cable_helper.py        650    584    10%
2021-06-11T22:03:53.0425562Z ----------------------------------------------------------------
2021-06-11T22:03:53.0426286Z TOTAL                                         1499   1159    23%
2021-06-11T22:03:53.0426906Z Coverage HTML written to dir htmlcov
2021-06-11T22:03:53.0427487Z Coverage XML written to file coverage.xml
2021-06-11T22:03:53.0427772Z 
2021-06-11T22:03:53.0428338Z ===================== 1 failed, 11 passed in 0.60 seconds ======================

@jleveque
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@stephenxs
Copy link
Collaborator

Submodule head of sonic-platform-common is advanced in sonic-net/sonic-buildimage#7868

@liat-grozovik
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@stephenxs
Copy link
Collaborator

@jleveque Can you trigger the test rerun as the dependent PR has been merged. Thanks

@jleveque
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liat-grozovik
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jleveque jleveque changed the title Add bitmap support for SFP error event [xcvrd] Add bitmap support for SFP error event Jun 22, 2021
@jleveque jleveque merged commit 53639de into sonic-net:master Jun 22, 2021
@lgtm-com
Copy link

lgtm-com bot commented Jun 22, 2021

This pull request introduces 1 alert when merging f7b5949 into 2fc05b2 - view on LGTM.com

new alerts:

  • 1 for Except block handles 'BaseException'

andywongarista pushed a commit to andywongarista/sonic-platform-daemons that referenced this pull request Jun 30, 2021
Support SFP error bitmap.

Currently, SONiC use a single value to represent SFP error, however, multiple SFP errors could exist at the same time. This PR is aimed to support it   

Signed-off-by: Stephen Sun <[email protected]>
@Junchao-Mellanox Junchao-Mellanox deleted the sfp-bit-map branch October 29, 2021 01:47
vdahiya12 pushed a commit to vdahiya12/sonic-platform-daemons that referenced this pull request Apr 4, 2022
…ties (sonic-net#184)

Added a `get_revision()` method to the generic platform device class which returns the hardware revision number of the device as a string.
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.

4 participants