summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2024-10-08 21:36:13 +0300
committerDonatas Abraitis <donatas@opensourcerouting.org>2024-10-15 17:42:51 +0300
commit8d39cfd613944be99671fe28a3d92c6b2cb716ab (patch)
treecdf9c3ced2caf54c31d64c715745163c8b537ac5
parentf677fc8db3c0195dc1bc8d7cd9887cf4e7aa638e (diff)
tests: Check if MED can be derived from `set metric igp|aigp`
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
-rw-r--r--tests/topotests/bgp_aigp/r1/bgpd.conf9
-rw-r--r--tests/topotests/bgp_aigp/r1/zebra.conf3
-rw-r--r--tests/topotests/bgp_aigp/r8/bgpd.conf4
-rw-r--r--tests/topotests/bgp_aigp/r8/zebra.conf4
-rw-r--r--tests/topotests/bgp_aigp/test_bgp_aigp.py32
5 files changed, 51 insertions, 1 deletions
diff --git a/tests/topotests/bgp_aigp/r1/bgpd.conf b/tests/topotests/bgp_aigp/r1/bgpd.conf
index 74a0215bc4..d99192421a 100644
--- a/tests/topotests/bgp_aigp/r1/bgpd.conf
+++ b/tests/topotests/bgp_aigp/r1/bgpd.conf
@@ -9,4 +9,13 @@ router bgp 65001
neighbor 10.0.0.3 timers 1 3
neighbor 10.0.0.3 timers connect 1
neighbor 10.0.0.3 update-source lo
+ neighbor 192.168.18.8 remote-as external
+ neighbor 192.168.18.8 timers 1 3
+ neighbor 192.168.18.8 timers connect 1
+ address-family ipv4
+ neighbor 192.168.18.8 route-map r8 out
+ exit-address-family
!
+route-map r8 permit 10
+ set metric igp
+exit
diff --git a/tests/topotests/bgp_aigp/r1/zebra.conf b/tests/topotests/bgp_aigp/r1/zebra.conf
index 0ed22d37be..7ac4bb5de9 100644
--- a/tests/topotests/bgp_aigp/r1/zebra.conf
+++ b/tests/topotests/bgp_aigp/r1/zebra.conf
@@ -8,3 +8,6 @@ interface r1-eth0
interface r1-eth1
ip address 192.168.13.1/24
!
+interface r1-eth2
+ ip address 192.168.18.1/24
+!
diff --git a/tests/topotests/bgp_aigp/r8/bgpd.conf b/tests/topotests/bgp_aigp/r8/bgpd.conf
new file mode 100644
index 0000000000..c50c3ce91a
--- /dev/null
+++ b/tests/topotests/bgp_aigp/r8/bgpd.conf
@@ -0,0 +1,4 @@
+router bgp 65008
+ no bgp ebgp-requires-policy
+ neighbor 192.168.18.1 remote-as external
+!
diff --git a/tests/topotests/bgp_aigp/r8/zebra.conf b/tests/topotests/bgp_aigp/r8/zebra.conf
new file mode 100644
index 0000000000..f7545270b2
--- /dev/null
+++ b/tests/topotests/bgp_aigp/r8/zebra.conf
@@ -0,0 +1,4 @@
+!
+interface r8-eth0
+ ip address 192.168.18.8/24
+!
diff --git a/tests/topotests/bgp_aigp/test_bgp_aigp.py b/tests/topotests/bgp_aigp/test_bgp_aigp.py
index 0d859adc53..92b54d0ae1 100644
--- a/tests/topotests/bgp_aigp/test_bgp_aigp.py
+++ b/tests/topotests/bgp_aigp/test_bgp_aigp.py
@@ -15,6 +15,8 @@ r2 and r3 receives those routes with aigp-metric TLV increased by 20,
and 10 appropriately.
r1 receives routes with aigp-metric TLV 81, 91 and 82, 92 respectively.
+
+r1 advertises MED from IGP protocol (set metric igp) to r8.
"""
import os
@@ -34,7 +36,7 @@ pytestmark = [pytest.mark.bgpd]
def build_topo(tgen):
- for routern in range(1, 8):
+ for routern in range(1, 9):
tgen.add_router("r{}".format(routern))
switch = tgen.add_switch("s1")
@@ -65,6 +67,10 @@ def build_topo(tgen):
switch.add_link(tgen.gears["r6"])
switch.add_link(tgen.gears["r7"])
+ switch = tgen.add_switch("s8")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r8"])
+
def setup_module(mod):
tgen = Topogen(build_topo, mod.__name__)
@@ -102,6 +108,7 @@ def test_bgp_aigp():
r3 = tgen.gears["r3"]
r4 = tgen.gears["r4"]
r5 = tgen.gears["r5"]
+ r8 = tgen.gears["r8"]
def _bgp_converge():
output = json.loads(r1.vtysh_cmd("show bgp ipv4 unicast 10.0.0.71/32 json"))
@@ -143,6 +150,11 @@ def test_bgp_aigp():
expected = {"paths": [{"aigpMetric": aigp, "valid": True}]}
return topotest.json_cmp(output, expected)
+ def _bgp_check_received_med(med):
+ output = json.loads(r8.vtysh_cmd("show bgp ipv4 unicast 10.0.0.71/32 json"))
+ expected = {"paths": [{"metric": med, "valid": True}]}
+ return topotest.json_cmp(output, expected)
+
def _bgp_check_aigp_metric_bestpath():
output = json.loads(
r1.vtysh_cmd(
@@ -252,6 +264,24 @@ def test_bgp_aigp():
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assert result is None, "AIGP attribute is not considered in best-path selection"
+ # r8, check if MED is set to 20 (derived from `set metric igp`)
+ test_func = functools.partial(_bgp_check_received_med, 20)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assert result is None, "MED attribute value is not 20"
+
+ r1.vtysh_cmd(
+ """
+configure terminal
+route-map r8 permit 10
+ set metric aigp
+"""
+ )
+
+ # r8, check if MED is set to 111 (derived from `set metric aigp`)
+ test_func = functools.partial(_bgp_check_received_med, 111)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assert result is None, "MED attribute value is not 111"
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]