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

[202012] Refactor Pcied and add unittest #199

Merged
merged 4 commits into from
Jul 25, 2021

Conversation

sujinmkang
Copy link
Collaborator

Description
Refactor the pcied and add the unit test

Motivation and Context
Added unit test to increase the pmon unit test coverage.

How Has This Been Tested?
Build with unit test enabled and run manually on a dut to verify the pcied.

Additional Information (Optional)

@lgtm-com
Copy link

lgtm-com bot commented Jul 7, 2021

This pull request introduces 1 alert when merging cde1d42 into 507cdf7 - view on LGTM.com

new alerts:

  • 1 for Implicit string concatenation in a list

@qiluo-msft qiluo-msft changed the title Cherry pick of https://github.com/Azure/sonic-platform-daemons/pull/189 [202012] Refactor Pcied and add unittest Jul 8, 2021
@qiluo-msft
Copy link
Contributor

Could you fix PR checkers?

@liat-grozovik
Copy link
Collaborator

@sujinmkang please note that without this PR we have a degradation in 202012.
Appreciate if you can give this prio as some of the work was already taken to 202012 while this cannot yet be merged.

@qiluo-msft
Copy link
Contributor

I rebased your commits and force pushed. Still there is PR checker failure.

daemon_pcied.check_n_update_pcie_aer_stats(0,1,0)
assert daemon_pcied.update_aer_to_statedb.call_count == 0
assert daemon_pcied.device_table.set.call_count == 0
assert platform_pcieutil.get_pcie_aer_stats.call_count == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Test is failing due to "NameError: global name 'platform_pcieutil' is not defined"
I belive you meant to write:

Suggested change
assert platform_pcieutil.get_pcie_aer_stats.call_count == 0
assert pcied.platform_pcieutil.get_pcie_aer_stats.call_count == 0

daemon_pcied.check_n_update_pcie_aer_stats(0,1,0)
assert daemon_pcied.update_aer_to_statedb.call_count == 1
assert daemon_pcied.device_table.set.call_count == 1
assert platform_pcieutil.get_pcie_aer_stats.call_count == 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here:

Suggested change
assert platform_pcieutil.get_pcie_aer_stats.call_count == 1
assert pcied.platform_pcieutil.get_pcie_aer_stats.call_count == 1

from sonic_platform.pcie import Pcie
_platform_pcieutil = Pcie(platform_path)
except ImportError as e:
self.log_error("Failed to load platform Pcie module. Error : {}".format(str(e)), True)
Copy link
Contributor

Choose a reason for hiding this comment

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

This caused in master for pcied to enter FATAL state (sonic-net/sonic-buildimage#7993)
This probably need the same fix as in master.
I also think this line shouldn't be an error level, since this is not an error flow, this is part of the normal loading flow we expect when a vendor didn't supply a Pcie class.

Suggested change
self.log_error("Failed to load platform Pcie module. Error : {}".format(str(e)), True)
log.log_notice("Failed to load platform Pcie module. Error : {}, Fallback to default module".format(str(e)), True)

from sonic_platform_base.sonic_pcie.pcie_common import PcieUtil
_platform_pcieutil = PcieUtil(platform_path)
except ImportError as e:
self.log_error("Failed to load default PcieUtil module. Error : {}".format(str(e)), True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.log_error("Failed to load default PcieUtil module. Error : {}".format(str(e)), True)
log.log_error("Failed to load default PcieUtil module. Error : {}".format(str(e)), True)

import sys
import threading

from sonic_py_common import daemon_base, device_info
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is needed for the fixes on line 48 & 53 to run

Suggested change
from sonic_py_common import daemon_base, device_info
from sonic_py_common import daemon_base, device_info, logger

@liat-grozovik
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liat-grozovik
Copy link
Collaborator

@sujinmkang please note than the you will need to have the submodule of 202012 back to buildimage before this can get in as there was recently a revert.

@liat-grozovik
Copy link
Collaborator

@DavidZagury if you have no further comments, can you please approve this PR?
@sujinmkang may you please merge this to 202012 and update the submodule pointers to make platform tests passing?

@liat-grozovik liat-grozovik requested a review from qiluo-msft July 25, 2021 08:50
@lguohan lguohan merged commit c90bb29 into sonic-net:202012 Jul 25, 2021
qiluo-msft pushed a commit to sonic-net/sonic-buildimage that referenced this pull request Jul 27, 2021
…ns (#8262)

sonic-platform-daemons:
* c90bb29 [202012] Refactor Pcied and add unittest (sonic-net/sonic-platform-daemons#199)

sonic-platform-common:
* 9a59e19 Revert "Unifying the platform api for get_pcie_aer_stats with PcieBase (sonic-net/sonic-platform-common#197)" (sonic-net/sonic-platform-common#207)
* d35960b Revert "Revert "Unifying the platform api for get_pcie_aer_stats with PcieBase (sonic-net/sonic-platform-common#197)" (sonic-net/sonic-platform-common#207)" (sonic-net/sonic-platform-common#210)
vdahiya12 pushed a commit to vdahiya12/sonic-platform-daemons that referenced this pull request Apr 4, 2022
#### Description
Following error is seen while parsing EEPROM fields for few transceivers.
'utf-8' codec can't decode byte 0xff in position 6: invalid start byte

#### Motivation and Context
EEPROM fields will not be displayed  if unicode characters are not properly.
E.g. Vendor Date: 20'u-tf--8'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants