]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: rework bmp policy message logging
authorFarid MIHOUB <farid.mihoub@6wind.com>
Fri, 11 Aug 2023 14:11:03 +0000 (16:11 +0200)
committerMaxence Younsi <mx.yns@outlook.fr>
Sat, 4 Nov 2023 11:19:30 +0000 (12:19 +0100)
Add "policy" field to the logged bmp messages so policy checks within
topotests would be easier and clearer.

Signed-off-by: Farid MIHOUB <farid.mihoub@6wind.com>
tests/topotests/bgp_bmp/test_bgp_bmp.py
tests/topotests/lib/bmp_collector/bmp.py

index 65f191b33aa74ab66008898c4eff6c230c09e0ba..1aeb2d9c19934e46e5f60d4b1eacef5829c8fbf1 100644 (file)
@@ -120,7 +120,7 @@ def get_bmp_messages():
     return messages
 
 
-def check_for_prefixes(expected_prefixes, bmp_log_type, post_policy):
+def check_for_prefixes(expected_prefixes, bmp_log_type, policy):
     """
     Check for the presence of the given prefixes in the BMP server logs with
     the given message type and the set policy.
@@ -138,7 +138,7 @@ def check_for_prefixes(expected_prefixes, bmp_log_type, post_policy):
         if "ip_prefix" in m.keys()
         and "bmp_log_type" in m.keys()
         and m["bmp_log_type"] == bmp_log_type
-        and m["post_policy"] == post_policy
+        and m["policy"] == policy
     ]
 
     # check for prefixes
@@ -202,7 +202,7 @@ def unicast_prefixes(policy):
 
     logger.info("checking for updated prefixes")
     # check
-    test_func = partial(check_for_prefixes, prefixes, "update", policy == POST_POLICY)
+    test_func = partial(check_for_prefixes, prefixes, "update", policy)
     success, _ = topotest.run_and_expect(test_func, True, wait=0.5)
     assert success, "Checking the updated prefixes has been failed !."
 
@@ -210,7 +210,7 @@ def unicast_prefixes(policy):
     configure_prefixes(tgen, "r2", 65502, "unicast", prefixes, update=False)
     logger.info("checking for withdrawed prefxies")
     # check
-    test_func = partial(check_for_prefixes, prefixes, "withdraw", policy == POST_POLICY)
+    test_func = partial(check_for_prefixes, prefixes, "withdraw", policy)
     success, _ = topotest.run_and_expect(test_func, True, wait=0.5)
     assert success, "Checking the withdrawed prefixes has been failed !."
 
index b07329cd523f76d885239451f3d495e175915b01..4ac4fdb0a9301a6ec367c32a1bb1fd05b0291dbf 100644 (file)
@@ -259,7 +259,7 @@ class BMPPerPeerMessage:
             is_as_path = bool(peer_flags & IS_AS_PATH)
             is_post_policy = bool(peer_flags & IS_POST_POLICY)
             is_ipv6 = bool(peer_flags & IS_IPV6)
-            msg['post_policy'] = is_post_policy
+            msg['policy'] = 'post-policy' if is_post_policy else 'pre-policy'
             msg['ipv6'] = is_ipv6
             msg['peer_ip'] = bin2str_ipaddress(peer_address, is_ipv6)