Skip to content

Commit

Permalink
tests: Add IPv6 network adv/withdraw case in bgp_evpn_rt5 topotest
Browse files Browse the repository at this point in the history
Note that withdrawing IPv6 route should not affect IPv4.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
  • Loading branch information
leonshaw committed Nov 20, 2023
1 parent dbf7836 commit 9cb30d1
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/topotests/bgp_evpn_rt5/r1/bgpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ router bgp 65000 vrf r1-vrf-101
address-family ipv4 unicast
network 192.168.102.21/32
exit-address-family
address-family ipv6 unicast
network fd00::1/128
exit-address-family
address-family l2vpn evpn
advertise ipv4 unicast
advertise ipv6 unicast
exit-address-family
!
1 change: 1 addition & 0 deletions tests/topotests/bgp_evpn_rt5/r1/zebra.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface r1-eth0
!
interface loop101 vrf r1-vrf-101
ip address 192.168.102.21/32
ipv6 address fd00::1/128
!


4 changes: 4 additions & 0 deletions tests/topotests/bgp_evpn_rt5/r2/bgpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ router bgp 65000 vrf r2-vrf-101
address-family ipv4 unicast
network 192.168.101.41/32
exit-address-family
address-family ipv6 unicast
network fd00::2/128
exit-address-family
address-family l2vpn evpn
advertise ipv4 unicast
advertise ipv6 unicast
exit-address-family
!
1 change: 1 addition & 0 deletions tests/topotests/bgp_evpn_rt5/r2/zebra.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ vrf r2-vrf-101
!
interface loop101 vrf r2-vrf-101
ip address 192.168.101.41/32
ipv6 address fd00::2/128
!
interface r2-eth0
ip address 192.168.100.41/24
Expand Down
64 changes: 63 additions & 1 deletion tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib import topotest
from lib.bgp import verify_bgp_rib
from lib.common_config import apply_raw_config
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger

Expand Down Expand Up @@ -178,20 +180,26 @@ def test_protocols_convergence():
output = tgen.gears["r1"].vtysh_cmd("show bgp vrf r1-vrf-101 ipv4", isjson=False)
logger.info("==== result from show bgp vrf r1-vrf-101 ipv4")
logger.info(output)
output = tgen.gears["r1"].vtysh_cmd("show bgp vrf r1-vrf-101 ipv6", isjson=False)
logger.info("==== result from show bgp vrf r1-vrf-101 ipv6")
logger.info(output)
output = tgen.gears["r1"].vtysh_cmd("show bgp vrf r1-vrf-101", isjson=False)
logger.info("==== result from show bgp vrf r1-vrf-101 ")
logger.info(output)
output = tgen.gears["r1"].vtysh_cmd("show ip route vrf r1-vrf-101", isjson=False)
logger.info("==== result from show ip route vrf r1-vrf-101")
logger.info(output)
output = tgen.gears["r1"].vtysh_cmd("show ipv6 route vrf r1-vrf-101", isjson=False)
logger.info("==== result from show ipv6 route vrf r1-vrf-101")
logger.info(output)
output = tgen.gears["r1"].vtysh_cmd("show evpn vni detail", isjson=False)
logger.info("==== result from show evpn vni detail")
logger.info(output)
output = tgen.gears["r1"].vtysh_cmd("show evpn next-hops vni all", isjson=False)
logger.info("==== result from show evpn next-hops vni all")
logger.info(output)
output = tgen.gears["r1"].vtysh_cmd("show evpn rmac vni all", isjson=False)
logger.info("==== result from show evpn next-hops vni all")
logger.info("==== result from show evpn rmac vni all")
logger.info(output)
# Check IPv4 and IPv6 connectivity between r1 and r2 ( routing vxlan evpn)
pingrouter = tgen.gears["r1"]
Expand All @@ -208,6 +216,60 @@ def test_protocols_convergence():
else:
logger.info("Check Ping IPv4 from R1(r1-vrf-101) to R2(192.168.101.41) OK")

logger.info("Check Ping IPv6 from R1(r1-vrf-101) to R2(r2-vrf-101 = fd00::2)")
output = pingrouter.run("ip netns exec r1-vrf-101 ping fd00::2 -f -c 1000")
logger.info(output)
if "1000 packets transmitted, 1000 received" not in output:
assert 0, "expected ping IPv6 from R1(r1-vrf-101) to R2(fd00::2) should be ok"
else:
logger.info("Check Ping IPv6 from R1(r1-vrf-101) to R2(fd00::2) OK")

config_no_ipv6 = {
"r2": {
"raw_config": [
"router bgp 65000 vrf r2-vrf-101",
"address-family ipv6 unicast",
"no network fd00::2/128",
]
}
}

logger.info("==== Remove IPv6 network on R2")
result = apply_raw_config(tgen, config_no_ipv6)
assert result is True, "Failed to remove IPv6 network on R2, Error: {} ".format(
result
)
ipv6_routes = {
"r1": {
"static_routes": [
{
"vrf": "r1-vrf-101",
"network": ["fd00::2/128"],
},
],
},
}
result = verify_bgp_rib(tgen, "ipv6", "r1", ipv6_routes, expected=False)
assert result is not True, "expect IPv6 route fd00::2/128 withdrawn"
output = tgen.gears["r1"].vtysh_cmd("show evpn next-hops vni all", isjson=False)
logger.info("==== result from show evpn next-hops vni all")
logger.info(output)
output = tgen.gears["r1"].vtysh_cmd("show evpn rmac vni all", isjson=False)
logger.info("==== result from show evpn next-hops vni all")
logger.info(output)
logger.info(
"Check Ping IPv4 from R1(r1-vrf-101) to R2(r2-vrf-101 = 192.168.101.41)"
)
output = pingrouter.run("ip netns exec r1-vrf-101 ping 192.168.101.41 -f -c 1000")
logger.info(output)
if "1000 packets transmitted, 1000 received" not in output:
assertmsg = (
"expected ping IPv4 from R1(r1-vrf-101) to R2(192.168.101.41) should be ok"
)
assert 0, assertmsg
else:
logger.info("Check Ping IPv4 from R1(r1-vrf-101) to R2(192.168.101.41) OK")


def test_memory_leak():
"Run the memory leak test and report results."
Expand Down

0 comments on commit 9cb30d1

Please sign in to comment.