Skip to content
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

aclshow unittest #468

Merged
merged 1 commit into from
Mar 13, 2019
Merged

Conversation

romankachur-mlnx
Copy link
Contributor

Signed-off-by: Roman Kachur romankac@mellanox.com

- What I did
I created a unittest for the aclshow utility
- How I did it
Exploiting mock_tables, I added mock Rules, Databases, and occasional Counters.
Unittest calls aclshow with different arguments, and compares its output with the predefined outputs.
In total 10 cases were covered:

  • aclshow
  • aclshow -a
  • aclshow -r RULE_1 -t DATAACL
  • aclshow -r RULE_0 -a
  • aclshow -r RULE_0
  • aclshow -r RULE_6,RULE_4 -vv
  • aclshow -t EVERFLOW
  • aclshow -t DATAACL
  • aclshow -c
  • aclshow -c ; aclshow -a

- How to verify it
python2 -m py.test aclshow_test.py -v
- Previous command output (if the output of a command-line utility has changed)
N/A
- New command output (if the output of a command-line utility has changed)

collected 10 items

aclshow_test.py::test_default PASSED
aclshow_test.py::test_all PASSED
aclshow_test.py::test_rule1_dataacl PASSED
aclshow_test.py::test_rule05_all PASSED
aclshow_test.py::test_rule0 PASSED
aclshow_test.py::test_rule4_rule6_verbose PASSED
aclshow_test.py::test_everflow PASSED
aclshow_test.py::test_dataacl PASSED
aclshow_test.py::test_clear PASSED
aclshow_test.py::test_all_after_clear PASSED

-->

import mock_tables.dbconnector

default_output = ''+ \
"""RULE NAME TABLE NAME PACKETS COUNT BYTES COUNT
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add line breakup and have the table header aligned with the data? this applies to all the below table

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line breakup makes assertion to fail, as it compares strings.

default_output = ''+ \
"""RULE NAME TABLE NAME PACKETS COUNT BYTES COUNT
------------ ------------ --------------- -------------
RULE_9 DATAACL 901 900
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain how the tool sort the table? it does not seems to be according to the rule name and not sure if the current behavior is the expected one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sorts by table name, then by counters.


import mock_tables.dbconnector

default_output = ''+ \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a description of the command used and the parameters to invoke this output. it will help so see the big picture

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added description to the expected outputs, ant to each test case.

if self.nullify_on_exit:
self.nullify_counters()
sys.stdout = self.old_stdout
#print self.result.getvalue() # Print output for debugging.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove unused code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

assert test.result.getvalue() == rule4_rule6_verbose_output

def test_everflow():
test = Aclshow(all=None, clear=None, rules=None, tables='EVERFLOW', verbose=None)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if mirroring was configured, were we suppose to see the data? if so, i think we should have dedicated case for it as well. i see below the table configured but are we missing additional configuration to see the info?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added two rules to be in Everflow.

Signed-off-by: Roman Kachur <romankac@mellanox.com>
@romankachur-mlnx
Copy link
Contributor Author

romankachur-mlnx commented Mar 1, 2019

Added PRIO column to the command output.

vstest will fail until aclshow is merged
#476

@liat-grozovik liat-grozovik merged commit f9d6df2 into sonic-net:master Mar 13, 2019
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 18, 2022
Include below commits

sonic-swss-common
```
83d3351 2021-04-22 | [swig] fix ConfigDBConnector.db_name (sonic-net#483) [Qi Luo]
fdf296f 2021-04-09 | Fix: ConfigDBConnector call super init with proper parameter name (sonic-net#470) [Qi Luo]
4f580e3 2021-03-26 | [swig] translate SonicV2Connector::keys return type from C++ vector<string> to Python list (sonic-net#468) [Qi Luo]
```

sonic-snmpagent
```
c160c2b 2021-08-04 | CPU Spike because of redundant and flooded keyspace notifis handled (sonic-net#230) [Vivek Reddy]
a4dd3bf 2021-08-03 | Non-block reading counters to tolerate corrupted/delayed counters in COUNTERS_DB (sonic-net#231) [Qi Luo]
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants