Skip to content

Commit

Permalink
tests: add an evpn RT5 path selection to bgp_path_selection
Browse files Browse the repository at this point in the history
Add an evpn RT5 path selection to bgp_path_selection

Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
louis-6wind committed Sep 26, 2023
1 parent c0a681e commit 820abf6
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 3 deletions.
15 changes: 14 additions & 1 deletion tests/topotests/bgp_path_selection/r1/bgpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ router bgp 65001
neighbor 192.0.2.2 activate
neighbor 192.0.2.3 activate
exit-address-family
address-family l2vpn evpn
neighbor 192.0.2.2 activate
neighbor 192.0.2.3 activate
advertise-all-vni
exit-address-family
!
router bgp 65001 vrf vrf1
bgp router-id 192.0.2.1
Expand All @@ -24,5 +29,13 @@ router bgp 65001 vrf vrf1
rt vpn both 52:100
import vpn
export vpn
!
router bgp 65001 vrf vrf2
bgp router-id 192.0.2.1
address-family ipv4 unicast
redistribute connected
address-family l2vpn evpn
autort rfc8365-compatible
rd 65001:100
exit-address-family
!
!
4 changes: 4 additions & 0 deletions tests/topotests/bgp_path_selection/r1/zebra.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
!
vrf vrf2
vni 100
exit-vrf
!
interface lo
ip address 192.0.2.1/32
ip address 172.16.255.1/32
Expand Down
17 changes: 16 additions & 1 deletion tests/topotests/bgp_path_selection/r2/bgpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ router bgp 65002
address-family ipv4 vpn
neighbor 192.168.1.1 activate
exit-address-family
address-family l2vpn evpn
neighbor 192.168.1.1 activate
advertise-all-vni
exit-address-family
!
router bgp 65002 vrf vrf1
bgp router-id 192.0.2.2
Expand All @@ -22,4 +26,15 @@ router bgp 65002 vrf vrf1
import vpn
export vpn
exit-address-family
!
!
router bgp 65002 vrf vrf2
bgp router-id 192.0.2.2
no bgp ebgp-requires-policy
address-family ipv4 unicast
redistribute connected
address-family l2vpn evpn
autort rfc8365-compatible
advertise ipv4 unicast
rd 65002:100
exit-address-family
!
4 changes: 4 additions & 0 deletions tests/topotests/bgp_path_selection/r2/zebra.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
!
vrf vrf2
vni 100
exit-vrf
!
int lo
ip address 192.0.2.2/32
!
Expand Down
17 changes: 16 additions & 1 deletion tests/topotests/bgp_path_selection/r3/bgpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ router bgp 65002
address-family ipv4 vpn
neighbor 192.168.2.1 activate
exit-address-family
address-family l2vpn evpn
neighbor 192.168.2.1 activate
advertise-all-vni
exit-address-family
!
router bgp 65002 vrf vrf1
bgp router-id 192.0.2.3
Expand All @@ -22,4 +26,15 @@ router bgp 65002 vrf vrf1
import vpn
export vpn
exit-address-family
!
!
router bgp 65002 vrf vrf2
bgp router-id 192.0.2.3
no bgp ebgp-requires-policy
address-family ipv4 unicast
redistribute connected
address-family l2vpn evpn
autort rfc8365-compatible
advertise ipv4 unicast
rd 65002:100
exit-address-family
!
4 changes: 4 additions & 0 deletions tests/topotests/bgp_path_selection/r3/zebra.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
!
vrf vrf2
vni 100
exit-vrf
!
int lo
ip address 192.0.2.3/32
!
Expand Down
112 changes: 112 additions & 0 deletions tests/topotests/bgp_path_selection/test_bgp_path_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,26 @@ def setup_module(mod):
tgen.gears["r{}".format(routern)].cmd("ip link add vrf1 type vrf table 10")
tgen.gears["r{}".format(routern)].cmd("ip link set vrf1 up")
tgen.gears["r{}".format(routern)].cmd("ip address add dev vrf1 {}.{}.{}.{}/32".format(routern, routern, routern,routern))
tgen.gears["r{}".format(routern)].cmd("ip link add vrf2 type vrf table 20")
tgen.gears["r{}".format(routern)].cmd("ip link set vrf2 up")
tgen.gears["r{}".format(routern)].cmd(
"ip address add dev vrf2 192.0.2.{}/32".format(routern)
)
tgen.gears["r{}".format(routern)].cmd("ip link add br1 type bridge")
tgen.gears["r{}".format(routern)].cmd(
"ip link add vxl1 type vxlan id 100 dev lo local 192.0.2.{}".format(routern)
)
tgen.gears["r{}".format(routern)].cmd("ip link set dev vxl1 master br1")
tgen.gears["r{}".format(routern)].cmd("ip link set dev br1 master vrf2")
tgen.gears["r{}".format(routern)].cmd("ip link set dev br1 up")
tgen.gears["r{}".format(routern)].cmd("ip link set dev vxl1 up")

