topotests: more tests in bgp_vpnv4_noretain

Add more VRFs in bgp_vpnv4_noretain and test combinations of no-retain
/ retain and import / un-import.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
This commit is contained in:
Louis Scalbert 2023-06-08 13:42:30 +02:00
parent d629c2f419
commit 22dfa04b78
10 changed files with 678 additions and 9 deletions

View File

@ -21,4 +21,22 @@ router bgp 65500 vrf vrf1
import vpn
exit-address-family
!
router bgp 65500 vrf vrf3
bgp router-id 192.0.2.1
address-family ipv4 unicast
redistribute connected
label vpn export 103
rd vpn export 192.0.2.1:3
rt vpn export 192.0.2.1:300
export vpn
exit-address-family
!
router bgp 65500 vrf vrf4
bgp router-id 192.0.2.1
address-family ipv4 unicast
label vpn export 104
rd vpn export 192.0.2.1:4
rt vpn import 192.0.2.1:300
import vpn
exit-address-family
!

View File

@ -34,6 +34,34 @@
}
]
},
"192.0.2.1:3":{
"10.103.0.0/24":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"external",
"prefix":"10.103.0.0",
"prefixLen":24,
"network":"10.103.0.0\/24",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"announceNexthopSelf":true,
"nhVrfName":"vrf3",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"r1",
"afi":"ipv4",
"used":true
}
]
}
]
},
"192.0.2.2:1":{
"10.201.0.0/24":[
{
@ -87,6 +115,33 @@
]
}
]
},
"192.0.2.2:3":{
"10.203.0.0/24":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"prefix":"10.203.0.0",
"prefixLen":24,
"network":"10.203.0.0\/24",
"metric":0,
"locPrf":100,
"weight":0,
"peerId":"10.125.0.2",
"path":"",
"origin":"incomplete",
"nexthops":[
{
"ip":"10.125.0.2",
"hostname":"r2",
"afi":"ipv4",
"used":true
}
]
}
]
}
}
}

View File

@ -34,6 +34,34 @@
}
]
},
"192.0.2.1:3":{
"10.103.0.0/24":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"external",
"prefix":"10.103.0.0",
"prefixLen":24,
"network":"10.103.0.0\/24",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"announceNexthopSelf":true,
"nhVrfName":"vrf3",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"r1",
"afi":"ipv4",
"used":true
}
]
}
]
},
"192.0.2.2:1":{
"10.201.0.0/24":[
{

View File

@ -0,0 +1,121 @@
{
"vrfId":0,
"vrfName":"default",
"routerId":"192.0.2.1",
"defaultLocPrf":100,
"localAS":65500,
"routes":{
"routeDistinguishers":{
"192.0.2.1:1":{
"10.101.0.0/24":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"external",
"prefix":"10.101.0.0",
"prefixLen":24,
"network":"10.101.0.0\/24",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"announceNexthopSelf":true,
"nhVrfName":"vrf1",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"r1",
"afi":"ipv4",
"used":true
}
]
}
]
},
"192.0.2.1:3":{
"10.103.0.0/24":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"external",
"prefix":"10.103.0.0",
"prefixLen":24,
"network":"10.103.0.0\/24",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"announceNexthopSelf":true,
"nhVrfName":"vrf3",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"r1",
"afi":"ipv4",
"used":true
}
]
}
]
},
"192.0.2.2:1":{
"10.201.0.0/24":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"prefix":"10.201.0.0",
"prefixLen":24,
"network":"10.201.0.0\/24",
"metric":0,
"locPrf":100,
"weight":0,
"peerId":"10.125.0.2",
"path":"",
"origin":"incomplete",
"nexthops":[
{
"ip":"10.125.0.2",
"hostname":"r2",
"afi":"ipv4",
"used":true
}
]
}
]
},
"192.0.2.2:2":{
"10.202.0.0/24":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"prefix":"10.202.0.0",
"prefixLen":24,
"network":"10.202.0.0\/24",
"metric":0,
"locPrf":100,
"weight":0,
"peerId":"10.125.0.2",
"path":"",
"origin":"incomplete",
"nexthops":[
{
"ip":"10.125.0.2",
"hostname":"r2",
"afi":"ipv4",
"used":true
}
]
}
]
}
}
}
}

