]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: fix bgp_bmp_vrf race condition 17226/head
authorLouis Scalbert <louis.scalbert@6wind.com>
Thu, 24 Oct 2024 15:18:55 +0000 (17:18 +0200)
committerLouis Scalbert <louis.scalbert@6wind.com>
Fri, 25 Oct 2024 12:17:20 +0000 (14:17 +0200)
The bgp_bmp_vrf topotest is randomly failing with similar messages:

> 2024-10-24 16:59:03,037 ERROR: topo: test failed at "bgp_bmp.test_bgp_bmp/test_bmp_bgp_unicast": Checking the updated prefixes has failed ! Generated JSON diff error report:
>
> $->pre-policy->update: expected has key '172.31.0.15/32' which is not present in output

It is particularly unsuccessful when run with valgrind:

> python3 -m pytest -vvss --valgrind-leak-kinds=all --valgrind-extra --valgrind-memleaks bgp_bmp_vrf

bgp_bmp_vrf is configuring a BMP policy on r1 and then some static BGP
prefixes on r2. If for some reasons, the BGP UPDATE arrives to r1 before
the BMP configuration is operational, the UPDATE is not sent to the BMP
server and the test fails.

Pre-configure the BMP policies at startup to avoid this race condition.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
tests/topotests/bgp_bmp_vrf/r1/bgpd.conf
tests/topotests/bgp_bmp_vrf/test_bgp_bmp_vrf.py

index 994cdbf68ea7e0060726233a43d6fe288e0a5cea..961e20498b2e737574877f91ddaad669c876e218 100644 (file)
@@ -7,6 +7,12 @@ router bgp 65501 vrf vrf1
 !
  bmp targets bmp1
   bmp connect 192.0.2.10 port 1789 min-retry 100 max-retry 10000
+   bmp monitor ipv4 unicast pre-policy
+   bmp monitor ipv6 unicast pre-policy
+   bmp monitor ipv4 unicast post-policy
+   bmp monitor ipv6 unicast post-policy
+   bmp monitor ipv4 unicast loc-rib
+   bmp monitor ipv6 unicast loc-rib
  exit
 !
 
index a7a1e87d9771ba0eceb23592b57fab6cfd7d880c..d31328bdb659bf0654cd40a826b388a05fe50659 100644 (file)
@@ -289,22 +289,6 @@ def check_for_peer_message(expected_peers, bmp_log_type):
     return True
 
 
-def set_bmp_policy(tgen, node, asn, target, safi, policy, vrf=None):
-    """
-    Configure the bmp policy.
-    """
-    vrf = " vrf {}".format(vrf) if vrf else ""
-    cmd = [
-        "con t\n",
-        "router bgp {}{}\n".format(asn, vrf),
-        "bmp targets {}\n".format(target),
-        "bmp monitor ipv4 {} {}\n".format(safi, policy),
-        "bmp monitor ipv6 {} {}\n".format(safi, policy),
-        "end\n",
-    ]
-    tgen.gears[node].vtysh_cmd("".join(cmd))
-
-
 def configure_prefixes(tgen, node, asn, safi, prefixes, vrf=None, update=True):
     """
     Configure the bgp prefixes.
@@ -331,7 +315,6 @@ def _test_prefixes(policy, step=1):
     message type and the right policy.
     """
     tgen = get_topogen()
-    set_bmp_policy(tgen, "r1", 65501, "bmp1", "unicast", policy, vrf="vrf1")
 
     prefixes = ["172.31.0.15/32", "2111::1111/128"]