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
Make PFC commands use a class #3057
base: master
Are you sure you want to change the base?
Conversation
001c9c9
to
3f80da0
Compare
/azpw run Azure.sonic-utilities |
/azpw run |
/azpw run Azure.sonic-utilities |
/azp run Azure.sonic-utilities |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@@ -1,160 +1,182 @@ | |||
#!/usr/bin/env python3 | |||
|
|||
import os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please sort imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
class TestPfc(TestPfcBase): | ||
@classmethod | ||
def setup_class(cls): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
teardown needs to be called for TestPfc to set the UTILITIES_UNIT_TESTING
to zero
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
teardown_class
is defined in the base class TestPfcBase
, it should inherit that method.
PFC handler to display asymmetric PFC information. | ||
""" | ||
header = ('Interface', 'Asymmetric') | ||
if "UTILITIES_UNIT_TESTING" in os.environ and os.environ["UTILITIES_UNIT_TESTING"] == "2": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do need this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need it, it looks like it was just to make writing the test easier but we can just as easily call the config command followed by the show command in the test.
tests/pfc_test.py
Outdated
|
||
def test_pfc_config_priority(self): | ||
self.executor(pfc.cli, ['config', 'priority', 'on', 'Ethernet0', '5'], | ||
expected_output=pfc_config_priority_on) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add test for showPfcPrio ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there already is one for showPfcPrio
see test_pfc_show_priority_all
, test_pfc_show_priority_intf
and test_pfc_show_asymmetric_intf_fake
This change puts contents originally in pfc/main.py into a class, to support the usage of the multi-asic helper in a future change. This change is required, as multi-asic helper relies on certain members of the class to exist. The multi-asic class helper will be used to add multi-asic support to pfc commands.
3f80da0
to
49590ab
Compare
expected_output=pfc_config_asymmetric) | ||
|
||
def test_pfc_config_priority(self): | ||
self.executor(pfc.cli, ['config', 'priority', 'on', 'Ethernet0', '5'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bktsim-arista Can we add "show pfc counter" test as well ? Also, Could we test this change on pizza box as well as chassis ?
What I did
This change puts contents originally in pfc/main.py into a class, to support the usage of the multi-asic helper in a future change. This change is required, as multi-asic helper being used expects members
self.config_db
andself.db
to exist when a function with the decoratorrun_on_multi_asic
is called. The multi-asic class helper will be used to add multi-asic support to pfc commands in a following pull request.This is a part of the set of changes being pushed for sonic-net/sonic-buildimage#15148
How I did it
Moved contents of PFC commands into a class. There are no functional changes.