From 4fbd10131980754a190d4c10fad67d1ccf269cb4 Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Mon, 23 Sep 2024 17:57:49 +0200 Subject: [PATCH] tests: zebra_rib, test vrf change Test table ID move to a VRF and the removal of the VRF. Signed-off-by: Louis Scalbert --- .../zebra_rib/r1/v4_route_table_1_no_vrf.json | 32 ++++++++++++++++++ .../zebra_rib/r1/v4_route_table_1_no_vrf.txt | 2 ++ .../r1/v4_route_table_1_vrf_red.json | 33 +++++++++++++++++++ .../zebra_rib/r1/v4_route_table_1_vrf_red.txt | 2 ++ tests/topotests/zebra_rib/test_zebra_rib.py | 10 ++++++ 5 files changed, 79 insertions(+) diff --git a/tests/topotests/zebra_rib/r1/v4_route_table_1_no_vrf.json b/tests/topotests/zebra_rib/r1/v4_route_table_1_no_vrf.json index 5190dc469ce1..70398d80b1a1 100644 --- a/tests/topotests/zebra_rib/r1/v4_route_table_1_no_vrf.json +++ b/tests/topotests/zebra_rib/r1/v4_route_table_1_no_vrf.json @@ -15,6 +15,38 @@ ] } ], + "10.0.0.0/24": [ + { + "protocol": "static", + "vrfName": "default", + "installed": true, + "table": 1, + "nexthops": [ + { + "fib": true, + "unreachable": true, + "blackhole": true, + "active": true + } + ] + } + ], + "10.1.0.0/24": [ + { + "protocol": "static", + "vrfName": "default", + "installed": true, + "table": 1, + "nexthops": [ + { + "fib": true, + "ip": "192.168.211.254", + "interfaceName": "r1-eth1", + "active": true + } + ] + } + ], "10.2.0.0/24": null, "10.3.0.0/24": null, "192.168.210.0/24": null, diff --git a/tests/topotests/zebra_rib/r1/v4_route_table_1_no_vrf.txt b/tests/topotests/zebra_rib/r1/v4_route_table_1_no_vrf.txt index 0664cab2d832..f0fcb73d4d68 100644 --- a/tests/topotests/zebra_rib/r1/v4_route_table_1_no_vrf.txt +++ b/tests/topotests/zebra_rib/r1/v4_route_table_1_no_vrf.txt @@ -1 +1,3 @@ blackhole default +blackhole 10.0.0.0/24 proto XXXX metric 20 +10.1.0.0/24 via 192.168.211.254 dev r1-eth1 proto XXXX metric 20 diff --git a/tests/topotests/zebra_rib/r1/v4_route_table_1_vrf_red.json b/tests/topotests/zebra_rib/r1/v4_route_table_1_vrf_red.json index f1dad10ab2bb..5949a69a7353 100644 --- a/tests/topotests/zebra_rib/r1/v4_route_table_1_vrf_red.json +++ b/tests/topotests/zebra_rib/r1/v4_route_table_1_vrf_red.json @@ -15,6 +15,39 @@ ] } ], + "10.0.0.0/24": [ + { + "protocol": "static", + "vrfName": "RED", + "installed": true, + "table": 1, + "nexthops": [ + { + "fib": true, + "unreachable": true, + "blackhole": true, + "active": true + } + ] + } + ], + "10.1.0.0/24": [ + { + "protocol": "static", + "vrfName": "RED", + "installed": true, + "table": 1, + "nexthops": [ + { + "fib": true, + "ip": "192.168.211.254", + "interfaceName": "r1-eth1", + "vrf": "default", + "active": true + } + ] + } + ], "10.2.0.0/24": [ { "protocol": "static", diff --git a/tests/topotests/zebra_rib/r1/v4_route_table_1_vrf_red.txt b/tests/topotests/zebra_rib/r1/v4_route_table_1_vrf_red.txt index 2053fa2bbeb6..fb3d0346894d 100644 --- a/tests/topotests/zebra_rib/r1/v4_route_table_1_vrf_red.txt +++ b/tests/topotests/zebra_rib/r1/v4_route_table_1_vrf_red.txt @@ -1,4 +1,6 @@ blackhole default +blackhole 10.0.0.0/24 proto XXXX metric 20 +10.1.0.0/24 via 192.168.211.254 dev r1-eth1 proto XXXX metric 20 10.2.0.0/24 via 192.168.210.254 dev r1-eth0 proto XXXX metric 20 10.3.0.0/24 via 192.168.212.254 dev r1-eth2 proto XXXX metric 20 192.168.210.0/24 dev r1-eth0 proto XXXX scope link src 192.168.210.1 diff --git a/tests/topotests/zebra_rib/test_zebra_rib.py b/tests/topotests/zebra_rib/test_zebra_rib.py index 810a46bd8b3c..6dc316752abd 100644 --- a/tests/topotests/zebra_rib/test_zebra_rib.py +++ b/tests/topotests/zebra_rib/test_zebra_rib.py @@ -139,6 +139,16 @@ def test_zebra_kernel_route_vrf(): step("Add routes in table 1") r1.run("ip route add blackhole default table {}".format(table_id)) + r1.vtysh_cmd( + """ +configure terminal + ip route 10.0.0.0/24 blackhole table {} + ip route 10.1.0.0/24 192.168.211.254 nexthop-vrf default table {} +""".format( + table_id, table_id + ) + ) + json_file = "{}/r1/v4_route_table_1_no_vrf.json".format(CWD) expected = json.loads(open(json_file).read()) test_func = partial(