forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[counterpoll] add port buffer drop group (sonic-net#1009)
Signed-off-by: Mykola Faryma <mykolaf@mellanox.com> Co-authored-by: Danny Allen <daall@microsoft.com> Co-authored-by: Volodymyr Samotiy <volodymyrs@mellanox.com>
- Loading branch information
1 parent
62e44d9
commit 5c173f7
Showing
3 changed files
with
125 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import sys | ||
import os | ||
import time | ||
import pytest | ||
import click | ||
import swsssdk | ||
from click.testing import CliRunner | ||
|
||
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) | ||
|
||
import mock_tables.dbconnector | ||
import counterpoll.main as counterpoll | ||
|
||
expected_counterpoll_show = """Type Interval (in ms) Status | ||
-------------------- ------------------ -------- | ||
QUEUE_STAT 10000 enable | ||
PORT_STAT 1000 enable | ||
PORT_BUFFER_DROP 60000 enable | ||
QUEUE_WATERMARK_STAT 10000 enable | ||
PG_WATERMARK_STAT 10000 enable | ||
""" | ||
|
||
class TestCounterpoll(object): | ||
@classmethod | ||
def setup_class(cls): | ||
print("SETUP") | ||
os.environ["PATH"] += os.pathsep + scripts_path | ||
os.environ["UTILITIES_UNIT_TESTING"] = "1" | ||
|
||
def test_show(self): | ||
runner = CliRunner() | ||
result = runner.invoke(counterpoll.cli.commands["show"], []) | ||
print(result.output) | ||
assert result.output == expected_counterpoll_show | ||
|
||
def test_port_buffer_drop_interval(self): | ||
runner = CliRunner() | ||
result = runner.invoke(counterpoll.cli.commands["port-buffer-drop"].commands["interval"], ["30000"]) | ||
print(result.output) | ||
assert result.exit_code == 0 | ||
|
||
def test_port_buffer_drop_interval_too_short(self): | ||
runner = CliRunner() | ||
result = runner.invoke(counterpoll.cli.commands["port-buffer-drop"].commands["interval"], ["1000"]) | ||
print(result.output) | ||
expected = "Invalid value for 'POLL_INTERVAL': 1000 is not in the valid range of 30000 to 300000." | ||
assert result.exit_code == 2 | ||
assert expected in result.output | ||
|
||
@classmethod | ||
def teardown_class(cls): | ||
print("TEARDOWN") | ||
os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1]) | ||
os.environ["UTILITIES_UNIT_TESTING"] = "0" |
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