-
Notifications
You must be signed in to change notification settings - Fork 31
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.tests): Added testcase to verify errordisable recovery reason #541
Conversation
anta/tests/services.py
Outdated
name = "VerifyErrdisableRecovery" | ||
description = "Verifies the error-disable recovery reason, status, and interval." | ||
categories = ["services"] | ||
commands = [AntaCommand(command="show errdisable recovery", ofmt="text")] |
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.
dont you have a json output for this?
EDIT:
4.31
ceos1(config)#show errdisable recovery | json
{
"errors": [
"This is an unconverted command"
]
}
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.
Yes command not support json output. I was about to add a note in doc string that command does not support json output but missed it. Will add it
anta/tests/services.py
Outdated
if line.strip(): | ||
# Split by first two whitespaces | ||
reason, status, interval = line.split(None, 2) | ||
if reason == input_reason: | ||
reason_found = True | ||
actual_reason_data = {"interval": interval, "status": status} | ||
expected_reason_data = {"interval": str(input_interval), "status": "Enabled"} | ||
if actual_reason_data != expected_reason_data: | ||
failed_log = get_failed_logs(expected_reason_data, actual_reason_data) | ||
self.result.is_failure(f"`{input_reason}`:{failed_log}") | ||
break |
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.
try always to avoid deeply nested if/else/for
if line.strip(): | |
# Split by first two whitespaces | |
reason, status, interval = line.split(None, 2) | |
if reason == input_reason: | |
reason_found = True | |
actual_reason_data = {"interval": interval, "status": status} | |
expected_reason_data = {"interval": str(input_interval), "status": "Enabled"} | |
if actual_reason_data != expected_reason_data: | |
failed_log = get_failed_logs(expected_reason_data, actual_reason_data) | |
self.result.is_failure(f"`{input_reason}`:{failed_log}") | |
break | |
if not line.strip(): | |
continue | |
# Split by first two whitespaces | |
reason, status, interval = line.split(None, 2) | |
if reason != input_reason: | |
continue | |
reason_found = True | |
actual_reason_data = {"interval": interval, "status": status} | |
expected_reason_data = {"interval": str(input_interval), "status": "Enabled"} | |
if actual_reason_data != expected_reason_data: | |
failed_log = get_failed_logs(expected_reason_data, actual_reason_data) | |
self.result.is_failure(f"`{input_reason}`:{failed_log}") | |
break |
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.
fixed, thanks for the suggestion
""" | ||
Errdisable Reason Timer Status Timer Interval | ||
------------------------------ ----------------- -------------- | ||
acl Enabled 300 | ||
arp-inspection Enabled 300 | ||
bgp-session-tracking Enabled 30 | ||
""" |
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.
Hmmm looks not really well formatted
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.
fixed
"`acl`:\nExpected `30` as the interval, but found `300` instead.\nExpected `Enabled` as the status, but found `Disabled` instead.", | ||
"`bgp-session-tracking`:\nExpected `300` as the interval, but found `30` instead.", |
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.
Not sure if the \n
makes sens in these error messages, especially whnen it is not in all of them (mlagasu)
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 can remove the last \n of each element
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
d36cdb6
to
15319d8
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
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.
LGTM
Conflicts have been resolved. A maintainer will review the pull request shortly. |
Description
Added testcase to verify errordisable recovery reason.
Fixes #538
Checklist:
pre-commit run
)tox -e testenv
)