summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2024-11-12 08:46:24 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2025-01-07 15:35:32 +0100
commitca7699f4aea34c12757ae9d469248f577b080dc1 (patch)
tree4a434c57e47149d1e7e27855232c7aa3a328aac3 /tests
parentbgpd, topotests: bmp imported bgp, add loc-rib peer up support when vrf flaps (diff)
downloadfrr-ca7699f4aea34c12757ae9d469248f577b080dc1.tar.xz
frr-ca7699f4aea34c12757ae9d469248f577b080dc1.zip
bgpd, topotests: bmp, send peer down when unconfiguring imported vrf
When unconfiguring an imported BGP instance, a peer down should be sent to notify BMP collector that the BGP instance is leaving. Add a test that controls the presence of the peer down loc-rib message. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/topotests/bgp_bmp/test_bgp_bmp_3.py84
1 files changed, 64 insertions, 20 deletions
diff --git a/tests/topotests/bgp_bmp/test_bgp_bmp_3.py b/tests/topotests/bgp_bmp/test_bgp_bmp_3.py
index 70037a525..7a68dcde8 100644
--- a/tests/topotests/bgp_bmp/test_bgp_bmp_3.py
+++ b/tests/topotests/bgp_bmp/test_bgp_bmp_3.py
@@ -188,31 +188,16 @@ def _test_prefixes(policy, vrf=None, step=0):
assert success, "Checking the updated prefixes has failed ! %s" % res
-def test_bmp_server_logging():
- """
- Assert the logging of the bmp server.
- """
-
- def check_for_log_file():
- tgen = get_topogen()
- output = tgen.gears["bmp1import"].run(
- "ls {}".format(os.path.join(tgen.logdir, "bmp1import"))
- )
- if "bmp.log" not in output:
- return False
- return True
-
- success, _ = topotest.run_and_expect(check_for_log_file, True, count=30, wait=1)
- assert success, "The BMP server is not logging"
-
-
-def test_peer_up():
+def _test_peer_up(check_locrib=True):
"""
Checking for BMP peers up messages
"""
tgen = get_topogen()
- peers = ["0.0.0.0", "192.168.1.3", "192:167::3"]
+ if check_locrib:
+ peers = ["0.0.0.0", "192.168.1.3", "192:167::3"]
+ else:
+ peers = ["192.168.1.3", "192:167::3"]
logger.info("checking for BMP peers up messages")
@@ -228,6 +213,28 @@ def test_peer_up():
assert success, "Checking the updated prefixes has been failed !."
+def test_bmp_server_logging():
+ """
+ Assert the logging of the bmp server.
+ """
+
+ def check_for_log_file():
+ tgen = get_topogen()
+ output = tgen.gears["bmp1import"].run(
+ "ls {}".format(os.path.join(tgen.logdir, "bmp1import"))
+ )
+ if "bmp.log" not in output:
+ return False
+ return True
+
+ success, _ = topotest.run_and_expect(check_for_log_file, True, count=30, wait=1)
+ assert success, "The BMP server is not logging"
+
+
+def test_bmp_peer_up_start():
+ _test_peer_up()
+
+
def test_bmp_bgp_unicast():
"""
Add/withdraw bgp unicast prefixes and check the bmp logs.
@@ -353,6 +360,43 @@ def test_bgp_instance_flapping():
assert success, "Checking the BMP peer up LOC-RIB message failed !."
+def test_peer_up_after_flush():
+ """
+ Checking for BMP peers down messages
+ """
+ _test_peer_up(check_locrib=False)
+
+
+def test_peer_down_locrib():
+ """
+ Checking for BMP peers down loc-rib messages
+ """
+ tgen = get_topogen()
+
+ tgen.gears["r1import"].vtysh_cmd(
+ """
+ configure terminal
+ router bgp 65501
+ bmp targets bmp1
+ no bmp import-vrf-view vrf1
+ """
+ )
+
+ peers = ["0.0.0.0"]
+
+ logger.info("checking for BMP peers down messages")
+
+ test_func = partial(
+ bmp_check_for_peer_message,
+ peers,
+ "peer down",
+ tgen.gears["bmp1import"],
+ os.path.join(tgen.logdir, "bmp1import", "bmp.log"),
+ )
+ success, _ = topotest.run_and_expect(test_func, True, count=30, wait=1)
+ assert success, "Checking the BMP peer down message has failed !."
+
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))