Skip to content

Commit

Permalink
bgp_evpn_rt5: add test for advertise route-map service
Browse files Browse the repository at this point in the history
Use the advertise route-map command, and check that it
filters out correctly the undesirable prefixes. Reversely,
check that undoing that route-map recovers all prefixes.

Signed-off-by: Philippe Guibert <[email protected]>
  • Loading branch information
pguibert6WIND committed Nov 25, 2024
1 parent 199d795 commit 7e88c4b
Show file tree
Hide file tree
Showing 3 changed files with 246 additions and 2 deletions.
191 changes: 191 additions & 0 deletions tests/topotests/bgp_evpn_rt5/r1/bgp_l2vpn_evpn_routes_all.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
{
"bgpLocalRouterId":"192.168.100.21",
"defaultLocPrf":100,
"localAS":65000,
"192.168.101.41:2":{
"rd":"192.168.101.41:2",
"[5]:[0]:[32]:[192.168.101.41]":{
"prefix":"[5]:[0]:[32]:[192.168.101.41]",
"prefixLen":352,
"paths":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"routeType":5,
"ethTag":0,
"ipLen":32,
"ip":"192.168.101.41",
"metric":0,
"locPrf":100,
"weight":0,
"peerId":"192.168.100.41",
"path":"",
"origin":"IGP",
"nexthops":[
{
"ip":"192.168.100.41",
"hostname":"r2",
"afi":"ipv4",
"used":true
}
]
}
]
},
"[5]:[0]:[32]:[192.168.102.41]":{
"prefix":"[5]:[0]:[32]:[192.168.102.41]",
"prefixLen":352,
"paths":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"routeType":5,
"ethTag":0,
"ipLen":32,
"ip":"192.168.102.41",
"metric":0,
"locPrf":100,
"weight":0,
"peerId":"192.168.100.41",
"path":"",
"origin":"IGP",
"nexthops":[
{
"ip":"192.168.100.41",
"hostname":"r2",
"afi":"ipv4",
"used":true
}
]
}
]
},
"[5]:[0]:[128]:[fd00::2]":{
"prefix":"[5]:[0]:[128]:[fd00::2]",
"prefixLen":352,
"paths":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"routeType":5,
"ethTag":0,
"ipLen":128,
"ip":"fd00::2",
"metric":0,
"locPrf":100,
"weight":0,
"peerId":"192.168.100.41",
"path":"",
"origin":"IGP",
"nexthops":[
{
"ip":"192.168.100.41",
"hostname":"r2",
"afi":"ipv4",
"used":true
}
]
}
]
},
"[5]:[0]:[128]:[fd00::3]":{
"prefix":"[5]:[0]:[128]:[fd00::3]",
"prefixLen":352,
"paths":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"routeType":5,
"ethTag":0,
"ipLen":128,
"ip":"fd00::3",
"metric":0,
"locPrf":100,
"weight":0,
"peerId":"192.168.100.41",
"path":"",
"origin":"IGP",
"nexthops":[
{
"ip":"192.168.100.41",
"hostname":"r2",
"afi":"ipv4",
"used":true
}
]
}
]
}
},
"192.168.102.21:2":{
"rd":"192.168.102.21:2",
"[5]:[0]:[32]:[192.168.102.21]":{
"prefix":"[5]:[0]:[32]:[192.168.102.21]",
"prefixLen":352,
"paths":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"external",
"routeType":5,
"ethTag":0,
"ipLen":32,
"ip":"192.168.102.21",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"IGP",
"nexthops":[
{
"ip":"192.168.100.21",
"hostname":"r1",
"afi":"ipv4",
"used":true
}
]
}
]
},
"[5]:[0]:[128]:[fd00::1]":{
"prefix":"[5]:[0]:[128]:[fd00::1]",
"prefixLen":352,
"paths":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"external",
"routeType":5,
"ethTag":0,
"ipLen":128,
"ip":"fd00::1",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"IGP",
"nexthops":[
{
"ip":"192.168.100.21",
"hostname":"r1",
"afi":"ipv4",
"used":true
}
]
}
]
}
},
"numPrefix":6,
"totalPrefix":6
}
22 changes: 20 additions & 2 deletions tests/topotests/bgp_evpn_rt5/r2/bgpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,30 @@ router bgp 65000 vrf r2-vrf-101
no bgp network import-check
address-family ipv4 unicast
network 192.168.101.41/32
network 192.168.102.41/32
exit-address-family
address-family ipv6 unicast
network fd00::2/128
network fd00::3/128
exit-address-family
address-family l2vpn evpn
advertise ipv4 unicast
advertise ipv6 unicast
advertise ipv4 unicast route-map rmap4
advertise ipv6 unicast route-map rmap6
exit-address-family
!
access-list acl4_1 seq 10 permit 192.168.101.41/32
access-list acl4_2 seq 10 permit 192.168.102.41/32
ipv6 access-list acl6_1 seq 10 permit fd00::2/128
ipv6 access-list acl6_2 seq 10 permit fd00::3/128
route-map rmap4 permit 1
match ip address acl4_1
exit
route-map rmap4 deny 2
match ip address acl4_2
exit
route-map rmap6 permit 1
match ipv6 address acl6_1
exit
route-map rmap6 deny 2
match ipv6 address acl6_2
exit
35 changes: 35 additions & 0 deletions tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,40 @@ def test_evpn_ping():
_test_evpn_ping_router(tgen.gears["r1"])


def test_evpn_disable_routemap():
"""
Check the removal of a route-map on R2. More EVPN Prefixes are expected
"""
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)

tgen.gears["r2"].vtysh_cmd(
"""
configure terminal\n
router bgp 65000 vrf r2-vrf-101\n
address-family l2vpn evpn\n
advertise ipv4 unicast\n
advertise ipv6 unicast\n
"""
)
router = tgen.gears["r1"]
json_file = "{}/{}/bgp_l2vpn_evpn_routes_all.json".format(CWD, router.name)
if not os.path.isfile(json_file):
assert 0, "bgp_l2vpn_evpn_routes.json file not found"

expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp,
router,
"show bgp l2vpn evpn json",
expected,
)
_, result = topotest.run_and_expect(test_func, None, count=20, wait=1)
assertmsg = '"{}" JSON output mismatches'.format(router.name)
assert result is None, assertmsg


def test_evpn_remove_ip():
"""
Check the removal of an EVPN route is correctly handled
Expand All @@ -360,6 +394,7 @@ def test_evpn_remove_ip():
"raw_config": [
"router bgp 65000 vrf r2-vrf-101",
"address-family ipv6 unicast",
"no network fd00::3/128",
"no network fd00::2/128",
]
}
Expand Down

0 comments on commit 7e88c4b

Please sign in to comment.