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 router path-selection paths #583

Merged
merged 11 commits into from
Apr 22, 2024

Conversation

MaheshGSLAB
Copy link
Collaborator

@MaheshGSLAB MaheshGSLAB commented Mar 14, 2024

Description

Added testcase to verify router path-selection paths.

VerifyRouterPathsHealth
"""
Verifies the route and telemetry state of all paths under router path-selection.
The expected states are 'IPsec established', 'Resolved' for route and 'active' for telemetry.

Expected Results
----------------
* Success: The test will pass if all paths under router path-selection have their route state as either 'IPsec established' or 'Resolved'
           and their telemetry state as 'active'.
* Failure: The test will fail if router path-selection is not configured, any path's route state is not 'IPsec established' or 'Resolved',
           or the telemetry state is 'inactive'.

"""

VerifySpecificRouterPath
"""
Verifies the route and telemetry state of a specific path for an IPv4 peer under router path-selection.
The expected states are 'IPsec established', 'Resolved' for route and 'active' for telemetry.

Expected Results
----------------
* Success: The test will pass if the path under router path-selection has its route state as either 'IPsec established' or 'Resolved'
           and telemetry state as 'active'.
* Failure: The test will fail if router path-selection is not configured, the path's route state is not 'IPsec established' or 'Resolved',
           or the telemetry state is 'inactive'.

"""

Fixes #577

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 marked this pull request as ready for review March 14, 2024 09:00
docs/api/tests.path_selection.md Outdated Show resolved Hide resolved
docs/api/tests.md Outdated Show resolved Hide resolved
mkdocs.yml Outdated Show resolved Hide resolved
anta/tests/path_selection.py Outdated Show resolved Hide resolved
@gmuloc gmuloc added this to the v1.0.0 milestone Apr 12, 2024
name = "VerifyRouterPathsHealth"
description = "Verifies the route and telemetry state of all paths under router path-selection."
categories: ClassVar[list[str]] = ["path-selection"]
commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show path-selection paths")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add revision for json

anta/tests/path_selection.py Outdated Show resolved Hide resolved
anta/tests/path_selection.py Outdated Show resolved Hide resolved
Comment on lines 64 to 66
# If the route state of any path is not 'ipsecEstablished' or 'routeResolved', the test fails
if route_state not in ["ipsecEstablished", "routeResolved"]:
self.result.is_failure(f"Route state for peer {peer} in group {group} is `{route_state}`.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

so here we could even imagine checking that if IPsec is enabled for the path-group for dynamic peers, we expect ipsecEstablished otherwise routeResolved. It would mean also retrieving the `show running-config path-seleciton

anta/tests/path_selection.py Show resolved Hide resolved

# If the telemetry state of any path is inactive, the test fails
elif not session:
self.result.is_failure(f"Telemetry state for peer {peer} in group {group} is `inactive`.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self.result.is_failure(f"Telemetry state for peer {peer} in group {group} is `inactive`.")
self.result.is_failure(f"Telemetry state for peer {peer} in path-group {group} is `inactive`.")


Expected Results
----------------
* Success: The test will pass if all paths under router path-selection have their route state as either 'IPsec established' or 'Resolved'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* Success: The test will pass if all paths under router path-selection have their route state as either 'IPsec established' or 'Resolved'
* Success: The test will pass if all path states under router path-selection are either 'IPsec established' or 'Resolved'

----------------
* Success: The test will pass if all paths under router path-selection have their route state as either 'IPsec established' or 'Resolved'
and their telemetry state as 'active'.
* Failure: The test will fail if router path-selection is not configured, any path's route state is not 'IPsec established' or 'Resolved',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing telemetry active check in the docstring (to be added) and reword like this:

Suggested change
* Failure: The test will fail if router path-selection is not configured, any path's route state is not 'IPsec established' or 'Resolved',
* Failure: The test will fail if router path-selection is not configured or if any path state is not 'IPsec established' or 'Resolved',

--------
```yaml
anta.tests.path_selection:
- VerifyRouterPathsHealth:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- VerifyRouterPathsHealth:
- VerifyPathsHealth:

self.result.is_failure(f"Telemetry state for peer {peer} in group {group} is `inactive`.")


class VerifySpecificRouterPath(AntaTest):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
class VerifySpecificRouterPath(AntaTest):
class VerifySpecificPath(AntaTest):

anta/tests/path_selection.py Show resolved Hide resolved
Copy link
Collaborator

@gmuloc gmuloc left a comment

Choose a reason for hiding this comment

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

Tested on a system :)

@gmuloc gmuloc merged commit a2f34a1 into aristanetworks:main Apr 22, 2024
17 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 support to validate router path-selections paths
3 participants