diff options
| author | anlan_cs <anlan_cs@126.com> | 2024-11-01 15:16:09 +0800 | 
|---|---|---|
| committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2024-11-05 15:22:24 +0000 | 
| commit | ac1bd83312d675fa567cbf7f574d2073a41cd474 (patch) | |
| tree | f59e82b7c5a7ff0e3e0bfd75602970a7def54409 | |
| parent | 3cb4dcda5cd000d3108db67414f83e58638d62d0 (diff) | |
test: add test case for kernel blackhole routes
The test verifies that a kernel blackhole route is not affected by
interface's link change.
Signed-off-by: anlan_cs <anlan_cs@126.com>
(cherry picked from commit 0073a870d1b769e96b4f23d0422914200591062e)
| -rw-r--r-- | tests/topotests/zebra_multiple_connected/r1/ip_route_kernel_blackhole.json | 24 | ||||
| -rw-r--r-- | tests/topotests/zebra_multiple_connected/test_zebra_multiple_connected.py | 21 | 
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/topotests/zebra_multiple_connected/r1/ip_route_kernel_blackhole.json b/tests/topotests/zebra_multiple_connected/r1/ip_route_kernel_blackhole.json new file mode 100644 index 0000000000..c8ea930370 --- /dev/null +++ b/tests/topotests/zebra_multiple_connected/r1/ip_route_kernel_blackhole.json @@ -0,0 +1,24 @@ +{ +  "0.0.0.0/0":[ +    { +      "prefix":"0.0.0.0/0", +      "prefixLen":0, +      "protocol":"kernel", +      "vrfName":"default", +      "selected":true, +      "destSelected":true, +      "distance":0, +      "metric":0, +      "installed":true, +      "table":254, +      "nexthops":[ +        { +          "fib":true, +          "unreachable":true, +          "blackhole":true, +          "active":true +        } +      ] +    } +  ] +} diff --git a/tests/topotests/zebra_multiple_connected/test_zebra_multiple_connected.py b/tests/topotests/zebra_multiple_connected/test_zebra_multiple_connected.py index 7dbeb6f1cc..eda8c88706 100644 --- a/tests/topotests/zebra_multiple_connected/test_zebra_multiple_connected.py +++ b/tests/topotests/zebra_multiple_connected/test_zebra_multiple_connected.py @@ -202,6 +202,27 @@ def test_zebra_kernel_route_add():      assert result, "Connected Route should have been added\n{}".format(_) +def test_zebra_kernel_route_blackhole_add(): +    "Test that a blackhole route is not affected by interface's link change" + +    tgen = get_topogen() +    if tgen.routers_have_failure(): +        pytest.skip(tgen.errors) + +    router = tgen.gears["r1"] +    router.run("ip route add blackhole default") +    router.run("ip link set dev r1-eth1 down") + +    kernel = "{}/{}/ip_route_kernel_blackhole.json".format(CWD, router.name) +    expected = json.loads(open(kernel).read()) + +    test_func = partial( +        topotest.router_json_cmp, router, "show ip route 0.0.0.0/0 json", expected +    ) +    result, _ = topotest.run_and_expect(test_func, None, count=20, wait=1) +    assert result, "Blackhole Route should have not been removed\n{}".format(_) + +  if __name__ == "__main__":      args = ["-s"] + sys.argv[1:]      sys.exit(pytest.main(args))  | 
