-
Notifications
You must be signed in to change notification settings - Fork 25
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
feat(anta): Added the test case to verify SNMP error counters #836
base: main
Are you sure you want to change the base?
Conversation
anta/tests/snmp.py
Outdated
@@ -237,3 +249,73 @@ def test(self) -> None: | |||
self.result.is_failure(f"Expected `{self.inputs.contact}` as the contact, but found `{contact}` instead.") | |||
else: | |||
self.result.is_success() | |||
|
|||
|
|||
class VerifySNMPErrors(AntaTest): |
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.
class VerifySNMPErrors(AntaTest): | |
class VerifySnmpErrors(AntaTest): |
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.
Updated.
anta/tests/snmp.py
Outdated
|
||
error_counters: ( | ||
list[ | ||
Literal[ |
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.
since we already defined the error list then use the same here so me should not update it on multiple places
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.
Updated. Added model validator. Thanks!!
anta/tests/snmp.py
Outdated
|
||
# Verify SNMP PDU counters. | ||
if not (snmp_counters := get_value(command_output, "counters")): | ||
self.result.is_failure("SNMP counter details not found.") |
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.
self.result.is_failure("SNMP counter details not found.") | |
self.result.is_failure("SNMP counter details are not found.") |
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.
Updated
return | ||
|
||
# In case SNMP error counters not provided, It will check all the error counters. | ||
if not error_counters: |
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.
same as other PR, iterate on actual command output not on defined list
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.
We need to iterate only defined error counters as in actual output we have error counters and trapPDUs also.
tests/units/anta_tests/test_snmp.py
Outdated
"inputs": {}, | ||
"expected": { | ||
"result": "failure", | ||
"messages": ["The following SNMP error counter(s) are not found or have non-zero counter:\ninVersionErrs, inParseErrs, outBadValueErrs"], |
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.
make a dict of all failure error and value as error count or not found
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.
Added dict in failure.
4199e90
to
45bf6e8
Compare
Quality Gate passedIssues Measures |
CodSpeed Performance ReportMerging #836 will not alter performanceComparing Summary
|
Description
Verifies the number of SNMP error counter(s) processed.
Fixes #834
Checklist:
pre-commit run
)tox -e testenv
)