]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_route_map_delay_timer/test_bgp_route_map_delay_timer.py
2 # SPDX-License-Identifier: ISC
4 # Copyright (c) 2023 by
5 # Donatas Abraitis <donatas@opensourcerouting.org>
18 pytestmark
= pytest
.mark
.bgpd
20 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
21 sys
.path
.append(os
.path
.join(CWD
, "../"))
23 # pylint: disable=C0413
24 from lib
import topotest
25 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
27 pytestmark
= [pytest
.mark
.bgpd
]
30 def setup_module(mod
):
31 topodef
= {"s1": ("r1", "r2")}
32 tgen
= Topogen(topodef
, mod
.__name
__)
35 router_list
= tgen
.routers()
37 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
39 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
42 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
48 def teardown_module(mod
):
53 def test_bgp_route_map_delay_timer():
56 if tgen
.routers_have_failure():
57 pytest
.skip(tgen
.errors
)
62 def _bgp_converge_1():
65 "show bgp ipv4 unicast neighbor 192.168.1.2 advertised-routes json"
73 "10.10.10.3/32": None,
76 return topotest
.json_cmp(output
, expected
)
78 test_func
= functools
.partial(_bgp_converge_1
)
79 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
80 assert result
is None, "10.10.10.3/32 should not be advertised to r2"
82 # Set route-map delay-timer to max value and remove 10.10.10.2/32.
83 # After this, r1 MUST do not announce updates immediately, and wait
84 # 600 seconds before withdrawing 10.10.10.2/32.
88 bgp route-map delay-timer 600
89 no ip prefix-list r1 seq 10 permit 10.10.10.2/32
93 def _bgp_converge_2():
96 "show bgp ipv4 unicast neighbor 192.168.1.2 advertised-routes json"
100 "advertisedRoutes": {
103 "10.10.10.2/32": None,
104 "10.10.10.3/32": None,
107 return topotest
.json_cmp(output
, expected
)
109 # We are checking `not None` here to wait count*wait time and if we have different
110 # results than expected, it means good - 10.10.10.2/32 wasn't withdrawn immediately.
111 test_func
= functools
.partial(_bgp_converge_2
)
112 _
, result
= topotest
.run_and_expect(test_func
, not None, count
=60, wait
=0.5)
115 ), "10.10.10.2/32 advertised, but should not be advertised to r2"
118 if __name__
== "__main__":
119 args
= ["-s"] + sys
.argv
[1:]
120 sys
.exit(pytest
.main(args
))