-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
topotests: bgp_vpnv4_ebgp, check 'extcommunity rt' presence
Add a test to check that the presence of a route-map at exportation with a 'set extcommunity rt' is enough to allow the prefix to be exported. Signed-off-by: Philippe Guibert <[email protected]>
- Loading branch information
1 parent
9191193
commit 9ffaeba
Showing
4 changed files
with
153 additions
and
56 deletions.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
bgp route-map delay-timer 1 | ||
router bgp 65500 | ||
bgp router-id 192.0.2.1 | ||
no bgp ebgp-requires-policy | ||
|
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env python | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
# Copyright 2023, 6wind | ||
import json | ||
|
||
from lib import topotest | ||
|
||
|
||
def check_show_bgp_vpn_prefix_not_found(router, ipversion, prefix, rd, label=None): | ||
""" | ||
Check if a given vpn prefix is not present in the BGP RIB | ||
* 'router': the router to check BGP VPN RIB | ||
* 'ipversion': The ip version to check: ipv4 or ipv6 | ||
* 'prefix': the IP prefix to check | ||
* 'rd': the route distinguisher to check | ||
* 'label: the label to check | ||
""" | ||
output = json.loads( | ||
router.vtysh_cmd("show bgp {} vpn {} json".format(ipversion, prefix)) | ||
) | ||
if label: | ||
expected = {rd: {"prefix": prefix, "paths": [{"remoteLabel": label}]}} | ||
else: | ||
expected = {rd: {"prefix": prefix}} | ||
ret = topotest.json_cmp(output, expected) | ||
if ret is None: | ||
return "not good" | ||
return None | ||
|
||
|
||
def check_show_bgp_vpn_prefix_found( | ||
router, ipversion, prefix, rd, label=None, nexthop=None | ||
): | ||
""" | ||
Check if a given vpn prefix is present in the BGP RIB | ||
* 'router': the router to check BGP VPN RIB | ||
* 'ipversion': The ip version to check: ipv4 or ipv6 | ||
* 'prefix': the IP prefix to check | ||
* 'rd': the route distinguisher to check | ||
* 'label: the label to check | ||
""" | ||
output = json.loads( | ||
router.vtysh_cmd("show bgp {} vpn {} json".format(ipversion, prefix)) | ||
) | ||
if label: | ||
if nexthop: | ||
expected = { | ||
rd: { | ||
"prefix": prefix, | ||
"paths": [{"remoteLabel": label, "nexthops": [{"ip": nexthop}]}], | ||
} | ||
} | ||
else: | ||
expected = {rd: {"prefix": prefix, "paths": [{"remoteLabel": label}]}} | ||
else: | ||
if nexthop: | ||
expected = { | ||
rd: {"prefix": prefix, "paths": [{"nexthops": [{"ip": nexthop}]}]} | ||
} | ||
else: | ||
expected = {rd: {"prefix": prefix}} | ||
return topotest.json_cmp(output, expected) |