]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: Add test case to verify that SIDs can be re-added
authorCarmine Scarpitta <cscarpit@cisco.com>
Wed, 26 Feb 2025 14:38:06 +0000 (15:38 +0100)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Fri, 28 Feb 2025 14:16:16 +0000 (14:16 +0000)
Add a test case to verify that staticd is able to re-install all SIDs
after deleting and re-adding them.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
(cherry picked from commit 641f0c6deb483c78a5cf2d69ec5335e5d4e498a5)

tests/topotests/static_srv6_sids/test_static_srv6_sids.py

index 8f38fd55dd4ccb270692e26d376e5f8d87552599..4bed5bf788c42bd70b2d4bbb29d7504b2fb7fac7 100755 (executable)
@@ -209,6 +209,48 @@ def test_srv6_static_sids_sid_delete_all():
     check_srv6_static_sids(router, "expected_srv6_sids_delete_all.json")
 
 
+def test_srv6_static_sids_sid_readd_all():
+    """
+    Re-add the static SIDs and verify the routing table
+    """
+    tgen = get_topogen()
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+    router = tgen.gears["r1"]
+
+    def _check_srv6_static_sids(router, expected_route_file):
+        logger.info("checking zebra srv6 static sids")
+        output = json.loads(router.vtysh_cmd("show ipv6 route static json"))
+        expected = open_json_file("{}/{}".format(CWD, expected_route_file))
+        return topotest.json_cmp(output, expected)
+
+    def check_srv6_static_sids(router, expected_file):
+        func = functools.partial(_check_srv6_static_sids, router, expected_file)
+        _, result = topotest.run_and_expect(func, None, count=15, wait=1)
+        assert result is None, "Failed"
+
+    router.vtysh_cmd(
+        """
+        configure terminal
+         segment-routing
+          srv6
+           static-sids
+            sid fcbb:bbbb:1::/48 locator MAIN behavior uN
+            sid fcbb:bbbb:1:fe10::/64 locator MAIN behavior uDT4 vrf Vrf10
+            sid fcbb:bbbb:1:fe20::/64 locator MAIN behavior uDT6 vrf Vrf20
+            sid fcbb:bbbb:1:fe30::/64 locator MAIN behavior uDT46 vrf Vrf30
+            sid fcbb:bbbb:1:fe40::/64 locator MAIN behavior uA interface sr0 nexthop 2001::2
+        """
+    )
+
+    # FOR DEVELOPER:
+    # If you want to stop some specific line and start interactive shell,
+    # please use tgen.mininet_cli() to start it.
+
+    logger.info("Test for srv6 sids configuration")
+    check_srv6_static_sids(router, "expected_srv6_sids.json")
+
+
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]
     sys.exit(pytest.main(args))