-
Notifications
You must be signed in to change notification settings - Fork 30
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
fix(anta.tests): VerifySpecificPath testcase with the latest changes #965
base: main
Are you sure you want to change the base?
fix(anta.tests): VerifySpecificPath testcase with the latest changes #965
Conversation
CodSpeed Performance ReportMerging #965 will not alter performanceComparing Summary
|
anta/tests/path_selection.py
Outdated
|
||
The expected states are 'IPsec established', 'Resolved' for path and 'active' for telemetry. | ||
This test performs the following checks for each specified router path: |
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.
This test performs the following checks for each specified router path: | |
This test performs the following checks for each specified DPS path: |
anta/tests/path_selection.py
Outdated
|
||
1. Verifies that the specified peer is configured. | ||
2. Verifies that the specified path group is found. | ||
3. Verifies that the expected source and destination address match the path group. |
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.
What do you mean?
anta/tests/path_selection.py
Outdated
|
||
# If the dpsPeers details are not found in the command output, the test fails. | ||
if not (dps_peers_details := get_value(command_output, "dpsPeers")): | ||
self.result.is_failure("Router path not configured") |
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("Router path not configured") | |
self.result.is_failure("Router path-selection not configured") |
anta/tests/path_selection.py
Outdated
self.result.is_failure("Router path not configured") | ||
return | ||
|
||
# Iterating on each router path mentioned in the inputs. |
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.
# Iterating on each router path mentioned in the inputs. | |
# Iterating on each DPS peer mentioned in the inputs. |
anta/tests/path_selection.py
Outdated
commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ | ||
AntaTemplate(template="show path-selection paths peer {peer} path-group {group} source {source} destination {destination}", revision=1) | ||
] | ||
commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show path-selection paths", revision=1)] | ||
|
||
class Input(AntaTest.Input): | ||
"""Input model for the VerifySpecificPath test.""" | ||
|
||
paths: list[RouterPath] |
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.
paths: list[RouterPath] | |
paths: list[DpsPath] |
anta/tests/path_selection.py
Outdated
path_data = next((path for path in path_group_details.values() if (path.get("source") == source and path.get("destination") == destination)), None) | ||
# If the expected and actual source and destination address of the path group are not matched, test fails. | ||
if not path_data: | ||
self.result.is_failure(f"{router_path} - Path 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(f"{router_path} - Path not found") | |
self.result.is_failure(f"{router_path} - No path matching the source and destination found.") |
anta/input_models/path_selection.py
Outdated
|
||
def __str__(self) -> str: | ||
"""Return a human-readable string representation of the RouterPath for reporting.""" | ||
return f"Peer: {self.peer} PathGroup: {self.path_group} Source: {self.source_address} Destination: {self.destination_address}" |
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.
return f"Peer: {self.peer} PathGroup: {self.path_group} Source: {self.source_address} Destination: {self.destination_address}" | |
return f"Peer: {self.peer}, PathGroup: {self.path_group}, Source: {self.source_address}, Destination: {self.destination_address}" |
anta/tests/path_selection.py
Outdated
|
||
path_state = path_data.get("state") | ||
session = get_value(path_data, "dpsSessions.0.active") | ||
expected_state = ["ipsecEstablished", "routeResolved"] |
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.
do you need this variable? why not just put it directly in line 153?
anta/tests/path_selection.py
Outdated
if path_state not in ["ipsecEstablished", "routeResolved"]: | ||
self.result.is_failure(f"Path state for `peer: {peer} source: {source} destination: {destination}` in path-group {path_group} is `{path_state}`.") | ||
if path_state not in expected_state: | ||
self.result.is_failure(f"{router_path} - State is not in ipsecEstablished, routeResolved - Actual: {path_state}") |
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(f"{router_path} - State is not in ipsecEstablished, routeResolved - Actual: {path_state}") | |
self.result.is_failure(f"{router_path} - State is not in ipsecEstablished, routeResolved. Actual: {path_state}") |
anta/tests/path_selection.py
Outdated
self.result.is_failure( | ||
f"Telemetry state for path `peer: {peer} source: {source} destination: {destination}` in path-group {path_group} is `inactive`." | ||
) | ||
self.result.is_failure(f"{router_path} - Telemetry state inactive") |
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(f"{router_path} - Telemetry state inactive") | |
self.result.is_failure(f"{router_path} - Telemetry state inactive for this path") |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
d15bc0b
to
85a60fa
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
79be309
to
d1351c3
Compare
anta/tests/path_selection.py
Outdated
|
||
Expected Results | ||
---------------- | ||
* Success: The test will pass if the path state under router path-selection is either 'IPsec established' or 'Resolved' | ||
* Success: The test will pass if the path state under router path selection is either 'IPsecEstablished' or 'Resolved' |
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.
* Success: The test will pass if the path state under router path selection is either 'IPsecEstablished' or 'Resolved' | |
* Success: The test will pass if the path state under router path-selection is either 'IPsecEstablished' or 'Resolved' |
anta/tests/path_selection.py
Outdated
and telemetry state as 'active'. | ||
* Failure: The test will fail if router path-selection is not configured or if the path state is not 'IPsec established' or 'Resolved', | ||
or if the telemetry state is 'inactive'. | ||
* Failure: The test will fail if router path selection is not configured, the path state is not 'IPsec established' or 'Resolved', |
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.
* Failure: The test will fail if router path selection is not configured, the path state is not 'IPsec established' or 'Resolved', | |
* Failure: The test will fail if router path selection or the peer is not configured or if the path state is not 'IPsec established' or 'Resolved', |
anta/tests/path_selection.py
Outdated
return [ | ||
template.render(peer=path.peer, group=path.path_group, source=path.source_address, destination=path.destination_address) for path in self.inputs.paths | ||
] | ||
DpsPath: ClassVar[type[DpsPath]] = DpsPath |
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.
DpsPath: ClassVar[type[DpsPath]] = DpsPath | |
RouterPath: ClassVar[type[DpsPath]] = DpsPath | |
"""To maintain backward compatibility.""" |
Quality Gate passedIssues Measures |
Description
Refactoring PathSelection (VerifySpecificPath) tests module to address the following issues:
Checklist:
pre-commit run
)tox -e testenv
)