]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: Add test case to verify `no static-sids` command
authorCarmine Scarpitta <cscarpit@cisco.com>
Wed, 26 Feb 2025 14:36:00 +0000 (15:36 +0100)
committerCarmine Scarpitta <cscarpit@cisco.com>
Thu, 27 Feb 2025 11:17:26 +0000 (12:17 +0100)
Add a test case to verify that staticd removes all SIDs when the
`no static-sids` command is executed.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
tests/topotests/static_srv6_sids/expected_srv6_sids_delete_all.json [new file with mode: 0644]
tests/topotests/static_srv6_sids/test_static_srv6_sids.py

diff --git a/tests/topotests/static_srv6_sids/expected_srv6_sids_delete_all.json b/tests/topotests/static_srv6_sids/expected_srv6_sids_delete_all.json
new file mode 100644 (file)
index 0000000..9e26dfe
--- /dev/null
@@ -0,0 +1 @@
+{}
\ No newline at end of file
index cdcc6fd29e3ed90023324f2b889e7b226af6abbf..8f38fd55dd4ccb270692e26d376e5f8d87552599 100755 (executable)
@@ -172,6 +172,43 @@ def test_srv6_static_sids_sid_readd():
     check_srv6_static_sids(router, "expected_srv6_sids.json")
 
 
+def test_srv6_static_sids_sid_delete_all():
+    """
+    Remove all static SIDs and verify they get removed
+    """
+    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, exact=True)
+
+    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
+           no static-sids
+        """
+    )
+
+    # 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_delete_all.json")
+
+
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]
     sys.exit(pytest.main(args))