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

fix(anta.tests): Updated testcase to support more address family #566

Merged

Conversation

MaheshGSLAB
Copy link
Collaborator

@MaheshGSLAB MaheshGSLAB commented Feb 29, 2024

Description

Updated VerifyBGPPeerCount, VerifyBGPPeersHealth and VerifyBGPSpecificPeers test to support more address families

Fixes #565

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 February 29, 2024 14:27
@@ -290,7 +290,7 @@ def validate_inputs(self: BaseModel) -> BaseModel:
"""
Validate the inputs provided to the BgpAfi class.

If afi is either ipv4 or ipv6, safi must be provided.
If afi is ipv4, ipv6 or sr-te, safi must be provided.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

missed to update, will update back in next commit

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes please update this. Also, can we add a note somewhere maybe in the docstring of the test class explaining the different syntax for sr-te?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

Comment on lines 330 to 333

# Swaping AFI and SAFI in case of SR-TE address family
if afi == "sr-te":
afi, safi = safi, afi
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should put that in the render function no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes we are doing this in render function too in the line (https://github.com/arista-netdevops-community/anta/pull/566/files#:~:text=%23%20For%20SR%2DTE,.vrf)))

Reason of here again to change is to get correct afi and safi in failure. If we dont swap then for SR-TE in failure we get afi as sr-te but expected is ipv4 and safi as sr-te.

Failures: [{'afi': 'sr-te', 'safi': 'ipv4', 'vrfs': {'default': {'10.255.0.2': {'peerState': 'Connect', 'inMsgQueue': 0, 'outMsgQueue': 0}}}}]

Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

Copy link
Collaborator

@carl-baillargeon carl-baillargeon left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@carl-baillargeon carl-baillargeon merged commit 965a111 into arista-netdevops-community:main Mar 19, 2024
19 checks passed
@@ -218,8 +220,12 @@ def render(self, template: AntaTemplate) -> list[AntaCommand]:
"""Render the template for each BGP address family in the input list."""
Copy link
Collaborator

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

@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we work to avoid the duplication of BgpAfi in every test?

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.

Refractor VerifyBGPSpecificPeers and VerifyBGPPeersHealth test to support more bgp address families
3 participants