Skip to content

Commit

Permalink
topotests: bgp_bmp, add vpn tests
Browse files Browse the repository at this point in the history
Test vpn prefixes sending to BMP

Signed-off-by: Farid Mihoub <farid.mihoub@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
  • Loading branch information
louis-6wind committed Feb 29, 2024
1 parent 8d3546f commit 5558606
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
26 changes: 26 additions & 0 deletions tests/topotests/bgp_bmp/r1/bgpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ router bgp 65501
bmp connect 192.0.2.10 port 1789 min-retry 100 max-retry 10000
exit
!
address-family ipv4 vpn
neighbor 192.168.0.2 activate
neighbor 192.168.0.2 soft-reconfiguration inbound
exit-address-family
address-family ipv6 vpn
neighbor 192:168::2 activate
neighbor 192:168::2 soft-reconfiguration inbound
exit-address-family
address-family ipv4 unicast
neighbor 192.168.0.2 activate
neighbor 192.168.0.2 soft-reconfiguration inbound
Expand All @@ -20,3 +28,21 @@ router bgp 65501
neighbor 192:168::2 soft-reconfiguration inbound
exit-address-family
!
router bgp 65502 vrf vrf1
bgp router_id 192.168.0.1
bgp log-neighbor-changes
address-family ipv4 unicast
label vpn export 101
rd vpn export 444:1
rt vpn both 52:100
export vpn
import vpn
exit-address-family
address-family ipv6 unicast
label vpn export 103
rd vpn export 555:1
rt vpn both 54:200
export vpn
import vpn
exit-address-family
exit
27 changes: 27 additions & 0 deletions tests/topotests/bgp_bmp/r2/bgpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,36 @@ router bgp 65502
no neighbor 192:168::1 activate
redistribute connected
exit-address-family
!
address-family ipv4 vpn
neighbor 192.168.0.1 activate
exit-address-family
!
address-family ipv6 vpn
neighbor 192:168::1 activate
exit-address-family
!
address-family ipv6 unicast
neighbor 192:168::1 activate
redistribute connected
exit-address-family
!
router bgp 65502 vrf vrf1
bgp router-id 192.168.0.2
bgp log-neighbor-changes
no bgp network import-check
address-family ipv4 unicast
label vpn export 102
rd vpn export 444:2
rt vpn both 52:100
export vpn
import vpn
exit-address-family
address-family ipv6 unicast
label vpn export 105
rd vpn export 555:2
rt vpn both 54:200
export vpn
import vpn
exit-address-family
exit
40 changes: 39 additions & 1 deletion tests/topotests/bgp_bmp/test_bgp_bmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def configure_prefixes(tgen, node, asn, safi, prefixes, vrf=None, update=True):
Configure the bgp prefixes.
"""
withdraw = "no " if not update else ""
vrf = " vrf {}" if vrf else ""
vrf = " vrf {}".format(vrf) if vrf else ""
for p in prefixes:
ip = ip_network(p)
cmd = [
Expand Down Expand Up @@ -216,6 +216,34 @@ def unicast_prefixes(policy):
assert success, "Checking the withdrawed prefixes has been failed !."


def vpn_prefixes(policy):
"""
Setup the BMP monitor policy, Add and withdraw ipv4/v6 prefixes.
Check if the previous actions are logged in the BMP server with the right
message type and the right policy.
"""
tgen = get_topogen()
set_bmp_policy(tgen, "r1", 65501, "bmp1", "vpn", policy)

prefixes = ["172.31.10.1/32", "2001::2222/128"]
# add prefixes
configure_prefixes(tgen, "r2", 65502, "unicast", prefixes, vrf="vrf1")

logger.info("checking for updated prefixes")
# check
test_func = partial(check_for_prefixes, prefixes, "update", policy)
success, _ = topotest.run_and_expect(test_func, True, wait=0.5)
assert success, "Checking the updated prefixes has been failed !."

# withdraw prefixes
configure_prefixes(tgen, "r2", 65502, "unicast", prefixes, vrf="vrf1", update=False)
logger.info("checking for withdrawed prefixes")
# check
test_func = partial(check_for_prefixes, prefixes, "withdraw", policy)
success, _ = topotest.run_and_expect(test_func, True, wait=0.5)
assert success, "Checking the withdrawed prefixes has been failed !."


def test_bmp_server_logging():
"""
Assert the logging of the bmp server.
Expand Down Expand Up @@ -244,6 +272,16 @@ def test_bmp_bgp_unicast():
unicast_prefixes(LOC_RIB)


def test_bmp_bgp_vpn():
# check for the prefixes in the BMP server logging file
logger.info("***** VPN prefixes pre-policy logging *****")
vpn_prefixes(PRE_POLICY)
logger.info("***** VPN prefixes post-policy logging *****")
vpn_prefixes(POST_POLICY)
logger.info("***** VPN prefixes loc-rib logging *****")
vpn_prefixes(LOC_RIB)


if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))

0 comments on commit 5558606

Please sign in to comment.