]> git.puffer.fish Git - mirror/frr.git/commitdiff
topotests: add ability to check that a prefix is not in BGP RIB
authorLouis Scalbert <louis.scalbert@6wind.com>
Thu, 12 May 2022 12:54:32 +0000 (14:54 +0200)
committerLouis Scalbert <louis.scalbert@6wind.com>
Fri, 16 Dec 2022 14:07:54 +0000 (15:07 +0100)
Add an "exist" key to check the existence of a prefix in the BGP RIB.
Useful to check that a prefix has not leaked by error.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
tests/topotests/lib/bgprib.py

index 35a57d0a9991214c8253c0dee990b02fcfaec729..ced6dd7de3022e71eed97280bf12ce8979cdaf51 100644 (file)
@@ -48,7 +48,15 @@ class BgpRib:
         for pfx in pfxtbl.keys():
             if debug:
                 self.log("trying pfx %s" % pfx)
-            if pfx != want["p"]:
+            if "exist" in want and want["exist"] == False:
+                if pfx == want["p"]:
+                    if debug:
+                        self.log("unexpected route: pfx=" + want["p"])
+                    return 0
+                if debug:
+                    self.log("unwant pfx=" + want["p"] + ", not " + pfx)
+                continue
+            elif pfx != want["p"]:
                 if debug:
                     self.log("want pfx=" + want["p"] + ", not " + pfx)
                 continue
@@ -75,6 +83,9 @@ class BgpRib:
             if debug:
                 self.log("missing route: pfx=" + want["p"] + ", nh=" + want["n"])
             return 0
+        if "exist" in want and want["exist"] == False:
+            return 1
+        return 0
 
     def RequireVpnRoutes(self, target, title, wantroutes, debug=0):
         import json