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
+ output = json.loads(r2.cmd("ip -j route show 172.16.255.1/32 proto bgp dev r2-eth0"))
+ expected = [{"dst":"172.16.255.1","gateway":"192.168.255.1","metric":20}]
+ return topotest.json_cmp(output, expected)
step("Initial BGP converge")
test_func = functools.partial(_bgp_converge)
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
+ assert _bgp_check_kernel_retained_routes() is None, "Failed to retain BGP routes in kernel on R2"
if __name__ == "__main__":