-
Notifications
You must be signed in to change notification settings - Fork 28
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): Updated testcase to support more address family #566
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3b287f5
issue-565: Updated testcase tosupport more address family
MaheshGSLAB 1dec877
issue-565: updated the logic to support sr-te address family
MaheshGSLAB 2f5e0a7
issue-565: Updated the doc string for SR-TE address family
MaheshGSLAB d4b38a3
issue-565: fixed the class name
MaheshGSLAB 1afdebf
issue-565: rebased with latest
MaheshGSLAB 22d43f1
Update docstrings
carl-baillargeon 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
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 |
---|---|---|
|
@@ -152,7 +152,9 @@ def _add_bgp_routes_failure( | |
class VerifyBGPPeerCount(AntaTest): | ||
"""Verifies the count of BGP peers for a given address family. | ||
|
||
It supports multiple types of address families (AFI) and subsequent service families (SAFI). | ||
It supports multiple types of Address Families Identifiers (AFI) and Subsequent Address Family Identifiers (SAFI). | ||
|
||
For SR-TE SAFI, the EOS command supports sr-te first then ipv4/ipv6 (AFI) which is handled automatically in this test. | ||
|
||
Please refer to the Input class attributes below for details. | ||
|
||
|
@@ -176,7 +178,7 @@ class Input(AntaTest.Input): | |
"""List of BGP address families (BgpAfi).""" | ||
|
||
class BgpAfi(BaseModel): | ||
"""Model for a BGP address family (AFI) and subsequent service family (SAFI).""" | ||
"""Model for a BGP address family (AFI) and subsequent address family (SAFI).""" | ||
|
||
afi: Afi | ||
"""BGP address family (AFI).""" | ||
|
@@ -218,8 +220,12 @@ def render(self, template: AntaTemplate) -> list[AntaCommand]: | |
"""Render the template for each BGP address family in the input list.""" | ||
commands = [] | ||
for afi in self.inputs.address_families: | ||
if template == VerifyBGPPeerCount.commands[0] and afi.afi in ["ipv4", "ipv6"]: | ||
if template == VerifyBGPPeerCount.commands[0] and afi.afi in ["ipv4", "ipv6"] and afi.safi != "sr-te": | ||
commands.append(template.render(afi=afi.afi, safi=afi.safi, vrf=afi.vrf, num_peers=afi.num_peers)) | ||
|
||
# For SR-TE SAFI, the EOS command supports sr-te first then ipv4/ipv6 | ||
elif template == VerifyBGPPeerCount.commands[0] and afi.afi in ["ipv4", "ipv6"] and afi.safi == "sr-te": | ||
commands.append(template.render(afi=afi.safi, safi=afi.afi, vrf=afi.vrf, num_peers=afi.num_peers)) | ||
elif template == VerifyBGPPeerCount.commands[1] and afi.afi not in ["ipv4", "ipv6"]: | ||
commands.append(template.render(afi=afi.afi, vrf=afi.vrf, num_peers=afi.num_peers)) | ||
return commands | ||
|
@@ -240,6 +246,10 @@ def test(self) -> None: | |
afi_vrf = cast(str, command.params.get("vrf")) | ||
num_peers = cast(PositiveInt, command.params.get("num_peers")) | ||
|
||
# Swaping AFI and SAFI in case of SR-TE | ||
if afi == "sr-te": | ||
afi, safi = safi, afi | ||
|
||
if not (vrfs := command_output.get("vrfs")): | ||
_add_bgp_failures(failures=failures, afi=afi, safi=safi, vrf=afi_vrf, issue="Not Configured") | ||
continue | ||
|
@@ -262,7 +272,9 @@ class VerifyBGPPeersHealth(AntaTest): | |
|
||
It will validate that all BGP sessions are established and all message queues for these BGP sessions are empty for a given address family. | ||
|
||
It supports multiple types of address families (AFI) and subsequent service families (SAFI). | ||
It supports multiple types of Address Families Identifiers (AFI) and Subsequent Address Family Identifiers (SAFI). | ||
|
||
For SR-TE SAFI, the EOS command supports sr-te first then ipv4/ipv6 (AFI) which is handled automatically in this test. | ||
|
||
Please refer to the Input class attributes below for details. | ||
|
||
|
@@ -286,7 +298,7 @@ class Input(AntaTest.Input): | |
"""List of BGP address families (BgpAfi).""" | ||
|
||
class BgpAfi(BaseModel): | ||
"""Model for a BGP address family (AFI) and subsequent service family (SAFI).""" | ||
"""Model for a BGP address family (AFI) and subsequent address family (SAFI).""" | ||
|
||
afi: Afi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we work to avoid the duplication of BgpAfi in every test? |
||
"""BGP address family (AFI).""" | ||
|
@@ -326,8 +338,12 @@ def render(self, template: AntaTemplate) -> list[AntaCommand]: | |
"""Render the template for each BGP address family in the input list.""" | ||
commands = [] | ||
for afi in self.inputs.address_families: | ||
if template == VerifyBGPPeersHealth.commands[0] and afi.afi in ["ipv4", "ipv6"]: | ||
if template == VerifyBGPPeersHealth.commands[0] and afi.afi in ["ipv4", "ipv6"] and afi.safi != "sr-te": | ||
commands.append(template.render(afi=afi.afi, safi=afi.safi, vrf=afi.vrf)) | ||
|
||
# For SR-TE SAFI, the EOS command supports sr-te first then ipv4/ipv6 | ||
elif template == VerifyBGPPeersHealth.commands[0] and afi.afi in ["ipv4", "ipv6"] and afi.safi == "sr-te": | ||
commands.append(template.render(afi=afi.safi, safi=afi.afi, vrf=afi.vrf)) | ||
elif template == VerifyBGPPeersHealth.commands[1] and afi.afi not in ["ipv4", "ipv6"]: | ||
commands.append(template.render(afi=afi.afi, vrf=afi.vrf)) | ||
return commands | ||
|
@@ -344,6 +360,10 @@ def test(self) -> None: | |
|
||
afi = cast(Afi, command.params.get("afi")) | ||
safi = cast(Optional[Safi], command.params.get("safi")) | ||
|
||
# Swaping AFI and SAFI in case of SR-TE | ||
if afi == "sr-te": | ||
afi, safi = safi, afi | ||
afi_vrf = cast(str, command.params.get("vrf")) | ||
|
||
if not (vrfs := command_output.get("vrfs")): | ||
|
@@ -374,7 +394,9 @@ class VerifyBGPSpecificPeers(AntaTest): | |
|
||
It will validate that the BGP session is established and all message queues for this BGP session are empty for the given peer(s). | ||
|
||
It supports multiple types of address families (AFI) and subsequent service families (SAFI). | ||
It supports multiple types of Address Families Identifiers (AFI) and Subsequent Address Family Identifiers (SAFI). | ||
|
||
For SR-TE SAFI, the EOS command supports sr-te first then ipv4/ipv6 (AFI) which is handled automatically in this test. | ||
|
||
Please refer to the Input class attributes below for details. | ||
|
||
|
@@ -398,7 +420,7 @@ class Input(AntaTest.Input): | |
"""List of BGP address families (BgpAfi).""" | ||
|
||
class BgpAfi(BaseModel): | ||
"""Model for a BGP address family (AFI) and subsequent service family (SAFI).""" | ||
"""Model for a BGP address family (AFI) and subsequent address family (SAFI).""" | ||
|
||
afi: Afi | ||
"""BGP address family (AFI).""" | ||
|
@@ -444,9 +466,14 @@ def validate_inputs(self: BaseModel) -> BaseModel: | |
def render(self, template: AntaTemplate) -> list[AntaCommand]: | ||
"""Render the template for each BGP address family in the input list.""" | ||
commands = [] | ||
|
||
for afi in self.inputs.address_families: | ||
if template == VerifyBGPSpecificPeers.commands[0] and afi.afi in ["ipv4", "ipv6"]: | ||
if template == VerifyBGPSpecificPeers.commands[0] and afi.afi in ["ipv4", "ipv6"] and afi.safi != "sr-te": | ||
commands.append(template.render(afi=afi.afi, safi=afi.safi, vrf=afi.vrf, peers=afi.peers)) | ||
|
||
# For SR-TE SAFI, the EOS command supports sr-te first then ipv4/ipv6 | ||
elif template == VerifyBGPSpecificPeers.commands[0] and afi.afi in ["ipv4", "ipv6"] and afi.safi == "sr-te": | ||
commands.append(template.render(afi=afi.safi, safi=afi.afi, vrf=afi.vrf, peers=afi.peers)) | ||
elif template == VerifyBGPSpecificPeers.commands[1] and afi.afi not in ["ipv4", "ipv6"]: | ||
commands.append(template.render(afi=afi.afi, vrf=afi.vrf, peers=afi.peers)) | ||
return commands | ||
|
@@ -463,6 +490,10 @@ def test(self) -> None: | |
|
||
afi = cast(Afi, command.params.get("afi")) | ||
safi = cast(Optional[Safi], command.params.get("safi")) | ||
|
||
# Swaping AFI and SAFI in case of SR-TE | ||
if afi == "sr-te": | ||
afi, safi = safi, afi | ||
afi_vrf = cast(str, command.params.get("vrf")) | ||
afi_peers = cast(List[Union[IPv4Address, IPv6Address]], command.params.get("peers", [])) | ||
|
||
|
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.
maybe this is a docstring that deserves more info given the "dark magic" in the rendering function