From a5da98ae1a88207cd46df1215827f405c10734e8 Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Tue, 27 Feb 2024 19:05:36 +0100 Subject: [PATCH] topotests: bgp_bmp, test presence of labels Test the presence of labels in BMP Signed-off-by: Louis Scalbert --- tests/topotests/bgp_bmp/test_bgp_bmp.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/topotests/bgp_bmp/test_bgp_bmp.py b/tests/topotests/bgp_bmp/test_bgp_bmp.py index c65ca81103..02de805068 100644 --- a/tests/topotests/bgp_bmp/test_bgp_bmp.py +++ b/tests/topotests/bgp_bmp/test_bgp_bmp.py @@ -123,7 +123,7 @@ def get_bmp_messages(): return messages -def check_for_prefixes(expected_prefixes, bmp_log_type, policy): +def check_for_prefixes(expected_prefixes, bmp_log_type, policy, labels=None): """ Check for the presence of the given prefixes in the BMP server logs with the given message type and the set policy. @@ -142,6 +142,12 @@ def check_for_prefixes(expected_prefixes, bmp_log_type, policy): and "bmp_log_type" in m.keys() and m["bmp_log_type"] == bmp_log_type and m["policy"] == policy + and ( + labels is None + or ( + m["ip_prefix"] in labels.keys() and m["label"] == labels[m["ip_prefix"]] + ) + ) ] # check for prefixes @@ -228,12 +234,23 @@ def vpn_prefixes(policy): set_bmp_policy(tgen, "r1", 65501, "bmp1", "vpn", policy) prefixes = ["172.31.10.1/32", "2001::2222/128"] + + if policy == PRE_POLICY: + # labels are not yet supported in adj-RIB-in. Do not test for the moment + labels = None + else: + # "label vpn export" value in r2/bgpd.conf + labels = { + "172.31.10.1/32": 102, + "2001::2222/128": 105, + } + # add prefixes configure_prefixes(tgen, "r2", 65502, "unicast", prefixes, vrf="vrf1") logger.info("checking for updated prefixes") # check - test_func = partial(check_for_prefixes, prefixes, "update", policy) + test_func = partial(check_for_prefixes, prefixes, "update", policy, labels=labels) success, _ = topotest.run_and_expect(test_func, True, wait=0.5) assert success, "Checking the updated prefixes has been failed !." -- 2.39.5