-
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): Cleaning up ISIS tests module #963
Open
vitthalmagadum
wants to merge
6
commits into
aristanetworks:main
Choose a base branch
from
vitthalmagadum:fix/isis_input
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+225
−231
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5c49bab
Refactor isis module tests
vitthalmagadum 484a366
Updated unit tests
vitthalmagadum fa82cc7
Merge branch 'main' into fix/isis_input
vitthalmagadum b7aa146
Addressed review comments: updated input models, failure msgs
vitthalmagadum 04a0ad3
Merge branch 'main' into fix/isis_input
gmuloc 54f6742
Merge branch 'main' into fix/isis_input
gmuloc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# Copyright (c) 2023-2024 Arista Networks, Inc. | ||
# Use of this source code is governed by the Apache License 2.0 | ||
# that can be found in the LICENSE file. | ||
"""Module containing input models for routing ISIS tests.""" | ||
|
||
from __future__ import annotations | ||
|
||
from ipaddress import IPv4Address | ||
from typing import Any, Literal | ||
from warnings import warn | ||
|
||
from pydantic import BaseModel, ConfigDict | ||
|
||
from anta.custom_types import Interface | ||
|
||
|
||
class ISISInstance(BaseModel): | ||
"""Model for a ISIS instance.""" | ||
gmuloc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
model_config = ConfigDict(extra="forbid") | ||
name: str | ||
"""The name of the IS-IS instance.""" | ||
vrf: str = "default" | ||
"""VRF context where the IS-IS instance is configured. Defaults to `default`.""" | ||
dataplane: Literal["MPLS", "mpls", "unset"] = "MPLS" | ||
"""Configured dataplane for the IS-IS instance.""" | ||
gmuloc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
segments: list[Segment] | None = None | ||
"""A list of IS-IS segments associated with the instance. Required field in the `VerifyISISSegmentRoutingDataplane` test""" | ||
gmuloc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def __str__(self) -> str: | ||
"""Return a human-readable string representation of the ISISInstance for reporting.""" | ||
return f"Instance: {self.name} VRF: {self.vrf}" | ||
|
||
|
||
class Segment(BaseModel): | ||
"""Segment model definition.""" | ||
|
||
model_config = ConfigDict(extra="forbid") | ||
interface: Interface | ||
"""Interface name to check.""" | ||
level: Literal[1, 2] = 2 | ||
"""ISIS level configured for interface. Default is 2.""" | ||
sid_origin: Literal["dynamic"] = "dynamic" | ||
"Specifies the origin of the Segment ID." | ||
address: IPv4Address | ||
"""IP address of the remote end of the segment(segment endpoint).""" | ||
|
||
def __str__(self) -> str: | ||
"""Return a human-readable string representation of the Segment for reporting.""" | ||
return f"Interface: {self.interface} Endpoint: {self.address}" | ||
gmuloc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
class ISISInterface(BaseModel): | ||
"""Model for a ISIS Interface.""" | ||
gmuloc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
model_config = ConfigDict(extra="forbid") | ||
name: Interface | ||
"""Interface name to check.""" | ||
vrf: str = "default" | ||
"""VRF name where ISIS instance is configured.""" | ||
gmuloc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
level: Literal[1, 2] = 2 | ||
"""ISIS level (1 or 2) configured for the interface. Default is 2.""" | ||
count: int | None = None | ||
"""The total number of IS-IS neighbors associated with interface.""" | ||
mode: Literal["point-to-point", "broadcast", "passive"] | None = None | ||
"""The operational mode of the IS-IS interface.""" | ||
gmuloc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def __str__(self) -> str: | ||
"""Return a human-readable string representation of the ISISInterface for reporting.""" | ||
return f"Interface: {self.name} VRF: {self.vrf} Level: {self.level if self.level else 'IS Type(1-2)'}" | ||
|
||
|
||
class InterfaceCount(ISISInterface): # pragma: no cover | ||
"""Alias for the ISISInterface model to maintain backward compatibility. | ||
|
||
When initialized, it will emit a deprecation warning and call the ISISInterface model. | ||
|
||
TODO: Remove this class in ANTA v2.0.0. | ||
""" | ||
|
||
def __init__(self, **data: Any) -> None: # noqa: ANN401 | ||
"""Initialize the ISISInterface class, emitting a deprecation warning.""" | ||
warn( | ||
message="InterfaceCount model is deprecated and will be removed in ANTA v2.0.0. Use the ISISInterface model instead.", | ||
category=DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
super().__init__(**data) | ||
|
||
|
||
class InterfaceState(ISISInterface): # pragma: no cover | ||
"""Alias for the ISISInterface model to maintain backward compatibility. | ||
|
||
When initialized, it will emit a deprecation warning and call the ISISInterface model. | ||
|
||
TODO: Remove this class in ANTA v2.0.0. | ||
""" | ||
|
||
def __init__(self, **data: Any) -> None: # noqa: ANN401 | ||
"""Initialize the ISISInterface class, emitting a deprecation warning.""" | ||
warn( | ||
message="InterfaceState model is deprecated and will be removed in ANTA v2.0.0. Use the ISISInterface model instead.", | ||
category=DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
super().__init__(**data) | ||
|
||
|
||
class IsisInstance(ISISInstance): # pragma: no cover | ||
"""Alias for the ISISInstance model to maintain backward compatibility. | ||
|
||
When initialized, it will emit a deprecation warning and call the ISISInstance model. | ||
|
||
TODO: Remove this class in ANTA v2.0.0. | ||
""" | ||
|
||
def __init__(self, **data: Any) -> None: # noqa: ANN401 | ||
"""Initialize the ISISInstance class, emitting a deprecation warning.""" | ||
warn( | ||
message="IsisInstance model is deprecated and will be removed in ANTA v2.0.0. Use the ISISInstance model instead.", | ||
category=DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
super().__init__(**data) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.