-
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
feat(anta): Added the test case to verify BGP NLRI prefixes #792
base: main
Are you sure you want to change the base?
Conversation
anta/tests/routing/bgp.py
Outdated
* Success: The test will pass if the `nlrisReceived` equals `nlrisAccepted`, indicating that all received NLRIs were accepted.. | ||
* Failure: The test will fail if the `nlrisReceived` is not equal to `nlrisAccepted`, indicating that some NLRIs were rejected or filtered out. |
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.
* Success: The test will pass if the `nlrisReceived` equals `nlrisAccepted`, indicating that all received NLRIs were accepted.. | |
* Failure: The test will fail if the `nlrisReceived` is not equal to `nlrisAccepted`, indicating that some NLRIs were rejected or filtered out. | |
* Success: The test will pass if the `NLRI Rcd` equals `NLRI Acc`, indicating that all received NLRIs were accepted. | |
* Failure: The test will fail if the `NLRI Rcd` is not equal to `NLRI Acc`, indicating that some NLRIs were rejected or filtered out. |
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.
Updated.
anta/tests/routing/bgp.py
Outdated
continue | ||
|
||
# Verifies the NLRIs received is equal to accepted. | ||
if (nlri_rec := get_value(peer_details, "ipv4Unicast.nlrisReceived")) != (nlri_acc := get_value(peer_details, "ipv4Unicast.nlrisAccepted")): |
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.
The ipv4Unicast is not static we can have different AFI.
wan1-dc1(config-router-bgp)#show bgp summary
BGP summary information for VRF default
Router identifier 10.100.254.1, local AS number 65000
Neighbor AS Session State AFI/SAFI AFI/SAFI State NLRI Rcd NLRI Acc
---------- ----------- ------------- ----------------------- -------------- ---------- ----------
10.255.0.1 65000 Established IPv4 SR-TE Negotiated 8 8
10.255.0.1 65000 Established IPv4 Dps Negotiated 9 9
10.255.0.1 65000 Established L2VPN EVPN Negotiated 52 52
10.255.0.1 65000 Established Link State Link State Negotiated 0 0
10.255.0.2 65000 Established IPv4 SR-TE Negotiated 8 8
10.255.0.2 65000 Established IPv4 Dps Negotiated 9 9
10.255.0.2 65000 Established L2VPN EVPN Negotiated 52 52
10.255.0.2 65000 Established Link State Link State Negotiated 0 0
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.
Added support for AFI and SAFI
anta/tests/routing/bgp.py
Outdated
# Verifies the NLRIs received is equal to accepted. | ||
if (nlri_rec := get_value(peer_details, "ipv4Unicast.nlrisReceived")) != (nlri_acc := get_value(peer_details, "ipv4Unicast.nlrisAccepted")): | ||
failures[peer_address] = { | ||
vrf: f"The NLRIs received and accepted should be consistent, but found NLRI received `{nlri_rec}` and NLRI accepted `{nlri_acc}` instead." |
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.
As testcase description is clear what the test is so having The NLRIs received and accepted should be consistent, but found
line for each peer is not ok as you are already mentioning it in self.result.is_failure
So just NLRI received {nlri_rec}
and NLRI accepted {nlri_acc}
is enough or {"NLRI received" "{nlri_rec}
, "NLRI accepted": {nlri_acc}
}
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.
Updated.
f50d10e
to
1b98a8b
Compare
anta/tests/routing/bgp.py
Outdated
|
||
Expected Results | ||
---------------- | ||
* Success: The test will pass if the `prefixReceived` equals `prefixAccepted`, indicating that all received prefix(s) were accepted. |
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.
prefixReceived and prefixAccepted seems to be json keys, please use text heading of command output in doc string and failure message to for ease of understanding
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.
Updated
anta/tests/routing/bgp.py
Outdated
command_output = command.json_output | ||
afi = command.params.afi | ||
safi = command.params.safi if hasattr(command.params, "safi") else None | ||
afi_vrf = command.params.vrf if hasattr(command.params, "vrf") else "default" |
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.
default
is the default vrf then i dont think we need any condition to parse the vrf. Same for safi
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.
Updated
bgp: | ||
- VerifyBGPPeerPrefixes: | ||
address_families: | ||
- afi: ipv4 |
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.
I believe we have to check for specific peer for specific AFI/SAFI. Please recheck.
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.
Updated. Thanks!
c2f80c6
to
de886f7
Compare
anta/tests/routing/bgp.py
Outdated
|
||
# Update the peer details as per input peer addresses for verification. | ||
if bgp_peers: | ||
details: dict[Any, Any] = {} |
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.
Please use the more meaning full variables.
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.
Updated.
anta/tests/routing/bgp.py
Outdated
if (prefix_acc and prefix_rcv) == "Not Found": | ||
failure[peer] = {"prefix received": prefix_rcv, "prefix accepted": prefix_acc} | ||
continue | ||
if prefix_rcv != prefix_acc: | ||
failure[peer] = {"prefix received": prefix_rcv, "prefix accepted": prefix_acc} |
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.
if (prefix_acc and prefix_rcv) == "Not Found": | |
failure[peer] = {"prefix received": prefix_rcv, "prefix accepted": prefix_acc} | |
continue | |
if prefix_rcv != prefix_acc: | |
failure[peer] = {"prefix received": prefix_rcv, "prefix accepted": prefix_acc} | |
if (prefix_acc and prefix_rcv) == "Not Found" or prefix_rcv != prefix_acc: | |
failure[peer] = {"prefix received": prefix_rcv, "prefix accepted": prefix_acc} |
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.
Updated
anta/tests/routing/bgp.py
Outdated
continue | ||
|
||
# Verify the received and accepted prefix(s). | ||
failure_logs = _get_inconsistent_peers(peer_details, peers) |
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.
please separate out the variable name by input or actual peers
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.
Updated. Thanks!!
de886f7
to
d8439a9
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Conflicts have been resolved. A maintainer will review the pull request shortly. |
anta/tests/routing/bgp.py
Outdated
"""Identify BGP peers with inconsistency of prefix(s) received and accepted in a BGP session. | ||
|
||
bgp_peers: list of IPv4 address of a BGP peer to be verified. If not provided, test will verifies all the BGP peers. | ||
|
||
Parameters | ||
---------- | ||
peer_details: The BGP peer data dictionary. | ||
bgp_peers: The list of IPv4 address of a BGP peer(s) to be verified. |
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.
Please correct the doc string format.
examples/tests.yaml
Outdated
@@ -678,4 +691,4 @@ anta.tests.routing: | |||
- endpoint: 1.0.0.14/32 | |||
vias: | |||
- type: ip | |||
nexthop: 1.1.1.1 | |||
nexthop: 1.1.1.1 |
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.
please add an empty line at the end
5d11dce
to
2545e65
Compare
CodSpeed Performance ReportMerging #792 will not alter performanceComparing Summary
|
"result": "failure", | ||
"messages": [ | ||
"The following BGP address family(s), peers are not configured or prefix(s) received and accepted are not consistent:\n" | ||
"{'ipv4': {'unicast': {'10.100.0.8': {'prefix received': 18, 'prefix accepted': 17}, '10.100.0.10': {'prefix received': 20, 'prefix accepted': 15}}," |
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.
please add the information of vrf in failure log
Quality Gate passedIssues Measures |
if not failures.get(afi): | ||
failures[afi] = {} |
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.
if not failures.get(afi): | |
failures[afi] = {} | |
failures.setdefault(afi, {}) |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Description
Verifies BGP IPv4 peer(s) consistency of NLRIs received and accepted in a BGP session.
Fixes #786
Checklist:
pre-commit run
)tox -e testenv
)