topotests: test leak from the default vrf

Add tests in bgp_vrf_route_leak_basic topotest to check that route
leaking from the default VRF results in an operational route.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
This commit is contained in:
Louis Scalbert 2024-02-01 11:44:06 +01:00
parent eeb9f76588
commit 8af61c8a34
4 changed files with 249 additions and 1 deletions

View File

@ -1,11 +1,19 @@
hostname r1 hostname r1
router bgp 99
no bgp ebgp-requires-policy
address-family ipv4 unicast
redistribute connected
import vrf DONNA
!
!
router bgp 99 vrf DONNA router bgp 99 vrf DONNA
no bgp ebgp-requires-policy no bgp ebgp-requires-policy
address-family ipv4 unicast address-family ipv4 unicast
redistribute connected redistribute connected
import vrf EVA import vrf EVA
import vrf NOTEXISTING import vrf NOTEXISTING
import vrf default
! !
! !
router bgp 99 vrf EVA router bgp 99 vrf EVA

View File

@ -1,5 +1,9 @@
hostname r1 hostname r1
int dummy0
ip address 10.0.4.1/24
no shut
!
int dummy1 int dummy1
ip address 10.0.0.1/24 ip address 10.0.0.1/24
no shut no shut

View File

@ -3,6 +3,7 @@
ip link add DONNA type vrf table 1001 ip link add DONNA type vrf table 1001
ip link add EVA type vrf table 1002 ip link add EVA type vrf table 1002
ip link add dummy0 type dummy # vrf default
ip link add dummy1 type dummy ip link add dummy1 type dummy
ip link add dummy2 type dummy ip link add dummy2 type dummy
ip link add dummy3 type dummy ip link add dummy3 type dummy

View File

@ -64,7 +64,7 @@ def teardown_module(mod):
tgen.stop_topology() tgen.stop_topology()
def test_vrf_route_leak(): def test_vrf_route_leak_donna():
logger.info("Ensure that routes are leaked back and forth") logger.info("Ensure that routes are leaked back and forth")
tgen = get_topogen() tgen = get_topogen()
# Don't run this test if we have any failure. # Don't run this test if we have any failure.
@ -109,6 +109,20 @@ def test_vrf_route_leak():
], ],
}, },
], ],
"10.0.4.0/24": [
{
"protocol": "bgp",
"selected": True,
"nexthops": [
{
"fib": True,
"interfaceName": "lo",
"vrf": "default",
"active": True,
},
],
},
],
"172.16.101.0/24": [ "172.16.101.0/24": [
{ {
"protocol": "bgp", "protocol": "bgp",
@ -129,6 +143,16 @@ def test_vrf_route_leak():
result, diff = topotest.run_and_expect(test_func, None, count=10, wait=0.5) result, diff = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
assert result, "BGP VRF DONNA check failed:\n{}".format(diff) assert result, "BGP VRF DONNA check failed:\n{}".format(diff)
def test_vrf_route_leak_eva():
logger.info("Ensure that routes are leaked back and forth")
tgen = get_topogen()
# Don't run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
r1 = tgen.gears["r1"]
# Test EVA VRF. # Test EVA VRF.
expect = { expect = {
"10.0.0.0/24": [ "10.0.0.0/24": [
@ -190,6 +214,217 @@ def test_vrf_route_leak():
assert result, "BGP VRF EVA check failed:\n{}".format(diff) assert result, "BGP VRF EVA check failed:\n{}".format(diff)
def test_vrf_route_leak_donna():
logger.info("Ensure that routes are leaked back and forth")
tgen = get_topogen()
# Don't run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
r1 = tgen.gears["r1"]
# Test DONNA VRF.
expect = {
"10.0.0.0/24": [
{
"protocol": "connected",
}
],
"10.0.1.0/24": [
{
"protocol": "bgp",
"selected": True,
"nexthops": [
{
"fib": True,
"interfaceName": "EVA",
"vrf": "EVA",
"active": True,
},
],
},
],
"10.0.2.0/24": [{"protocol": "connected"}],
"10.0.3.0/24": [
{
"protocol": "bgp",
"selected": True,
"nexthops": [
{
"fib": True,
"interfaceName": "EVA",
"vrf": "EVA",
"active": True,
},
],
},
],
"10.0.4.0/24": [
{
"protocol": "bgp",
"selected": True,
"nexthops": [
{
"fib": True,
"interfaceName": "lo",
"vrf": "default",
"active": True,
},
],
},
],
"172.16.101.0/24": [
{
"protocol": "bgp",
"nexthops": [
{
"interfaceIndex": 0,
"interfaceName": "unknown",
"vrf": "Unknown",
},
],
},
],
}
test_func = partial(
topotest.router_json_cmp, r1, "show ip route vrf DONNA json", expect
)
result, diff = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
assert result, "BGP VRF DONNA check failed:\n{}".format(diff)
def test_vrf_route_leak_eva():
logger.info("Ensure that routes are leaked back and forth")
tgen = get_topogen()
# Don't run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
r1 = tgen.gears["r1"]
# Test EVA VRF.
expect = {
"10.0.0.0/24": [
{
"protocol": "bgp",
"selected": True,
"nexthops": [
{
"fib": True,
"interfaceName": "DONNA",
"vrf": "DONNA",
"active": True,
},
],
},
],
"10.0.1.0/24": [
{
"protocol": "connected",
}
],
"10.0.2.0/24": [
{
"protocol": "bgp",
"selected": True,
"nexthops": [
{
"fib": True,
"interfaceName": "DONNA",
"vrf": "DONNA",
"active": True,
},
],
},
],
"10.0.3.0/24": [
{
"protocol": "connected",
}
],
"172.16.101.0/24": [
{
"protocol": "bgp",
"nexthops": [
{
"interfaceIndex": 0,
"interfaceName": "unknown",
"vrf": "Unknown",
},
],
},
],
}
def test_vrf_route_leak_default():
logger.info("Ensure that routes are leaked back and forth")
tgen = get_topogen()
# Don't run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
r1 = tgen.gears["r1"]
# Test default VRF.
expect = {
"10.0.0.0/24": [
{
"protocol": "bgp",
"selected": True,
"nexthops": [
{
"fib": True,
"interfaceName": "DONNA",
"vrf": "DONNA",
"active": True,
},
],
},
],
"10.0.2.0/24": [
{
"protocol": "bgp",
"selected": True,
"nexthops": [
{
"fib": True,
"interfaceName": "DONNA",
"vrf": "DONNA",
"active": True,
},
],
},
],
"10.0.4.0/24": [
{
"protocol": "connected",
}
],
}
test_func = partial(topotest.router_json_cmp, r1, "show ip route json", expect)
result, diff = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
assert result, "BGP VRF default check failed:\n{}".format(diff)
def test_ping():
"Simple ping tests"
tgen = get_topogen()
# Don't run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
r1 = tgen.gears["r1"]
logger.info("Ping from default to DONNA")
output = r1.run("ping -c 4 -w 4 -I 10.0.4.1 10.0.0.1")
assert " 0% packet loss" in output, "Ping default->DONNA FAILED"
def test_memory_leak(): def test_memory_leak():
"Run the memory leak test and report results." "Run the memory leak test and report results."
tgen = get_topogen() tgen = get_topogen()