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 1ba2320 commit 2e9ddac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
3 changes: 0 additions & 3 deletions tests/topotests/bgp_gr_restart_retain_routes/r2/zebra.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
!
interface lo
ip address 172.16.255.2/32
!
interface r2-eth0
ip address 192.168.255.2/24
!
Expand Down
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 2e9ddac

Please sign in to comment.