summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/topotests/bgp_aigp/r1/bgpd.conf7
-rw-r--r--tests/topotests/bgp_aigp/test_bgp_aigp.py36
2 files changed, 24 insertions, 19 deletions
diff --git a/tests/topotests/bgp_aigp/r1/bgpd.conf b/tests/topotests/bgp_aigp/r1/bgpd.conf
index d99192421a..15621999c5 100644
--- a/tests/topotests/bgp_aigp/r1/bgpd.conf
+++ b/tests/topotests/bgp_aigp/r1/bgpd.conf
@@ -16,6 +16,13 @@ router bgp 65001
neighbor 192.168.18.8 route-map r8 out
exit-address-family
!
+ip prefix-list p71 seq 5 permit 10.0.0.71/32
+ip prefix-list p72 seq 5 permit 10.0.0.72/32
+!
route-map r8 permit 10
+ match ip address prefix-list p71
set metric igp
+route-map r8 permit 20
+ match ip address prefix-list p72
+ set metric aigp
exit
diff --git a/tests/topotests/bgp_aigp/test_bgp_aigp.py b/tests/topotests/bgp_aigp/test_bgp_aigp.py
index 92b54d0ae1..a59b71590b 100644
--- a/tests/topotests/bgp_aigp/test_bgp_aigp.py
+++ b/tests/topotests/bgp_aigp/test_bgp_aigp.py
@@ -17,6 +17,8 @@ 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.
+
+r1 advertises MED from AIGP (set metric aigp) to r8.
"""
import os
@@ -150,9 +152,16 @@ 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}]}
+ def _bgp_check_received_med():
+ output = json.loads(
+ r8.vtysh_cmd("show bgp ipv4 unicast 10.0.0.64/28 longer-prefixes json")
+ )
+ expected = {
+ "routes": {
+ "10.0.0.71/32": [{"valid": True, "metric": 20}],
+ "10.0.0.72/32": [{"valid": True, "metric": 112}],
+ }
+ }
return topotest.json_cmp(output, expected)
def _bgp_check_aigp_metric_bestpath():
@@ -264,23 +273,12 @@ 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)
+ # r8, check if MED is set derived from `set metric igp`, and `set metric aigp`
+ test_func = functools.partial(_bgp_check_received_med)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
- assert result is None, "MED attribute value is not 111"
+ assert (
+ result is None
+ ), "MED attribute values are not derived from `set metric [a]igp`"
if __name__ == "__main__":