View File

@ -0,0 +1,121 @@
{
"vrfId":0,
"vrfName":"default",
"routerId":"192.0.2.1",
"defaultLocPrf":100,
"localAS":65500,
"routes":{
"routeDistinguishers":{
"192.0.2.1:1":{
"10.101.0.0/24":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"external",
"prefix":"10.101.0.0",
"prefixLen":24,
"network":"10.101.0.0\/24",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"announceNexthopSelf":true,
"nhVrfName":"vrf1",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"r1",
"afi":"ipv4",
"used":true
}
]
}
]
},
"192.0.2.1:3":{
"10.103.0.0/24":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"external",
"prefix":"10.103.0.0",
"prefixLen":24,
"network":"10.103.0.0\/24",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"announceNexthopSelf":true,
"nhVrfName":"vrf3",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"r1",
"afi":"ipv4",
"used":true
}
]
}
]
},
"192.0.2.2:1":{
"10.201.0.0/24":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"prefix":"10.201.0.0",
"prefixLen":24,
"network":"10.201.0.0\/24",
"metric":0,
"locPrf":100,
"weight":0,
"peerId":"10.125.0.2",
"path":"",
"origin":"incomplete",
"nexthops":[
{
"ip":"10.125.0.2",
"hostname":"r2",
"afi":"ipv4",
"used":true
}
]
}
]
},
"192.0.2.2:3":{
"10.203.0.0/24":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"prefix":"10.203.0.0",
"prefixLen":24,
"network":"10.203.0.0\/24",
"metric":0,
"locPrf":100,
"weight":0,
"peerId":"10.125.0.2",
"path":"",
"origin":"incomplete",
"nexthops":[
{
"ip":"10.125.0.2",
"hostname":"r2",
"afi":"ipv4",
"used":true
}
]
}
]
}
}
}
}

View File

@ -11,3 +11,6 @@ interface r1-eth0
interface r1-eth1 vrf vrf1
ip address 10.101.0.1/24
!
interface r1-eth3 vrf vrf3
ip address 10.103.0.1/24
!

View File

@ -32,3 +32,13 @@ router bgp 65500 vrf vrf2
import vpn
exit-address-family
!
router bgp 65500 vrf vrf3
bgp router-id 192.0.2.2
address-family ipv4 unicast
redistribute connected
label vpn export 203
rd vpn export 192.0.2.2:3
rt vpn export 192.0.2.2:300
export vpn
exit-address-family
!

View File

@ -33,6 +33,33 @@
}
]
},
"192.0.2.1:3": {
"10.103.0.0/24": [
{
"valid": true,
"bestpath": true,
"selectionReason": "First path received",
"pathFrom": "internal",
"prefix": "10.103.0.0",
"prefixLen": 24,
"network": "10.103.0.0/24",
"metric": 0,
"locPrf": 100,
"weight": 0,
"peerId": "10.125.0.1",
"path": "",
"origin": "incomplete",
"nexthops": [
{
"ip": "10.125.0.1",
"hostname": "r1",
"afi": "ipv4",
"used": true
}
]
}
]
},
"192.0.2.2:1": {
"10.201.0.0/24": [
{
@ -88,6 +115,34 @@
]
}
]
},
"192.0.2.2:3": {
"10.203.0.0/24": [
{
"valid": true,
"bestpath": true,
"selectionReason": "First path received",
"pathFrom": "external",
"prefix": "10.203.0.0",
"prefixLen": 24,
"network": "10.203.0.0/24",
"metric": 0,
"weight": 32768,
"peerId": "(unspec)",
"path": "",
"origin": "incomplete",
"announceNexthopSelf": true,
"nhVrfName": "vrf3",
"nexthops": [
{
"ip": "0.0.0.0",
"hostname": "r2",
"afi": "ipv4",
"used": true
}
]
}
]
}
}
}

View File

@ -14,3 +14,6 @@ interface r2-eth1 vrf vrf1
interface r2-eth2 vrf vrf2
ip address 10.202.0.2/24
!
interface r2-eth3 vrf vrf3
ip address 10.203.0.1/24
!

