summaryrefslogtreecommitdiff
path: root/tests/topotests/bgp_oad/test_bgp_oad.py
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2024-10-18 22:51:37 +0300
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-10-22 15:06:54 +0000
commitc024da828a05b3e6c4823b3940543f391d518b5e (patch)
tree9b4f14d36bc0c8e2c5190d11cbee7cad465c876a /tests/topotests/bgp_oad/test_bgp_oad.py
parent8257291d20a83513be823b78751f8891aea99817 (diff)
tests: Check if BGP no-export community is passed to BGP OAD peers
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org> (cherry picked from commit 7eaec540ec8aaca5821fc5ac1259b8eb8127f230)
Diffstat (limited to 'tests/topotests/bgp_oad/test_bgp_oad.py')
-rw-r--r--tests/topotests/bgp_oad/test_bgp_oad.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/topotests/bgp_oad/test_bgp_oad.py b/tests/topotests/bgp_oad/test_bgp_oad.py
index 6dd46fbdaa..b2ea7e0f19 100644
--- a/tests/topotests/bgp_oad/test_bgp_oad.py
+++ b/tests/topotests/bgp_oad/test_bgp_oad.py
@@ -8,6 +8,8 @@
"""
Test if local-preference is passed between different EBGP peers when
EBGP-OAD is configured.
+
+Also check if no-export community is passed to the EBGP-OAD peer.
"""
import os
@@ -51,6 +53,9 @@ def test_bgp_oad():
pytest.skip(tgen.errors)
r1 = tgen.gears["r1"]
+ r2 = tgen.gears["r2"]
+ r3 = tgen.gears["r3"]
+ r4 = tgen.gears["r4"]
def _bgp_converge():
output = json.loads(r1.vtysh_cmd("show bgp ipv4 unicast 10.10.10.10/32 json"))
@@ -85,6 +90,37 @@ def test_bgp_oad():
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, "Can't converge"
+ def _bgp_check_no_export(router, arg=[{"valid": True}]):
+ output = json.loads(router.vtysh_cmd("show bgp ipv4 unicast json"))
+ expected = {
+ "routes": {
+ "10.10.10.1/32": arg,
+ }
+ }
+ return topotest.json_cmp(output, expected)
+
+ test_func = functools.partial(
+ _bgp_check_no_export,
+ r2,
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assert result is None, "10.10.10.1/32 should be advertised to r2"
+
+ test_func = functools.partial(
+ _bgp_check_no_export,
+ r3,
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assert result is None, "10.10.10.1/32 should be advertised to r3"
+
+ test_func = functools.partial(
+ _bgp_check_no_export,
+ r4,
+ None,
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assert result is None, "10.10.10.1/32 should not be advertised to r4 (not OAD peer)"
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]