]> git.puffer.fish Git - mirror/frr.git/commitdiff
topotests: bgp_bmp, add peer up message test when router-id changes
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 19 Dec 2024 08:01:12 +0000 (09:01 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 30 Dec 2024 14:13:38 +0000 (15:13 +0100)
Add a test to control the value of the peer bgp id of loc-rib peer up
messages when the bgp router-id is reconfigured.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
tests/topotests/bgp_bmp/bgpbmp.py
tests/topotests/bgp_bmp/test_bgp_bmp_2.py

index 8c14c4c9de5ec4d21560565fcb0cffc62173b7a3..ddd723bee256ce1714c1f621a01ea877e672d065 100644 (file)
@@ -187,7 +187,12 @@ def bmp_check_for_prefixes(
 
 
 def bmp_check_for_peer_message(
-    expected_peers, bmp_log_type, bmp_collector, bmp_log_file, is_rd_instance=False
+    expected_peers,
+    bmp_log_type,
+    bmp_collector,
+    bmp_log_file,
+    is_rd_instance=False,
+    peer_bgp_id=None,
 ):
     """
     Check for the presence of a peer up message for the peer
@@ -209,6 +214,8 @@ def bmp_check_for_peer_message(
     for m in messages:
         if is_rd_instance and m["peer_distinguisher"] == "0:0":
             continue
+        if peer_bgp_id and m["peer_bgp_id"] != peer_bgp_id:
+            continue
         if (
             "peer_ip" in m.keys()
             and m["peer_ip"] != "0.0.0.0"
index fc0bf1b7957a2885cd6c7a30b2b2a960e9b84e58..2c4ea76ac5f845431ccf41fdd0aa794c250818d8 100644 (file)
@@ -289,6 +289,56 @@ def test_bgp_instance_flapping():
     assert success, "Checking the BMP peer up LOC-RIB message failed !."
 
 
+def test_bgp_routerid_changed():
+    """
+    Checking for BGP loc-rib up messages with new router-id
+    """
+    tgen = get_topogen()
+
+    tgen.gears["r1vrf"].vtysh_cmd(
+        """
+        configure terminal
+        router bgp 65501 vrf vrf1
+        bgp router-id 192.168.1.77
+        """
+    )
+
+    peers = ["0.0.0.0"]
+
+    logger.info(
+        "checking for BMP peer down LOC-RIB message with router-id set to 192.168.0.1."
+    )
+    test_func = partial(
+        bmp_check_for_peer_message,
+        peers,
+        "peer down",
+        tgen.gears["bmp1vrf"],
+        os.path.join(tgen.logdir, "bmp1vrf", "bmp.log"),
+        is_rd_instance=True,
+    )
+    success, _ = topotest.run_and_expect(test_func, True, count=30, wait=1)
+    assert (
+        success
+    ), "Checking the BMP peer down LOC-RIB message with router-id set to 192.168.0.1 failed !."
+
+    logger.info(
+        "checking for BMP peer up LOC-RIB message with router-id set to 192.168.1.77."
+    )
+    test_func = partial(
+        bmp_check_for_peer_message,
+        peers,
+        "peer up",
+        tgen.gears["bmp1vrf"],
+        os.path.join(tgen.logdir, "bmp1vrf", "bmp.log"),
+        is_rd_instance=True,
+        peer_bgp_id="192.168.1.77",
+    )
+    success, _ = topotest.run_and_expect(test_func, True, count=30, wait=1)
+    assert (
+        success
+    ), "Checking the BMP peer up LOC-RIB message with router-id set to 192.168.1.77 failed !."
+
+
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]
     sys.exit(pytest.main(args))