summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/topotests/bgp_sender_as_path_loop_detection/r1/bgpd.conf23
-rw-r--r--tests/topotests/bgp_sender_as_path_loop_detection/r1/zebra.conf1
-rw-r--r--tests/topotests/bgp_sender_as_path_loop_detection/r2/bgpd.conf15
-rw-r--r--tests/topotests/bgp_sender_as_path_loop_detection/r3/bgpd.conf6
-rw-r--r--tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py48
5 files changed, 51 insertions, 42 deletions
diff --git a/tests/topotests/bgp_sender_as_path_loop_detection/r1/bgpd.conf b/tests/topotests/bgp_sender_as_path_loop_detection/r1/bgpd.conf
index 719d76392d..409be74740 100644
--- a/tests/topotests/bgp_sender_as_path_loop_detection/r1/bgpd.conf
+++ b/tests/topotests/bgp_sender_as_path_loop_detection/r1/bgpd.conf
@@ -1,14 +1,19 @@
! exit1
router bgp 65001
- no bgp ebgp-requires-policy
- neighbor 192.168.255.1 remote-as 65002
- neighbor 192.168.255.1 timers 3 10
- address-family ipv4 unicast
- neighbor 192.168.255.1 route-map prepend out
- redistribute connected
- exit-address-family
- !
+ no bgp ebgp-requires-policy
+ neighbor 192.168.255.1 remote-as 65002
+ neighbor 192.168.255.1 timers 3 10
+ address-family ipv4 unicast
+ neighbor 192.168.255.1 route-map prepend out
+ redistribute connected
+ exit-address-family
+ !
+!
+ip prefix-list p1 seq 5 permit 172.16.255.253/32
!
route-map prepend permit 10
- set as-path prepend 65003
+ match ip address prefix-list p1
+ set as-path prepend 65003
+!
+route-map prepend permit 20
!
diff --git a/tests/topotests/bgp_sender_as_path_loop_detection/r1/zebra.conf b/tests/topotests/bgp_sender_as_path_loop_detection/r1/zebra.conf
index 9904bb4e16..74489a0571 100644
--- a/tests/topotests/bgp_sender_as_path_loop_detection/r1/zebra.conf
+++ b/tests/topotests/bgp_sender_as_path_loop_detection/r1/zebra.conf
@@ -1,5 +1,6 @@
! exit1
interface lo
+ ip address 172.16.255.253/32
ip address 172.16.255.254/32
!
interface r1-eth0
diff --git a/tests/topotests/bgp_sender_as_path_loop_detection/r2/bgpd.conf b/tests/topotests/bgp_sender_as_path_loop_detection/r2/bgpd.conf
index a4a654d7b5..dcb52a2e7d 100644
--- a/tests/topotests/bgp_sender_as_path_loop_detection/r2/bgpd.conf
+++ b/tests/topotests/bgp_sender_as_path_loop_detection/r2/bgpd.conf
@@ -1,11 +1,10 @@
! spine
router bgp 65002
- no bgp ebgp-requires-policy
- neighbor 192.168.255.2 remote-as 65001
- neighbor 192.168.255.2 timers 3 10
- neighbor 192.168.255.2 solo
- neighbor 192.168.254.2 remote-as 65003
- neighbor 192.168.254.2 timers 3 10
- neighbor 192.168.254.2 solo
- neighbor 192.168.254.2 sender-as-path-loop-detection
+ no bgp ebgp-requires-policy
+ neighbor 192.168.255.2 remote-as 65001
+ neighbor 192.168.255.2 timers 3 10
+ neighbor 192.168.255.2 sender-as-path-loop-detection
+ neighbor 192.168.254.2 remote-as 65003
+ neighbor 192.168.254.2 timers 3 10
+ neighbor 192.168.254.2 sender-as-path-loop-detection
!
diff --git a/tests/topotests/bgp_sender_as_path_loop_detection/r3/bgpd.conf b/tests/topotests/bgp_sender_as_path_loop_detection/r3/bgpd.conf
index 2e24de0b2d..519273d30d 100644
--- a/tests/topotests/bgp_sender_as_path_loop_detection/r3/bgpd.conf
+++ b/tests/topotests/bgp_sender_as_path_loop_detection/r3/bgpd.conf
@@ -1,6 +1,6 @@
! exit2
router bgp 65003
- no bgp ebgp-requires-policy
- neighbor 192.168.254.1 remote-as 65002
- neighbor 192.168.254.1 timers 3 10
+ no bgp ebgp-requires-policy
+ neighbor 192.168.254.1 remote-as 65002
+ neighbor 192.168.254.1 timers 3 10
!
diff --git a/tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py b/tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py
index b5c33f359b..ebeab05648 100644
--- a/tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py
+++ b/tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py
@@ -85,20 +85,20 @@ def test_bgp_sender_as_path_loop_detection():
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
- router = tgen.gears["r2"]
+ r2 = tgen.gears["r2"]
- def _bgp_converge(router):
- output = json.loads(router.vtysh_cmd("show ip bgp neighbor 192.168.255.2 json"))
+ def _bgp_converge():
+ output = json.loads(r2.vtysh_cmd("show ip bgp neighbor 192.168.255.2 json"))
expected = {
"192.168.255.2": {
"bgpState": "Established",
- "addressFamilyInfo": {"ipv4Unicast": {"acceptedPrefixCounter": 2}},
+ "addressFamilyInfo": {"ipv4Unicast": {"acceptedPrefixCounter": 3}},
}
}
return topotest.json_cmp(output, expected)
- def _bgp_has_route_from_r1(router):
- output = json.loads(router.vtysh_cmd("show ip bgp 172.16.255.254/32 json"))
+ def _bgp_has_route_from_r1():
+ output = json.loads(r2.vtysh_cmd("show ip bgp 172.16.255.253/32 json"))
expected = {
"paths": [
{
@@ -111,31 +111,35 @@ def test_bgp_sender_as_path_loop_detection():
}
return topotest.json_cmp(output, expected)
- def _bgp_suppress_route_to_r3(router):
+ def _bgp_suppress_route_to_r1():
output = json.loads(
- router.vtysh_cmd(
- "show ip bgp neighbor 192.168.254.2 advertised-routes json"
- )
+ r2.vtysh_cmd("show ip bgp neighbor 192.168.255.2 advertised-routes json")
)
expected = {"totalPrefixCounter": 0}
return topotest.json_cmp(output, expected)
- test_func = functools.partial(_bgp_converge, router)
- success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
-
- assert result is None, 'Failed bgp convergence in "{}"'.format(router)
+ def _bgp_suppress_route_to_r3():
+ output = json.loads(
+ r2.vtysh_cmd("show ip bgp neighbor 192.168.254.2 advertised-routes json")
+ )
+ expected = {"totalPrefixCounter": 2}
+ return topotest.json_cmp(output, expected)
- test_func = functools.partial(_bgp_has_route_from_r1, router)
- success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ test_func = functools.partial(_bgp_converge)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+ assert result is None, "Failed bgp to convergence"
- assert result is None, 'Failed to see a route from r1 in "{}"'.format(router)
+ test_func = functools.partial(_bgp_has_route_from_r1)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+ assert result is None, "Failed to see a route from r1"
- test_func = functools.partial(_bgp_suppress_route_to_r3, router)
- success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ test_func = functools.partial(_bgp_suppress_route_to_r3)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+ assert result is None, "Route 172.16.255.253/32 should not be sent to r3 from r2"
- assert (
- result is None
- ), 'Route 172.16.255.254/32 should not be sent to r3 "{}"'.format(router)
+ test_func = functools.partial(_bgp_suppress_route_to_r1)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+ assert result is None, "Routes should not be sent to r1 from r2"
if __name__ == "__main__":