]> git.proxmox.com Git - mirror_frr.git/blobdiff - tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / tests / topotests / bgp_vpnv4_noretain / test_bgp_vpnv4_noretain.py
index ed5cc3faf66187ce950daf74f96e56ded3b04153..9b8ae4b7e3303736e46b2d07007156d0f8040407 100644 (file)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# SPDX-License-Identifier: ISC
 
 #
 # test_bgp_vpnv4_noretain.py
@@ -6,20 +7,6 @@
 #
 # Copyright 2022 6WIND S.A.
 #
-# Permission to use, copy, modify, and/or distribute this software
-# for any purpose with or without fee is hereby granted, provided
-# that the above copyright notice and this permission notice appear
-# in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
-# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
-# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
-# OF THIS SOFTWARE.
-#
 
 """
  test_bgp_vpnv4_noretain.py: Do not keep the VPNvx entries when no
@@ -134,12 +121,21 @@ def teardown_module(_mod):
 
 
 def router_json_cmp_exact_filter(router, cmd, expected):
-    # filter out tableVersion, version and nhVrfID
-    output = router.cmd('vtysh -c "{}" | grep -v ersion | grep -v nhVrfId'.format(cmd))
+    output = router.vtysh_cmd(cmd)
     logger.info("{}: {}\n{}".format(router.name, cmd, output))
 
     json_output = json.loads(output)
 
+    # filter out tableVersion, version and nhVrfID
+    json_output.pop("tableVersion")
+    for rd, data in json_output["routes"]["routeDistinguishers"].items():
+        for prefix, attrs in data.items():
+            for attr in attrs:
+                if "nhVrfId" in attr:
+                    attr.pop("nhVrfId")
+                if "version" in attr:
+                    attr.pop("version")
+
     return topotest.json_cmp(json_output, expected, exact=True)