]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: add rtadv topotest
authorDmytro Shytyi <dmytro.shytyi@6wind.com>
Mon, 10 Mar 2025 18:03:07 +0000 (19:03 +0100)
committerDmytro Shytyi <dmytro.shytyi@6wind.com>
Mon, 17 Mar 2025 10:33:09 +0000 (11:33 +0100)
Verify the new rtadv "show interface json" fields
The rtadv json parameters should not be present
when bgp instance is disabled.

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
tests/topotests/bgp_vpn_5549_route_map/test_bgp_vpn_5549_route_map.py

index 08d6e140a141dacf6a497aa7c1e9d017e7d8cc63..93764642d85ba2cee1c2318ebc96214e6f4206af 100644 (file)
@@ -165,6 +165,131 @@ def test_bgp_vpn_5549():
     assert result is None, "IPv6 nexthop is invalid"
 
 
+def check_show_interface_rtadv_params_found(router):
+    output = json.loads(router.vtysh_cmd("show interface json"))
+    expected = {
+        "pe1-eth1": {
+            "ndAdvertisedReachableTimeMsecs": 0,
+            "ndAdvertisedRetransmitIntervalMsecs": 0,
+            "ndAdvertisedHopCountLimitHops": 64,
+            "ndRouterAdvertisementsIntervalSecs": 10,
+            "ndRouterAdvertisementsDoNotUseFastRetransmit": False,
+            "ndRouterAdvertisementsLifetimeTracksRaInterval": True,
+            "ndRouterAdvertisementDefaultRouterPreference": "medium",
+            "hostsUseStatelessAutoconfigForAddresses": True,
+        }
+    }
+    return topotest.json_cmp(output, expected)
+
+
+def test_show_interface_rtadv_params_found():
+    tgen = get_topogen()
+
+    router = tgen.gears["pe1"]
+    test_func = functools.partial(check_show_interface_rtadv_params_found, router)
+    success, _ = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+    assert success, "rtadv output is invalid"
+
+
+def check_show_interface_rtadv_params_not_found(router):
+    output = json.loads(router.vtysh_cmd("show interface json"))
+    expected = {
+        "pe1-eth1": {
+            "ndAdvertisedReachableTimeMsecs": 0,
+            "ndAdvertisedRetransmitIntervalMsecs": 0,
+        }
+    }
+
+    ret = topotest.json_cmp(output, expected)
+    if ret is None:
+        return "Unexpected: interface rtadv parameters found"
+    return None
+
+
+def test_show_interface_rtadv_params_not_found():
+    tgen = get_topogen()
+
+    router = tgen.gears["pe1"]
+    router.vtysh_cmd(
+        "configure \n \
+        router bgp 65001 \n \
+        no neighbor 2001:db8:1::2 \n \
+        exit \n \
+        exit"
+    )
+
+    test_func = functools.partial(check_show_interface_rtadv_params_not_found, router)
+    success, _ = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+    assert success, "not good"
+
+
+def check_show_interface_rtadv_params_found_reapply(router):
+    output = json.loads(router.vtysh_cmd("show interface json"))
+    expected = {
+        "pe1-eth1": {
+            "ndAdvertisedReachableTimeMsecs": 0,
+            "ndAdvertisedRetransmitIntervalMsecs": 0,
+        }
+    }
+    return topotest.json_cmp(output, expected)
+
+
+def test_show_interface_rtadv_params_found_reapply():
+    tgen = get_topogen()
+
+    router = tgen.gears["pe1"]
+    router.vtysh_cmd(
+        "configure \n \
+            router bgp 65001 \n \
+            neighbor 2001:db8:1::2 remote-as internal \n \
+            neighbor 2001:db8:1::2 update-source 2001:db8:1::1 \n \
+            neighbor 2001:db8:1::2 timers 1 3 \n \
+            neighbor 2001:db8:1::2 timers connect 1 \n \
+            neighbor 2001:db8:1::2 capability extended-nexthop \n \
+            exit \n \
+            exit"
+    )
+
+    test_func = functools.partial(
+        check_show_interface_rtadv_params_found_reapply, router
+    )
+    success, _ = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+    assert success, "rtadv output is invalid"
+
+
+def check_show_interface_rtadv_params_not_found_after_reapply(router):
+    output = json.loads(router.vtysh_cmd("show interface json"))
+
+    expected = {
+        "pe1-eth1": {
+            "ndAdvertisedReachableTimeMsecs": 0,
+            "ndAdvertisedRetransmitIntervalMsecs": 0,
+        }
+    }
+
+    ret = topotest.json_cmp(output, expected)
+    if ret is None:
+        return "Unexpected: interface rtadv parameters found"
+    return None
+
+
+def test_show_interface_rtadv_params_not_found_after_reapply():
+    tgen = get_topogen()
+
+    router = tgen.gears["pe1"]
+    router.vtysh_cmd(
+        "configure \n \
+            no router bgp 65001 vrf RED \n \
+            no router bgp 65001 \n \
+            exit"
+    )
+    test_func = functools.partial(
+        check_show_interface_rtadv_params_not_found_after_reapply, router
+    )
+    success, _ = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+    assert success, "not good"
+
+
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]
     sys.exit(pytest.main(args))