mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-12 23:47:13 +00:00
topotests: add vpn test to control aggregated prefix is exported
Add a test in bgp_vpnv4_ebgp test to control that the aggregated prefix is exported and selected as a VPN prefix. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
1cbbc94e55
commit
bccf1e5447
@ -15,8 +15,10 @@ router bgp 65500
|
||||
!
|
||||
router bgp 65500 vrf vrf1
|
||||
bgp router-id 192.0.2.1
|
||||
neighbor 172.31.2.100 remote-as 65500
|
||||
address-family ipv4 unicast
|
||||
redistribute connected
|
||||
aggregate-address 172.31.1.0/24
|
||||
label vpn export 101
|
||||
rd vpn export 444:1
|
||||
rt vpn both 52:100
|
||||
|
@ -0,0 +1,52 @@
|
||||
{
|
||||
"444:1":{
|
||||
"prefix":"172.31.1.0/24",
|
||||
"advertisedTo":{
|
||||
"192.168.0.2":{
|
||||
"hostname":"r2"
|
||||
},
|
||||
"192.168.0.3":{
|
||||
"hostname":"r3"
|
||||
}
|
||||
},
|
||||
"paths":[
|
||||
{
|
||||
"aspath":{
|
||||
"string":"Local",
|
||||
"segments":[
|
||||
],
|
||||
"length":0
|
||||
},
|
||||
"aggregatorAs":65500,
|
||||
"aggregatorId":"192.0.2.1",
|
||||
"nhVrfName":"vrf1",
|
||||
"announceNexthopSelf":true,
|
||||
"origin":"incomplete",
|
||||
"metric":0,
|
||||
"weight":32768,
|
||||
"valid":true,
|
||||
"sourced":true,
|
||||
"local":true,
|
||||
"atomicAggregate":true,
|
||||
"bestpath":{
|
||||
"overall":true,
|
||||
"selectionReason":"First path received"
|
||||
},
|
||||
"originatorId":"192.0.2.1",
|
||||
"nexthops":[
|
||||
{
|
||||
"ip":"0.0.0.0",
|
||||
"afi":"ipv4",
|
||||
"metric":0,
|
||||
"accessible":true,
|
||||
"used":true
|
||||
}
|
||||
],
|
||||
"peer":{
|
||||
"peerId":"0.0.0.0",
|
||||
"routerId":"192.0.2.1"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -1,6 +1,10 @@
|
||||
log stdout
|
||||
interface r1-eth1 vrf vrf1
|
||||
ip address 172.31.0.1/32
|
||||
ip address 172.31.1.1/32
|
||||
ip address 172.31.1.2/32
|
||||
ip address 172.31.1.3/32
|
||||
ip address 172.31.2.1/24
|
||||
!
|
||||
interface r1-eth0
|
||||
ip address 192.168.0.1/24
|
||||
|
6
tests/topotests/bgp_vpnv4_ebgp/r100/bgpd.conf
Normal file
6
tests/topotests/bgp_vpnv4_ebgp/r100/bgpd.conf
Normal file
@ -0,0 +1,6 @@
|
||||
router bgp 65500
|
||||
bgp router-id 192.0.2.100
|
||||
neighbor 172.31.2.1 remote-as 65500
|
||||
address-family ipv4 unicast
|
||||
exit-address-family
|
||||
exit
|
147
tests/topotests/bgp_vpnv4_ebgp/r100/show_bgp_ipv4.json
Normal file
147
tests/topotests/bgp_vpnv4_ebgp/r100/show_bgp_ipv4.json
Normal file
@ -0,0 +1,147 @@
|
||||
{
|
||||
"vrfId": 0,
|
||||
"vrfName": "default",
|
||||
"routerId": "192.0.2.100",
|
||||
"defaultLocPrf": 100,
|
||||
"localAS": 65500,
|
||||
"routes": {
|
||||
"172.31.0.1/32": [{
|
||||
"valid":true,
|
||||
"bestpath":true,
|
||||
"selectionReason":"First path received",
|
||||
"pathFrom":"internal",
|
||||
"prefix":"172.31.0.1",
|
||||
"prefixLen":32,
|
||||
"network":"172.31.0.1/32",
|
||||
"metric":0,
|
||||
"locPrf":100,
|
||||
"weight":0,
|
||||
"peerId":"172.31.2.1",
|
||||
"origin":"incomplete",
|
||||
"nexthops":[{
|
||||
"ip":"172.31.2.1",
|
||||
"afi":"ipv4",
|
||||
"used":true
|
||||
}]
|
||||
}],
|
||||
"172.31.0.10/32": [{
|
||||
"valid":true,
|
||||
"bestpath":true,
|
||||
"selectionReason":"First path received",
|
||||
"pathFrom":"internal",
|
||||
"prefix":"172.31.0.10",
|
||||
"prefixLen":32,
|
||||
"network":"172.31.0.10/32",
|
||||
"metric":0,
|
||||
"locPrf":100,
|
||||
"weight":0,
|
||||
"peerId":"172.31.2.1",
|
||||
"path":"65501",
|
||||
"origin":"incomplete",
|
||||
"nexthops":[{
|
||||
"ip":"172.31.2.1",
|
||||
"afi":"ipv4",
|
||||
"used":true
|
||||
}]
|
||||
}],
|
||||
"172.31.1.0/24": [{
|
||||
"valid":true,
|
||||
"bestpath":true,
|
||||
"selectionReason":"First path received",
|
||||
"pathFrom":"internal",
|
||||
"prefix":"172.31.1.0",
|
||||
"prefixLen":24,
|
||||
"network":"172.31.1.0/24",
|
||||
"metric":0,
|
||||
"locPrf":100,
|
||||
"weight":0,
|
||||
"peerId":"172.31.2.1",
|
||||
"path":"",
|
||||
"origin":"incomplete",
|
||||
"nexthops":[{
|
||||
"ip":"172.31.2.1",
|
||||
"afi":"ipv4",
|
||||
"used":true
|
||||
}]
|
||||
}],
|
||||
"172.31.1.1/32": [{
|
||||
"valid":true,
|
||||
"bestpath":true,
|
||||
"selectionReason":"First path received",
|
||||
"pathFrom":"internal",
|
||||
"prefix":"172.31.1.1",
|
||||
"prefixLen":32,
|
||||
"network":"172.31.1.1/32",
|
||||
"metric":0,
|
||||
"locPrf":100,
|
||||
"weight":0,
|
||||
"peerId":"172.31.2.1",
|
||||
"path":"",
|
||||
"origin":"incomplete",
|
||||
"nexthops":[{
|
||||
"ip":"172.31.2.1",
|
||||
"afi":"ipv4",
|
||||
"used":true}]
|
||||
}],
|
||||
"172.31.1.2/32": [{
|
||||
"valid":true,
|
||||
"bestpath":true,
|
||||
"selectionReason":"First path received",
|
||||
"pathFrom":"internal",
|
||||
"prefix":"172.31.1.2",
|
||||
"prefixLen":32,
|
||||
"network":"172.31.1.2/32",
|
||||
"metric":0,
|
||||
"locPrf":100,
|
||||
"weight":0,
|
||||
"peerId":"172.31.2.1",
|
||||
"path":"",
|
||||
"origin":"incomplete",
|
||||
"nexthops":[{
|
||||
"ip":"172.31.2.1",
|
||||
"afi":"ipv4",
|
||||
"used":true}]
|
||||
}],
|
||||
"172.31.1.3/32": [{
|
||||
"valid":true,
|
||||
"bestpath":true,
|
||||
"selectionReason":"First path received",
|
||||
"pathFrom":"internal",
|
||||
"prefix":"172.31.1.3",
|
||||
"prefixLen":32,
|
||||
"network":"172.31.1.3/32",
|
||||
"metric":0,
|
||||
"locPrf":100,
|
||||
"weight":0,
|
||||
"peerId":"172.31.2.1",
|
||||
"path":"",
|
||||
"origin":"incomplete",
|
||||
"nexthops":[{
|
||||
"ip":"172.31.2.1",
|
||||
"afi":"ipv4",
|
||||
"used":true
|
||||
}]
|
||||
}],
|
||||
"172.31.2.0/24": [{
|
||||
"valid":true,
|
||||
"bestpath":true,
|
||||
"selectionReason":"First path received",
|
||||
"pathFrom":"internal",
|
||||
"prefix":"172.31.2.0",
|
||||
"prefixLen":24,
|
||||
"network":"172.31.2.0/24",
|
||||
"metric":0,
|
||||
"locPrf":100,
|
||||
"weight":0,
|
||||
"peerId":"172.31.2.1",
|
||||
"path":"",
|
||||
"origin":"incomplete",
|
||||
"nexthops":[{
|
||||
"ip":"172.31.2.1",
|
||||
"afi":"ipv4",
|
||||
"used":true}]
|
||||
}]
|
||||
} ,
|
||||
"totalRoutes": 7,
|
||||
"totalPaths": 7
|
||||
}
|
4
tests/topotests/bgp_vpnv4_ebgp/r100/zebra.conf
Normal file
4
tests/topotests/bgp_vpnv4_ebgp/r100/zebra.conf
Normal file
@ -0,0 +1,4 @@
|
||||
log stdout
|
||||
interface r100-eth0
|
||||
ip address 172.31.2.100/24
|
||||
!
|
@ -45,6 +45,7 @@ def build_topo(tgen):
|
||||
tgen.add_router("r1")
|
||||
tgen.add_router("r2")
|
||||
tgen.add_router("r3")
|
||||
tgen.add_router("r100")
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
@ -53,6 +54,7 @@ def build_topo(tgen):
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r100"])
|
||||
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
@ -524,6 +526,54 @@ router bgp 65501
|
||||
assert result is None, assertmsg
|
||||
|
||||
|
||||
def test_aggregated_route_on_r100():
|
||||
"""
|
||||
Check that only aggregated route on r100 is received
|
||||
"""
|
||||
tgen = get_topogen()
|
||||
if tgen.routers_have_failure():
|
||||
pytest.skip(tgen.errors)
|
||||
|
||||
r100 = tgen.gears["r100"]
|
||||
logger.info("Checking prefixes list on R100")
|
||||
json_file = "{}/{}/show_bgp_ipv4.json".format(CWD, r100.name)
|
||||
|
||||
expected = json.loads(open(json_file).read())
|
||||
test_func = partial(
|
||||
topotest.router_json_cmp,
|
||||
r100,
|
||||
"show bgp ipv4 json",
|
||||
expected,
|
||||
)
|
||||
_, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
|
||||
assertmsg = '"{}" JSON output mismatches'.format(r100.name)
|
||||
assert result is None, assertmsg
|
||||
|
||||
|
||||
def test_aggregated_exported_route_on_r1():
|
||||
"""
|
||||
Check that the aggregated route 172.31.1.0/24 is exported
|
||||
"""
|
||||
tgen = get_topogen()
|
||||
if tgen.routers_have_failure():
|
||||
pytest.skip(tgen.errors)
|
||||
|
||||
r1 = tgen.gears["r1"]
|
||||
logger.info("Checking 172.31.1.0/24 VPN prefix on R1")
|
||||
json_file = "{}/{}/show_bgp_ipv4_172_31_1_0.json".format(CWD, r1.name)
|
||||
|
||||
expected = json.loads(open(json_file).read())
|
||||
test_func = partial(
|
||||
topotest.router_json_cmp,
|
||||
r1,
|
||||
"show bgp ipv4 vpn 172.31.1.0/24 json",
|
||||
expected,
|
||||
)
|
||||
_, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
|
||||
assertmsg = '"{}" JSON output mismatches'.format(r1.name)
|
||||
assert result is None, assertmsg
|
||||
|
||||
|
||||
def test_memory_leak():
|
||||
"Run the memory leak test and report results."
|
||||
tgen = get_topogen()
|
||||
|
Loading…
Reference in New Issue
Block a user