-
Notifications
You must be signed in to change notification settings - Fork 664
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
Fix multi-asic behaviour for dropstat #3059
Merged
wenyiz2021
merged 9 commits into
sonic-net:master
from
bktsim-arista:multi-asic-dropstat
Jul 24, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
954e31b
Fixes dropstat multi-asic behaviour by using multi-asic helpers
bktsim-arista 776fa9d
Change namespace arg processing per Wenyi request
rdjeric-arista b93a1bd
Linter fixes
rdjeric-arista 44c4aa0
Revert "Change namespace arg processing per Wenyi request"
rdjeric-arista a4344a3
Address review comments
kenneth-arista b963c4e
Support multi-asic clear command
kenneth-arista 8d2988c
Adding missing asic_db table for tests
kenneth-arista a2aadb0
Added clearing of userCache
kenneth-arista b2df7ae
Add UT for single ASIC
kenneth-arista 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 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 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import click | ||
import utilities_common.cli as clicommon | ||
import utilities_common.multi_asic as multi_asic_util | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add some test to cover the single asic as well? |
||
|
||
|
||
# | ||
|
@@ -41,7 +42,8 @@ def capabilities(verbose): | |
@click.option('-g', '--group', required=False) | ||
@click.option('-t', '--counter_type', required=False) | ||
@click.option('--verbose', is_flag=True, help="Enable verbose output") | ||
def counts(group, counter_type, verbose): | ||
@multi_asic_util.multi_asic_click_option_namespace | ||
def counts(group, counter_type, verbose, namespace): | ||
"""Show drop counts""" | ||
cmd = ['dropstat', '-c', 'show'] | ||
|
||
|
@@ -51,4 +53,7 @@ def counts(group, counter_type, verbose): | |
if counter_type: | ||
cmd += ['-t', str(counter_type)] | ||
|
||
if namespace: | ||
cmd += ['-n', str(namespace)] | ||
|
||
clicommon.run_command(cmd, display_cmd=verbose) |
This file contains 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,6 @@ | ||
{ | ||
"ASIC_STATE:SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000": { | ||
"SAI_SWITCH_ATTR_INIT_SWITCH": "true", | ||
"SAI_SWITCH_ATTR_SRC_MAC_ADDRESS": "DE:AD:BE:EF:CA:FE" | ||
} | ||
} |
This file contains 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,122 @@ | ||
import os | ||
import sys | ||
from .utils import get_result_and_return_code | ||
|
||
test_path = os.path.dirname(os.path.abspath(__file__)) | ||
modules_path = os.path.dirname(test_path) | ||
scripts_path = os.path.join(modules_path, "scripts") | ||
sys.path.insert(0, test_path) | ||
sys.path.insert(0, modules_path) | ||
|
||
dropstat_masic_result_asic0 = """\ | ||
IFACE STATE RX_ERR RX_DROPS TX_ERR TX_DROPS DEBUG_0 DEBUG_2 | ||
------------ ------- -------- ---------- -------- ---------- --------- --------- | ||
Ethernet0 U 10 100 0 0 80 20 | ||
Ethernet4 U 0 1000 0 0 800 100 | ||
Ethernet-BP0 U 0 1000 0 0 800 100 | ||
Ethernet-BP4 U 0 1000 0 0 800 100 | ||
|
||
DEVICE DEBUG_1 | ||
---------------- --------- | ||
sonic_drops_test 1000 | ||
""" | ||
|
||
dropstat_masic_result_asic1 = """\ | ||
IFACE STATE RX_ERR RX_DROPS TX_ERR TX_DROPS DEBUG_0 DEBUG_2 | ||
-------------- ------- -------- ---------- -------- ---------- --------- --------- | ||
Ethernet-BP256 U 10 100 0 0 80 20 | ||
Ethernet-BP260 U 0 1000 0 0 800 100 | ||
|
||
DEVICE DEBUG_1 | ||
---------------- --------- | ||
sonic_drops_test 1000 | ||
""" | ||
|
||
dropstat_masic_result_clear_all = """\ | ||
IFACE STATE RX_ERR RX_DROPS TX_ERR TX_DROPS DEBUG_0 DEBUG_2 | ||
------------ ------- -------- ---------- -------- ---------- --------- --------- | ||
Ethernet0 U 0 0 0 0 0 0 | ||
Ethernet4 U 0 0 0 0 0 0 | ||
Ethernet-BP0 U 0 0 0 0 0 0 | ||
Ethernet-BP4 U 0 0 0 0 0 0 | ||
|
||
DEVICE DEBUG_1 | ||
---------------- --------- | ||
sonic_drops_test 0 | ||
IFACE STATE RX_ERR RX_DROPS TX_ERR TX_DROPS DEBUG_0 DEBUG_2 | ||
-------------- ------- -------- ---------- -------- ---------- --------- --------- | ||
Ethernet-BP256 U 0 0 0 0 0 0 | ||
Ethernet-BP260 U 0 0 0 0 0 0 | ||
|
||
DEVICE DEBUG_1 | ||
---------------- --------- | ||
sonic_drops_test 0 | ||
""" | ||
|
||
|
||
class TestMultiAsicDropstat(object): | ||
@classmethod | ||
def setup_class(cls): | ||
os.environ["PATH"] += os.pathsep + scripts_path | ||
os.environ["UTILITIES_UNIT_TESTING"] = "1" | ||
os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "multi_asic" | ||
print("SETUP") | ||
|
||
def test_show_dropcount_masic_asic0(self): | ||
os.environ["UTILITIES_UNIT_TESTING_DROPSTAT_CLEAN_CACHE"] = "1" | ||
return_code, result = get_result_and_return_code([ | ||
'dropstat', '-c', 'show', '-n', 'asic0' | ||
]) | ||
os.environ.pop("UTILITIES_UNIT_TESTING_DROPSTAT_CLEAN_CACHE") | ||
print("return_code: {}".format(return_code)) | ||
print("result = {}".format(result)) | ||
assert result == dropstat_masic_result_asic0 and return_code == 0 | ||
|
||
def test_show_dropcount_masic_all_and_clear(self): | ||
os.environ["UTILITIES_UNIT_TESTING_DROPSTAT_CLEAN_CACHE"] = "1" | ||
return_code, result = get_result_and_return_code([ | ||
'dropstat', '-c', 'show' | ||
]) | ||
os.environ.pop("UTILITIES_UNIT_TESTING_DROPSTAT_CLEAN_CACHE") | ||
print("return_code: {}".format(return_code)) | ||
print("result = {}".format(result)) | ||
assert result == dropstat_masic_result_asic0 + dropstat_masic_result_asic1 | ||
assert return_code == 0 | ||
|
||
return_code, result = get_result_and_return_code([ | ||
'dropstat', '-c', 'clear' | ||
]) | ||
print("return_code: {}".format(return_code)) | ||
print("result = {}".format(result)) | ||
assert result == 'Cleared drop counters\n' and return_code == 0 | ||
|
||
return_code, result = get_result_and_return_code([ | ||
'dropstat', '-c', 'show' | ||
]) | ||
print("return_code: {}".format(return_code)) | ||
print("result = {}".format(result)) | ||
assert result == dropstat_masic_result_clear_all and return_code == 0 | ||
|
||
def test_show_dropcount_masic_invalid_ns(self): | ||
return_code, result = get_result_and_return_code([ | ||
'dropstat', '-c', 'show', '-n', 'asic5' | ||
]) | ||
print("return_code: {}".format(return_code)) | ||
print("result = {}".format(result)) | ||
assert return_code == 2 | ||
assert "invalid choice: asic5" in result | ||
|
||
def test_show_dropcount_version(self): | ||
return_code, result = get_result_and_return_code([ | ||
'dropstat', '--version' | ||
]) | ||
print("return_code: {}".format(return_code)) | ||
print("result = {}".format(result)) | ||
assert return_code == 0 | ||
|
||
@classmethod | ||
def teardown_class(cls): | ||
os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1]) | ||
os.environ.pop("UTILITIES_UNIT_TESTING") | ||
os.environ.pop("UTILITIES_UNIT_TESTING_TOPOLOGY") | ||
print("TEARDOWN") |
Oops, something went wrong.
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.
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 we need to add this change here?
dropstat
is standalone python script. the click options need to present inshow/dropcounter.py
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.
The original script also supported argument parsing. Using the
click
simplified that logic significantly. It was suggested earlier by Wenyi and I agree this is an improvement over what was originally implemented. Furthermore, the UTs directly call this script.