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

refactor(anta.tests): Refactor VerifyISISSegmentRoutingTunnels test case #1037

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vitthalmagadum
Copy link
Collaborator

Description

Refactor VerifyISISSegmentRoutingTunnels test case

Fixes #388

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)

Copy link

codspeed-hq bot commented Feb 11, 2025

CodSpeed Performance Report

Merging #1037 will not alter performance

Comparing vitthalmagadum:issue_587_isis_sr_tunnel (5842f0c) with main (e587f3f)

Summary

✅ 22 untouched benchmarks

Copy link
Collaborator

@geetanjalimanegslab geetanjalimanegslab left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -122,3 +122,63 @@ def __init__(self, **data: Any) -> None: # noqa: ANN401
stacklevel=2,
)
super().__init__(**data)


class SRTunnelEntry(BaseModel):
Copy link
Contributor

Choose a reason for hiding this comment

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

We are already using Segment + TunnelPath so I think Tunnel makes sense.

Suggested change
class SRTunnelEntry(BaseModel):
class Tunnel(BaseModel):

Copy link
Contributor

Choose a reason for hiding this comment

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

You also need to add a ClassVar for the deprecated Vias model for backward compatibility.

endpoint: IPv4Network
"""Endpoint of the tunnel."""
vias: list[TunnelPath] | None = None
"""Optional list of path to reach endpoint."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""Optional list of path to reach endpoint."""
"""Optional list of paths to reach the endpoint."""

"""Optional list of path to reach endpoint."""

def __str__(self) -> str:
"""Return a human-readable string representation of the SRTunnelEntry for reporting."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""Return a human-readable string representation of the SRTunnelEntry for reporting."""
"""Return a human-readable string representation of the Tunnel for reporting."""

if self.interface:
base_string += f" Interface: {self.interface}"
if self.tunnel_id:
base_string += f" TunnelID: {self.tunnel_id}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
base_string += f" TunnelID: {self.tunnel_id}"
base_string += f" Tunnel ID: {self.tunnel_id}"

"""Computation method of the tunnel. If None, then it is not tested. Default: None"""

def _eos_entry_lookup(self, search_value: IPv4Network, entries: dict[str, Any], search_key: str = "endpoint") -> dict[str, Any] | None:
def _eos_entry_lookup(self, search_value: str, entries: dict[str, Any], search_key: str = "endpoint") -> dict[str, Any] | None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need that function? Can we use get_item from our tools module instead?

@@ -1922,7 +1922,7 @@
},
"expected": {
"result": "failure",
"messages": ["Tunnel to 1.0.0.13/32 is incorrect."],
"messages": ["Endpoint: 1.0.0.13/32 Type: tunnel - Tunnel is incorrect"],
Copy link
Contributor

Choose a reason for hiding this comment

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

What is incorrect here?

@@ -2010,7 +2010,7 @@
},
"expected": {
"result": "failure",
"messages": ["Tunnel to 1.0.0.122/32 is incorrect."],
"messages": ["Endpoint: 1.0.0.122/32 Next-hop: 10.0.1.2 Type: ip Interface: Ethernet1 - Tunnel is incorrect"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing here. The user doesn't know what is incorrect about the tunnel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Input subclasses refactoring
3 participants