]> git.puffer.fish Git - matthieu/frr.git/commitdiff
topotests: fix bgp_vpnv[4,6]_per_nexthop prefix not updated
authorPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 2 Oct 2023 19:17:20 +0000 (21:17 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 18 Oct 2023 07:41:02 +0000 (09:41 +0200)
The bgp_vpnv[4,6]_table_check() functions analyze the
expected label value of VPN prefixes present in the BGP table.
However, it doesn't verify if the prefixes exist before doing
this. Consequently, the tests will fail if the prefixes do not
show up immediately.
Ensure that all expected VPN prefixes are present before
executing the function.

Fixes: ae5a6bc1f6ba ("topotests: add bgp mpls allocation per next-hop test")
Fixes: 37a02a8dcb0d ("topotests: add bgp_vpnv6 test allocation")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
tests/topotests/bgp_vpnv4_per_nexthop_label/test_bgp_vpnv4_per_nexthop_label.py
tests/topotests/bgp_vpnv6_per_nexthop_label/test_bgp_vpnv6_per_nexthop_label.py

index ce278ed7a7e81334cc603c7f08d8afa649b0b843..d4c355a44a1d092225972dffab33bcece8befd8b 100644 (file)
@@ -151,6 +151,16 @@ def teardown_module(_mod):
     tgen.stop_topology()
 
 
+def check_bgp_vpnv4_prefix_presence(router, prefix):
+    "Check the presence of a prefix"
+    tgen = get_topogen()
+
+    dump = router.vtysh_cmd("show bgp ipv4 vpn {} json".format(prefix), isjson=True)
+    if not dump:
+        return "{}, prefix ipv4 vpn {} is not installed yet".format(router.name, prefix)
+    return None
+
+
 def bgp_vpnv4_table_check(router, group, label_list=None, label_value_expected=None):
     """
     Dump and check that vpnv4 entries have the same MPLS label value
@@ -163,6 +173,12 @@ def bgp_vpnv4_table_check(router, group, label_list=None, label_value_expected=N
 
     stored_label_inited = False
     for prefix in group:
+        test_func = functools.partial(check_bgp_vpnv4_prefix_presence, router, prefix)
+        success, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
+        assert success, "{}, prefix ipv4 vpn {} is not installed yet".format(
+            router.name, prefix
+        )
+
         dump = router.vtysh_cmd("show bgp ipv4 vpn {} json".format(prefix), isjson=True)
         assert dump, "{0}, {1}, route distinguisher not present".format(
             router.name, prefix
index e936ccc1e44424a088ef39d8917c97976204c859..3d5f8f643bc67da06ad1b349aa9efdd91390960d 100644 (file)
@@ -54,7 +54,7 @@ pytestmark = [pytest.mark.bgpd]
 PREFIXES_R11 = ["172:31::11/128", "172:31::20/128", "172:31::111/128"]
 PREFIXES_R12 = ["172:31::12/128", "172:31::15/128"]
 PREFIXES_REDIST_R14 = ["172:31::14/128"]
-PREFIXES_CONNECTED = ["192:168::255/112", "192:2::/64"]
+PREFIXES_CONNECTED = ["192:168::255:0/112", "192:2::/64"]
 
 
 def build_topo(tgen):
@@ -150,6 +150,16 @@ def teardown_module(_mod):
     tgen.stop_topology()
 
 
+def check_bgp_vpnv6_prefix_presence(router, prefix):
+    "Check the presence of a prefix"
+    tgen = get_topogen()
+
+    dump = router.vtysh_cmd("show bgp ipv6 vpn {} json".format(prefix), isjson=True)
+    if not dump:
+        return "{}, prefix ipv6 vpn {} is not installed yet".format(router.name, prefix)
+    return None
+
+
 def bgp_vpnv6_table_check(router, group, label_list=None, label_value_expected=None):
     """
     Dump and check that vpnv6 entries have the same MPLS label value
@@ -162,6 +172,12 @@ def bgp_vpnv6_table_check(router, group, label_list=None, label_value_expected=N
 
     stored_label_inited = False
     for prefix in group:
+        test_func = functools.partial(check_bgp_vpnv6_prefix_presence, router, prefix)
+        success, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
+        assert success, "{}, prefix ipv6 vpn {} is not installed yet".format(
+            router.name, prefix
+        )
+
         dump = router.vtysh_cmd("show bgp ipv6 vpn {} json".format(prefix), isjson=True)
         for rd, pathes in dump.items():
             for path in pathes["paths"]:
@@ -237,7 +253,9 @@ def check_show_mpls_table(router, blacklist=None, label_list=None, whitelist=Non
             label_list.add(in_label)
         for nh in label_info["nexthops"]:
             if "installed" not in nh.keys():
-                return "{} {} is not installed yet on {}".format(in_label, label_info, router.name)
+                return "{} {} is not installed yet on {}".format(
+                    in_label, label_info, router.name
+                )
             if nh["installed"] != True or nh["type"] != "BGP":
                 return "{}, show mpls table, nexthop is not installed".format(
                     router.name