tgen.gears["r2"].cmd("ip address add dev vrf1 192.0.2.8/32")
tgen.gears["r3"].cmd("ip address add dev vrf1 192.0.2.8/32")

tgen.gears["r2"].cmd("ip address add dev vrf2 192.0.4.8/32")
tgen.gears["r3"].cmd("ip address add dev vrf2 192.0.4.8/32")

for i, (rname, router) in enumerate(router_list.items(), 1):
router.load_config(
TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
Expand Down Expand Up @@ -144,6 +161,58 @@ def _bgp_check_path_selection_vpn_ecmp():
assert result is None, "Failed to see BGP prefixes on R1"


def test_bgp_path_selection_evpn_r5_ecmp():
tgen = get_topogen()

if tgen.routers_have_failure():
pytest.skip(tgen.errors)

def _bgp_check_path_selection_evpn_r5_ecmp():
output = json.loads(
tgen.gears["r1"].vtysh_cmd("show ip route vrf vrf2 192.0.4.8/32 json")
)
expected = {
"192.0.4.8/32": [
{
"prefix": "192.0.4.8/32",
"protocol": "bgp",
"vrfName": "vrf2",
"selected": True,
"installed": True,
"internalNextHopNum": 2,
"internalNextHopActiveNum": 2,
"nexthops": [
{
"fib": True,
"ip": "192.0.2.2",
"afi": "ipv4",
"interfaceName": "br1",
"active": True,
"onLink": True,
"weight": 1,
},
{
"fib": True,
"ip": "192.0.2.3",
"afi": "ipv4",
"interfaceName": "br1",
"active": True,
"onLink": True,
"weight": 1,
},
],
}
]
}

return topotest.json_cmp(output, expected)

step("Check if two ECMP paths are present")
test_func = functools.partial(_bgp_check_path_selection_evpn_r5_ecmp)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
assert result is None, "Failed to see BGP prefixes on R1"


def test_bgp_path_selection_metric():
tgen = get_topogen()

Expand Down Expand Up @@ -215,6 +284,49 @@ def _bgp_check_path_selection_vpn_metric():
assert result is None, "Failed to see BGP prefixes on R1"


def test_bgp_path_selection_evpn_r5_metric():
tgen = get_topogen()

if tgen.routers_have_failure():
pytest.skip(tgen.errors)

def _bgp_check_path_selection_evpn_r5_metric():
output = json.loads(
tgen.gears["r1"].vtysh_cmd("show ip route vrf vrf2 192.0.4.8/32 json")
)
expected = {
"192.0.4.8/32": [
{
"prefix": "192.0.4.8/32",
"protocol": "bgp",
"vrfName": "vrf2",
"selected": True,
"installed": True,
"internalNextHopNum": 1,
"internalNextHopActiveNum": 1,
"nexthops": [
{
"fib": True,
"ip": "192.0.2.2",
"afi": "ipv4",
"interfaceName": "br1",
"active": True,
"onLink": True,
"weight": 1,
}
],
}
]
}

return topotest.json_cmp(output, expected)

step("Check if IGP metric best path is selected")
test_func = functools.partial(_bgp_check_path_selection_evpn_r5_metric)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
assert result is None, "Failed to see BGP prefixes on R1"


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

0 comments on commit 820abf6

Please sign in to comment.