View File

@ -55,6 +55,18 @@ def build_topo(tgen):
switch = tgen.add_switch("s4")
switch.add_link(tgen.gears["r2"])
switch = tgen.add_switch("s5")
switch.add_link(tgen.gears["r1"])
switch = tgen.add_switch("s6")
switch.add_link(tgen.gears["r2"])
switch = tgen.add_switch("s7")
switch.add_link(tgen.gears["r1"])
switch = tgen.add_switch("s8")
switch.add_link(tgen.gears["r2"])
def _populate_iface():
tgen = get_topogen()
@ -65,12 +77,18 @@ def _populate_iface():
"ip link set dev vrf1 up",
"ip link set dev {0}-eth1 master vrf1",
"echo 1 > /proc/sys/net/mpls/conf/vrf1/input",
]
cmds_list_extra = [
"ip link add vrf2 type vrf table 20",
"ip link set dev vrf2 up",
"ip link set dev {0}-eth2 master vrf2",
"echo 1 > /proc/sys/net/mpls/conf/vrf2/input",
"ip link add vrf3 type vrf table 30",
"ip link set dev vrf3 up",
"ip link set dev {0}-eth3 master vrf3",
"echo 1 > /proc/sys/net/mpls/conf/vrf3/input",
"ip link add vrf4 type vrf table 40",
"ip link set dev vrf4 up",
"ip link set dev {0}-eth4 master vrf4",
"echo 1 > /proc/sys/net/mpls/conf/vrf4/input",
]
for cmd in cmds_list:
@ -85,12 +103,6 @@ def _populate_iface():
output = tgen.net["r2"].cmd(cmd.format("r2", "2", "1"))
logger.info("output: " + output)
for cmd in cmds_list_extra:
input = cmd.format("r2", "2", "1")
logger.info("input: " + cmd)
output = tgen.net["r2"].cmd(cmd.format("r2", "2", "1"))
logger.info("output: " + output)
def setup_module(mod):
"Sets up the pytest environment"
@ -226,6 +238,249 @@ router bgp 65500
check_show_bgp_ipv4_vpn("r2", "ipv4_vpn_routes_all.json")
def test_bgp_no_retain_step3():
"""
Apply and check no bgp retain route-target all on r1
"""
rname = "r1"
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
router = tgen.gears["r1"]
router.vtysh_cmd(
"configure\nrouter bgp 65500\naddress-family ipv4 vpn\nno bgp retain route-target all\n"
)
check_show_bgp_ipv4_vpn(rname, "ipv4_vpn_routes_no_retain_init.json")
check_show_bgp_ipv4_vpn("r2", "ipv4_vpn_routes_all.json")
def test_bgp_no_retain_add_vrf2_step4():
"""
Add vrf2 on r1 and check bgp vpnv4 table
"""
rname = "r1"
cfg = """
configure
router bgp 65500 vrf vrf2
bgp router-id 192.0.2.1
address-family ipv4 unicast
redistribute connected
label vpn export 102
rd vpn export 192.0.2.1:200
rt vpn import 192.0.2.2:200
import vpn
exit-address-family
!
"""
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
router = tgen.gears[rname]
router.vtysh_cmd(cfg)
check_show_bgp_ipv4_vpn(rname, "ipv4_vpn_routes_no_retain_init_plus_r2_vrf2.json")
check_show_bgp_ipv4_vpn("r2", "ipv4_vpn_routes_all.json")
def test_bgp_no_retain_unimport_vrf2_step5():
"""
Unimport to vrf2 on r1 and check bgp vpnv4 table
"""
rname = "r1"
cfg = """
configure
router bgp 65500 vrf vrf2
address-family ipv4 unicast
no import vpn
exit-address-family
!
"""
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
router = tgen.gears[rname]
router.vtysh_cmd(cfg)
check_show_bgp_ipv4_vpn(rname, "ipv4_vpn_routes_no_retain_init.json")
check_show_bgp_ipv4_vpn("r2", "ipv4_vpn_routes_all.json")
def test_bgp_no_retain_import_vrf2_step6():
"""
Re-import to vrf2 on r1 and check bgp vpnv4 table
"""
rname = "r1"
cfg = """
configure
router bgp 65500 vrf vrf2
address-family ipv4 unicast
import vpn
exit-address-family
!
"""
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
router = tgen.gears[rname]
router.vtysh_cmd(cfg)
check_show_bgp_ipv4_vpn(rname, "ipv4_vpn_routes_no_retain_init_plus_r2_vrf2.json")
check_show_bgp_ipv4_vpn("r2", "ipv4_vpn_routes_all.json")
def test_bgp_no_retain_import_vrf1_step7():
"""
Import r2 vrf1 into r1 vrf2 and check bgp vpnv4 table
"""
rname = "r1"
cfg = """
configure
router bgp 65500 vrf vrf2
address-family ipv4 unicast
rt vpn import 192.0.2.1:100
exit-address-family
!
"""
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
router = tgen.gears[rname]
router.vtysh_cmd(cfg)
check_show_bgp_ipv4_vpn(rname, "ipv4_vpn_routes_no_retain_init.json")
check_show_bgp_ipv4_vpn("r2", "ipv4_vpn_routes_all.json")
def test_bgp_no_retain_import_vrf3_step8():
"""
Import r2 vrf3 into r1 vrf2 and check bgp vpnv4 table
"""
rname = "r1"
cfg = """
configure
router bgp 65500 vrf vrf2
address-family ipv4 unicast
rt vpn import 192.0.2.2:300
exit-address-family
!
"""
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
router = tgen.gears[rname]
router.vtysh_cmd(cfg)
check_show_bgp_ipv4_vpn(rname, "ipv4_vpn_routes_no_retain_init_plus_r2_vrf3.json")
check_show_bgp_ipv4_vpn("r2", "ipv4_vpn_routes_all.json")
def test_bgp_no_retain_unimport_vrf3_step9():
"""
Un-import r2 vrf3 into r1 vrf2 and check bgp vpnv4 table
"""
rname = "r1"
cfg = """
configure
router bgp 65500 vrf vrf2
address-family ipv4 unicast
no rt vpn import 192.0.2.2:300
exit-address-family
!
"""
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
router = tgen.gears[rname]
router.vtysh_cmd(cfg)
check_show_bgp_ipv4_vpn(rname, "ipv4_vpn_routes_no_retain_init.json")
check_show_bgp_ipv4_vpn("r2", "ipv4_vpn_routes_all.json")
def test_bgp_no_retain_import_vrf3_step10():
"""
Import r2 vrf3 into r1 vrf2 and check bgp vpnv4 table
"""
rname = "r1"
cfg = """
configure
router bgp 65500 vrf vrf2
address-family ipv4 unicast
rt vpn import 192.0.2.2:300
exit-address-family
!
"""
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
router = tgen.gears[rname]
router.vtysh_cmd(cfg)
check_show_bgp_ipv4_vpn(rname, "ipv4_vpn_routes_no_retain_init_plus_r2_vrf3.json")
check_show_bgp_ipv4_vpn("r2", "ipv4_vpn_routes_all.json")
def test_bgp_no_retain_remove_vrf2_step11():
"""
Import r2 vrf3 into r1 vrf2 and check bgp vpnv4 table
"""
rname = "r1"
cfg = """
configure
no router bgp 65500 vrf vrf2
"""
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
router = tgen.gears[rname]
router.vtysh_cmd(cfg)
check_show_bgp_ipv4_vpn(rname, "ipv4_vpn_routes_no_retain_init.json")
check_show_bgp_ipv4_vpn("r2", "ipv4_vpn_routes_all.json")
def test_bgp_retain_step12():
"""
Configure retain and check bgp vpnv4 table
"""
rname = "r1"
cfg = """
configure
router bgp 65500
address-family ipv4 vpn
bgp retain route-target all
"""
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
router = tgen.gears[rname]
router.vtysh_cmd(cfg)
check_show_bgp_ipv4_vpn(rname, "ipv4_vpn_routes_all.json")
check_show_bgp_ipv4_vpn("r2", "ipv4_vpn_routes_all.json")
def test_memory_leak():
"Run the memory leak test and report results."
tgen = get_topogen()