Skip to content

Commit

Permalink
[pbh]: Add UTs.
Browse files Browse the repository at this point in the history
Signed-off-by: Nazarii Hnydyn <[email protected]>
  • Loading branch information
nazariig committed Jun 27, 2024
1 parent c4b6ebd commit af60a63
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/pbh_input/assert_show_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@
"""


show_pbh_statistics_partial = """\
TABLE RULE RX PACKETS COUNT RX BYTES COUNT
---------- ------ ------------------ ----------------
pbh_table1 nvgre 100 200
pbh_table2 vxlan 0 0
"""


show_pbh_statistics_updated="""\
TABLE RULE RX PACKETS COUNT RX BYTES COUNT
---------- ------ ------------------ ----------------
Expand Down
11 changes: 11 additions & 0 deletions tests/pbh_input/counters_db_partial.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"COUNTERS:oid:0x9000000000000": { },
"COUNTERS:oid:0x9000000000001": {
"SAI_ACL_COUNTER_ATTR_PACKETS": "300",
"SAI_ACL_COUNTER_ATTR_BYTES": "400"
},
"ACL_COUNTER_RULE_MAP": {
"pbh_table1:nvgre": "oid:0x9000000000000",
"pbh_table2:vxlan": "oid:0x9000000000001"
}
}
28 changes: 28 additions & 0 deletions tests/pbh_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,34 @@ def test_show_pbh_statistics_after_clear(self):
assert result.exit_code == SUCCESS
assert result.output == assert_show_output.show_pbh_statistics_zero

def test_show_pbh_statistics_after_clear_and_counters_partial(self):
dbconnector.dedicated_dbs['COUNTERS_DB'] = os.path.join(mock_db_path, 'counters_db_partial')
dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'full_pbh_config')

self.remove_pbh_counters_file()

db = Db()
runner = CliRunner()

result = runner.invoke(
clear.cli.commands["pbh"].
commands["statistics"], [], obj=db
)

logger.debug("\n" + result.output)
logger.debug(result.exit_code)

dbconnector.dedicated_dbs['COUNTERS_DB'] = os.path.join(mock_db_path, 'counters_db')

result = runner.invoke(
show.cli.commands["pbh"].
commands["statistics"], [], obj=db
)

logger.debug("\n" + result.output)
logger.debug(result.exit_code)
assert result.exit_code == SUCCESS
assert result.output == assert_show_output.show_pbh_statistics_partial

def test_show_pbh_statistics_after_clear_and_counters_updated(self):
dbconnector.dedicated_dbs['COUNTERS_DB'] = os.path.join(mock_db_path, 'counters_db')
Expand Down

0 comments on commit af60a63

Please sign in to comment.