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

feat(anta.tests): Added testcase to verify errordisable recovery reason #541

Merged
merged 2 commits into from
Feb 23, 2024

Conversation

MaheshGSLAB
Copy link
Collaborator

Description

Added testcase to verify errordisable recovery reason.

    Verifies the error-disable recovery reason, status, and interval.

    Expected Results:
        * Success: The test will pass if the error-disable recovery reason status is enabled and the interval matches the input.
        * Failure: The test will fail if the error-disable recovery reason is not found, the status is not enabled, or the interval does not match the input.

Fixes #538

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have run pre-commit for code linting and typing (pre-commit run)
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (tox -e testenv)

@MaheshGSLAB MaheshGSLAB changed the title feat(anta.tests):: Added testcase to verify errordisable recovery reason feat(anta.tests): Added testcase to verify errordisable recovery reason Jan 23, 2024
@MaheshGSLAB MaheshGSLAB marked this pull request as ready for review January 23, 2024 13:18
name = "VerifyErrdisableRecovery"
description = "Verifies the error-disable recovery reason, status, and interval."
categories = ["services"]
commands = [AntaCommand(command="show errdisable recovery", ofmt="text")]
Copy link
Collaborator

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"
    ]
}

Copy link
Collaborator Author

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

Comment on lines 62 to 72
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
Copy link
Collaborator

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

Suggested change
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

Copy link
Collaborator Author

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

Comment on lines 19 to 25
"""
Errdisable Reason Timer Status Timer Interval
------------------------------ ----------------- --------------
acl Enabled 300
arp-inspection Enabled 300
bgp-session-tracking Enabled 30
"""
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 100 to 101
"`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.",
Copy link
Collaborator

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)

Copy link
Collaborator Author

@MaheshGSLAB MaheshGSLAB Jan 25, 2024

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

Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

Copy link
Contributor

github-actions bot commented Feb 7, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Contributor

@carl-baillargeon carl-baillargeon left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@gmuloc gmuloc merged commit 447ee19 into aristanetworks:main Feb 23, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the testcase to verify Errdisable Recovery Interval
3 participants