Skip to content

Commit

Permalink
tests: Check if the routes in the kernel are retained for GR as well
Browse files Browse the repository at this point in the history
Not only in BGP table.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
  • Loading branch information
ton31337 committed Sep 30, 2022
1 parent 95098d9 commit 18e427b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
2 changes: 0 additions & 2 deletions tests/topotests/bgp_gr_restart_retain_routes/r1/zebra.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ interface lo
interface r1-eth0
ip address 192.168.255.1/24
!
ip forwarding
!
3 changes: 0 additions & 3 deletions tests/topotests/bgp_gr_restart_retain_routes/r2/bgpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ router bgp 65002
neighbor 192.168.255.1 remote-as external
neighbor 192.168.255.1 timers 1 3
neighbor 192.168.255.1 timers connect 1
address-family ipv4
redistribute connected
exit-address-family
!
5 changes: 0 additions & 5 deletions tests/topotests/bgp_gr_restart_retain_routes/r2/zebra.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
!
interface lo
ip address 172.16.255.2/32
!
interface r2-eth0
ip address 192.168.255.2/24
!
ip forwarding
!
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,25 @@ def _bgp_converge():
}
return topotest.json_cmp(output, expected)

def _bgp_check_retained_routes():
def _bgp_check_bgp_retained_routes():
output = json.loads(r2.vtysh_cmd("show bgp ipv4 unicast 172.16.255.1/32 json"))
expected = {"paths": [{"stale": True}]}
return topotest.json_cmp(output, expected)

def _bgp_check_kernel_retained_routes():
output = (
r2.cmd("ip route show 172.16.255.1/32 proto bgp dev r2-eth0")
.replace("\n", "")
.rstrip()
)
expected = "172.16.255.1 via 192.168.255.1 metric 20"
diff = topotest.get_textdiff(
output, expected, "Actual IP Routing Table", "Expected IP RoutingTable"
)
if diff:
return False
return True

step("Initial BGP converge")
test_func = functools.partial(_bgp_converge)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
Expand All @@ -103,11 +117,14 @@ def _bgp_check_retained_routes():
step("Restart R1")
stop_router(tgen, "r1")

step("Check if routes are retained at R2")
test_func = functools.partial(_bgp_check_retained_routes)
step("Check if routes (BGP) are retained at R2")
test_func = functools.partial(_bgp_check_bgp_retained_routes)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
assert result is None, "Failed to see BGP retained routes on R2"

step("Check if routes (Kernel) are retained at R2")
assert _bgp_check_kernel_retained_routes() == True


if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
Expand Down

0 comments on commit 18e427b

Please sign in to comment.