-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from alpeshspatel/alpeshspatel/util.msft.20220…
…5.mmuconfig What I did Extended the mmuconfig utility with a "-s / --staticth" keyword to configure the threshold configured via pg_profile_lookup.ini The utility had ability to configure "-a/alpha" for dynamic threshold
- Loading branch information
Showing
6 changed files
with
268 additions
and
15 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,112 @@ | ||
show_mmu_config = """\ | ||
Lossless traffic pattern: | ||
-------------------- - | ||
default_dynamic_th 0 | ||
over_subscribe_ratio 2 | ||
-------------------- - | ||
Pool: egress_lossless_pool | ||
---- -------- | ||
mode dynamic | ||
size 13945824 | ||
type egress | ||
---- -------- | ||
Pool: egress_lossy_pool | ||
---- ------- | ||
mode dynamic | ||
type egress | ||
---- ------- | ||
Pool: ingress_lossless_pool | ||
---- ------- | ||
mode dynamic | ||
type ingress | ||
---- ------- | ||
Pool: ingress_lossy_pool | ||
---- ------- | ||
mode dynamic | ||
type ingress | ||
---- ------- | ||
Pool: ingress_lossless_pool_hbm | ||
---- --------- | ||
mode static | ||
size 139458240 | ||
type ingress | ||
---- --------- | ||
Profile: ingress_lossy_profile | ||
---------- ------------------ | ||
dynamic_th 3 | ||
pool ingress_lossy_pool | ||
size 0 | ||
---------- ------------------ | ||
Profile: ingress_lossless_profile_hbm | ||
--------- ------------------------- | ||
static_th 12121212 | ||
pool ingress_lossless_pool_hbm | ||
size 0 | ||
--------- ------------------------- | ||
Profile: headroom_profile | ||
---------- --------------------- | ||
dynamic_th 0 | ||
pool ingress_lossless_pool | ||
xon 18432 | ||
xoff 32768 | ||
size 51200 | ||
---------- --------------------- | ||
Profile: alpha_profile | ||
------------- --------------------- | ||
dynamic_th 0 | ||
pool ingress_lossless_pool | ||
headroom_type dynamic | ||
------------- --------------------- | ||
Profile: egress_lossless_profile | ||
---------- -------------------- | ||
dynamic_th 0 | ||
pool egress_lossless_pool | ||
size 0 | ||
---------- -------------------- | ||
Profile: egress_lossy_profile | ||
---------- ----------------- | ||
dynamic_th 0 | ||
pool egress_lossy_pool | ||
size 0 | ||
---------- ----------------- | ||
""" | ||
|
||
testData = { | ||
'mmuconfig_list' : {'cmd' : ['show'], | ||
'args' : [], | ||
'rc' : 0, | ||
'rc_output': show_mmu_config | ||
}, | ||
'mmu_cfg_static_th' : {'cmd' : ['config'], | ||
'args' : ['-p', 'ingress_lossless_profile_hbm', '-s', '12121213'], | ||
'rc' : 0, | ||
'db_table' : 'BUFFER_PROFILE', | ||
'cmp_args' : ['ingress_lossless_profile_hbm,static_th,12121213'], | ||
'rc_msg' : '' | ||
}, | ||
'mmu_cfg_alpha' : {'cmd' : ['config'], | ||
'args' : ['-p', 'alpha_profile', '-a', '2'], | ||
'rc' : 0, | ||
'db_table' : 'BUFFER_PROFILE', | ||
'cmp_args' : ['alpha_profile,dynamic_th,2'], | ||
'rc_msg' : '' | ||
}, | ||
'mmu_cfg_alpha_invalid' : {'cmd' : ['config'], | ||
'args' : ['-p', 'alpha_profile', '-a', '12'], | ||
'rc' : 2, | ||
'rc_msg' : 'Usage: mmu [OPTIONS]\nTry "mmu --help" for help.\n\nError: Invalid value for "-a": 12 is not in the valid range of -8 to 8.\n' | ||
} | ||
|
||
} |
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,86 @@ | ||
import os | ||
import sys | ||
import json | ||
import pytest | ||
|
||
from click.testing import CliRunner | ||
import config.main as config | ||
import show.main as show | ||
from utilities_common.db import Db | ||
from .mmuconfig_input.mmuconfig_test_vectors import * | ||
|
||
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) | ||
|
||
|
||
class Testmmuconfig(object): | ||
@classmethod | ||
def setup_class(cls): | ||
os.environ["PATH"] += os.pathsep + scripts_path | ||
os.environ['UTILITIES_UNIT_TESTING'] = "2" | ||
print("SETUP") | ||
|
||
def test_mmu_show_config(self): | ||
self.executor(testData['mmuconfig_list']) | ||
|
||
def test_mmu_alpha_config(self): | ||
self.executor(testData['mmu_cfg_alpha']) | ||
|
||
def test_mmu_alpha_invalid_config(self): | ||
self.executor(testData['mmu_cfg_alpha_invalid']) | ||
|
||
def test_mmu_staticth_config(self): | ||
self.executor(testData['mmu_cfg_static_th']) | ||
|
||
def executor(self, input): | ||
runner = CliRunner() | ||
|
||
if 'db_table' in input: | ||
db = Db() | ||
data_list = list(db.cfgdb.get_table(input['db_table'])) | ||
input['rc_msg'] = input['rc_msg'].format(",".join(data_list)) | ||
|
||
if 'show' in input['cmd']: | ||
exec_cmd = show.cli.commands["mmu"] | ||
result = runner.invoke(exec_cmd, input['args']) | ||
exit_code = result.exit_code | ||
output = result.output | ||
elif 'config' in input['cmd']: | ||
exec_cmd = config.config.commands["mmu"] | ||
result = runner.invoke(exec_cmd, input['args'], catch_exceptions=False) | ||
exit_code = result.exit_code | ||
output = result.output | ||
|
||
print(exit_code) | ||
print(output) | ||
|
||
if input['rc'] == 0: | ||
assert exit_code == 0 | ||
else: | ||
assert exit_code != 0 | ||
|
||
if 'cmp_args' in input: | ||
fd = open('/tmp/mmuconfig', 'r') | ||
cmp_data = json.load(fd) | ||
for args in input['cmp_args']: | ||
profile, name, value = args.split(',') | ||
assert(cmp_data[profile][name] == value) | ||
fd.close() | ||
|
||
if 'rc_msg' in input: | ||
assert input['rc_msg'] in output | ||
|
||
if 'rc_output' in input: | ||
assert output == input['rc_output'] | ||
|
||
|
||
@classmethod | ||
def teardown_class(cls): | ||
os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1]) | ||
os.environ['UTILITIES_UNIT_TESTING'] = "0" | ||
if os.path.isfile('/tmp/mmuconfig'): | ||
os.remove('/tmp/mmuconfig') | ||
print("TEARDOWN") |
Oops, something went wrong.