From a92a2683a316e9029d6f858f961a281a6caf6696 Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Thu, 8 Jun 2023 12:52:44 +0200 Subject: [PATCH] topotests: filter out void RD in bgp_vpnv4_noretain Filter out route-distinguishers that have no prefix in "show bgp table json" Signed-off-by: Louis Scalbert --- .../r1/ipv4_vpn_routes_no_retain_init.json | 2 -- .../bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_no_retain_init.json b/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_no_retain_init.json index 261dec9f9f..855ae1c2c9 100644 --- a/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_no_retain_init.json +++ b/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_no_retain_init.json @@ -60,8 +60,6 @@ ] } ] - }, - "192.0.2.2:2":{ } } } diff --git a/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py b/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py index 979cebf6ae..9d48daa588 100644 --- a/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py +++ b/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py @@ -17,6 +17,7 @@ import os import sys import json from functools import partial +from copy import deepcopy import pytest # Save the Current Working Directory to find configuration files. @@ -138,6 +139,12 @@ def router_json_cmp_exact_filter(router, cmd, expected): if "version" in attr: attr.pop("version") + # filter out RD with no data (e.g. "444:3": {}) + json_tmp = deepcopy(json_output) + for rd, data in json_tmp["routes"]["routeDistinguishers"].items(): + if len(data.keys()) == 0: + json_output["routes"]["routeDistinguishers"].pop(rd) + return topotest.json_cmp(json_output, expected, exact=True) -- 2.39.5