Skip to content

Commit

Permalink
topotests: add bgp test to check the ADJ-RIB-IN label value
Browse files Browse the repository at this point in the history
The test is done on r2. A BGP update is received on r2, and is
filtered on r2. The RIB of r2 does not have the BGP update stored,
but the ADJ-RIB-IN is yet present. To demonstrate this, if the
inbound route-map is removed, then the BGP update should be copied
from the the ADJ-RIB-IN and added to the RIB with the label
value.

Signed-off-by: Philippe Guibert <[email protected]>
  • Loading branch information
pguibert6WIND authored and louis-6wind committed Jun 8, 2023
1 parent c349517 commit 85f39d8
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions tests/topotests/bgp_vpnv4_ebgp/test_bgp_vpnv4_ebgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import json
from functools import partial
import pytest
import functools

# Save the Current Working Directory to find configuration files.
CWD = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -247,6 +248,72 @@ def test_adj_rib_out_label_change():
assert result is None, assertmsg


def test_adj_rib_in_label_change():
"""
Check that syncinig with ADJ-RIB-in on r2
permits restoring the initial label value
"""
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)

logger.info("Enable soft inbound on r2")
tgen.gears["r2"].vtysh_cmd(
"configure terminal\nrouter bgp 65501\naddress-family ipv4 vpn\nneighbor 192.168.0.1 soft-reconfiguration inbound\n",
isjson=False,
)
logger.info("Creating a deny route-map on r2")
tgen.gears["r2"].vtysh_cmd(
"configure terminal\naccess-list 1 permit any\nroute-map rmap deny 1\nmatch ip address 1\n",
isjson=False,
)
logger.info("Attaching the deny route-map at input on r2")
tgen.gears["r2"].vtysh_cmd(
"configure terminal\nrouter bgp 65501\naddress-family ipv4 vpn\nneighbor 192.168.0.1 route-map rmap in\n",
isjson=False,
)

# check that 172.31.0.1 should not be present
logger.info("Check that received update 172.31.0.1 is not present")

def _prefix1_not_found(router):
output = json.loads(router.vtysh_cmd("show bgp ipv4 vpn 172.31.0.1 json"))
expected = {"444:1": {"prefix": "172.31.0.1/32"}}
ret = topotest.json_cmp(output, expected)
if ret is None:
return "not good"
return None

router = tgen.gears["r2"]
test_func = functools.partial(_prefix1_not_found, router)
success, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
assert success, "r2, vpnv4 update 172.31.0.1 still present"

logger.info("Detaching the deny route-map at input on r2")
tgen.gears["r2"].vtysh_cmd(
"configure terminal\nrouter bgp 65501\naddress-family ipv4 vpn\nno neighbor 192.168.0.1 route-map rmap in\n",
isjson=False,
)
# Check BGP IPv4 route entry for 172.31.0.1 on r1
logger.info(
"Checking that 172.31.0.1 BGP update is present and has valid label on r2"
)
json_file = "{}/{}/bgp_ipv4_vpn_route_1723101.json".format(CWD, router.name)
if not os.path.isfile(json_file):
assert 0, "bgp_ipv4_vpn_route_1723101.json file not found"

expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp,
router,
"show bgp ipv4 vpn 172.31.0.1/32 json",
expected,
)
_, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
assertmsg = '"{}" JSON output mismatches'.format(router.name)
assert result is None, assertmsg


def test_memory_leak():
"Run the memory leak test and report results."
tgen = get_topogen()
Expand Down

0 comments on commit 85f39d8

Please sign in to comment.