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

feat(anta.tests): Adding the test case to verify BGP timers #510

Merged
merged 2 commits into from
Feb 14, 2024

Conversation

MaheshGSLAB
Copy link
Contributor

@MaheshGSLAB MaheshGSLAB commented Jan 3, 2024

Description

Adding the test case to verify BGP timers

Fixes #509

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 self-assigned this Jan 3, 2024
@MaheshGSLAB MaheshGSLAB changed the title feat: Adding the test case to verify BGP timers feat(anta.tests)!: Adding the test case to verify BGP timers Jan 4, 2024
@MaheshGSLAB MaheshGSLAB marked this pull request as ready for review January 4, 2024 11:09
@gmuloc gmuloc changed the title feat(anta.tests)!: Adding the test case to verify BGP timers feat(anta.tests): Adding the test case to verify BGP timers Jan 5, 2024
keep_alive_time = bgp_peer.keep_alive_time

# Verify BGP peer
if not (bgp_output := get_value(self.instance_commands[0].json_output, f"vrfs..{vrf}..peerList", separator="..")):
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to use separator=".." here?


# Verify BGP peer
if not (bgp_output := get_value(self.instance_commands[0].json_output, f"vrfs..{vrf}..peerList", separator="..")):
failures[str(peer_address)] = {vrf: "Not configured"}
Copy link
Contributor

Choose a reason for hiding this comment

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

peer_address is already a str no?

name = "VerifyBGPTimers"
description = "Verifies if the BGP peers are configured with the correct hold and keep alive timers in the specified VRF."
categories = ["routing", "bgp"]
commands = [AntaCommand(command="show bgp neighbors")]
Copy link
Contributor

Choose a reason for hiding this comment

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

show bgp neighbors will give you the neighbors of the default VRF only. You should use show bgp neighbors vrf all or use AntaTemplate and show bgp neighbors vrf {vrf}.

failures[str(peer_address)] = {vrf: "Not configured"}
continue

bgp_index = create_index(bgp_output, "peerAddress")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check if the get_item function in AVD does what you want? If so, let's copy the code in anta.tools so we can use it.

bgp_index = create_index(bgp_output, "peerAddress")
bgp_output = bgp_index.get(peer_address)
if not bgp_output:
failures[str(peer_address)] = {vrf: "Not configured"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need a second statement here if there peer is not configured?

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
Contributor

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

Copy link
Contributor

@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 after restricting int inputs.

"""IPv4 address of a BGP peer"""
vrf: str = "default"
"""Optional VRF for BGP peer. If not provided, it defaults to `default`."""
hold_time: int
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
hold_time: int
hold_time: int = Field(ge=3, le=7200)

"""Optional VRF for BGP peer. If not provided, it defaults to `default`."""
hold_time: int
"""BGP hold time in seconds"""
keep_alive_time: int
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
keep_alive_time: int
keep_alive_time: int = Field(ge=0, le=3600)

Copy link
Contributor

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

@titom73 titom73 self-requested a review February 7, 2024 14:38
@titom73 titom73 added state: conflict validated PR validated, waiting for conflict resolution or PR merge party and removed one-more-review labels Feb 7, 2024
Copy link
Contributor

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

@carl-baillargeon carl-baillargeon merged commit b67f186 into aristanetworks:main Feb 14, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rn: feat(anta.tests) validated PR validated, waiting for conflict resolution or PR merge party
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the test case to verify the BGP hold and keep alive timers
4 participants