]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/rip_bfd_topo1/test_rip_bfd_topo1.py
2 # SPDX-License-Identifier: ISC
5 # test_rip_bfd_topo1.py
6 # Part of NetDEF Topology Tests
8 # Copyright (c) 2023 by
9 # Network Device Education Foundation, Inc. ("NetDEF")
13 test_rip_bfd_topo1.py: Test RIP BFD integration.
20 from functools
import partial
21 from lib
import topotest
22 from lib
.topogen
import Topogen
, TopoRouter
23 from lib
.topolog
import logger
31 @pytest.fixture(scope
="module")
33 "Setup/Teardown the environment and provide tgen argument to tests"
39 tgen
= Topogen(topodef
, request
.module
.__name
__)
42 router_list
= tgen
.routers()
44 for router_name
, router
in router_list
.items():
45 router
.load_config(TopoRouter
.RD_BFD
, "bfdd.conf")
46 router
.load_config(TopoRouter
.RD_RIP
, "ripd.conf")
47 router
.load_config(TopoRouter
.RD_ZEBRA
, "zebra.conf")
48 if router_name
in ["r2", "r3"]:
49 router
.load_config(TopoRouter
.RD_STATIC
, "staticd.conf")
56 @pytest.fixture(autouse
=True)
57 def skip_on_failure(tgen
):
58 "Test if routers is still running otherwise skip tests"
59 if tgen
.routers_have_failure():
60 pytest
.skip("skipped because of previous test failure")
63 def show_rip_json(router
):
64 "Get router 'show ip rip' JSON output"
65 output
= router
.vtysh_cmd("show ip rip")
66 routes
= output
.splitlines()[6:]
71 r
"(.)\((.)\)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)", route
)
79 "metric": int(match
[5]),
83 if json
.get(match
[3]) is None:
86 json
[match
[3]].append(route_entry
)
91 def expect_routes(router
, routes
, time_amount
):
92 "Expect 'routes' in 'router'."
95 "Internal test function."
96 return topotest
.json_cmp(show_rip_json(router
), routes
)
98 _
, result
= topotest
.run_and_expect(test_function
,
102 assert result
is None, "Unexpected routing table in {}".format(
106 def expect_bfd_peers(router
, peers
):
107 "Expect 'peers' in 'router' BFD status."
109 topotest
.router_json_cmp
,
111 "show bfd peers json",
114 _
, result
= topotest
.run_and_expect(test_func
, None, count
=20, wait
=1)
115 assert result
is None, "{} BFD peer status mismatch".format(router
)
118 def test_rip_convergence(tgen
):
119 "Test that RIP learns the neighbor routes."
123 "10.254.254.2/32": [{
126 "from": "192.168.0.2"
128 "10.254.254.3/32": [{
131 "from": "192.168.1.2"
133 "10.254.254.100/32": [{
136 "from": "192.168.0.2",
140 "from": "192.168.1.2",
144 expect_bfd_peers(tgen
.gears
["r1"], [{
145 "peer": "192.168.0.2",
147 "receive-interval": 1000,
148 "transmit-interval": 1000,
150 "peer": "192.168.1.2",
152 "receive-interval": 1000,
153 "transmit-interval": 1000,
158 "10.254.254.1/32": [{
161 "from": "192.168.0.1"
163 "10.254.254.3/32": [{
166 "from": "192.168.0.1"
168 "10.254.254.100/32": [{
175 expect_bfd_peers(tgen
.gears
["r2"], [{
176 "peer": "192.168.0.1",
178 "receive-interval": 1000,
179 "transmit-interval": 1000,
184 "10.254.254.1/32": [{
187 "from": "192.168.1.1"
189 "10.254.254.2/32": [{
192 "from": "192.168.1.1"
194 "10.254.254.100/32": [{
201 expect_bfd_peers(tgen
.gears
["r3"], [{
202 "peer": "192.168.1.1",
204 "receive-interval": 1000,
205 "transmit-interval": 1000,
209 def test_rip_bfd_convergence(tgen
):
210 "Test that RIP drop the gone neighbor routes."
212 tgen
.gears
["r3"].link_enable("r3-eth0", False)
216 "10.254.254.2/32": [{
219 "from": "192.168.0.2"
221 "10.254.254.3/32": None,
222 "10.254.254.100/32": [{
225 "from": "192.168.0.2",
231 "10.254.254.1/32": None,
232 "10.254.254.2/32": None,
233 "10.254.254.100/32": [{
241 def test_memory_leak(tgen
):
242 "Run the memory leak test and report results."
244 if not tgen
.is_memleak_enabled():
245 pytest
.skip("Memory leak test/report is disabled")
247 tgen
.report_memory_leaks()
250 if __name__
== "__main__":
251 args
= ["-s"] + sys
.argv
[1:]
252 sys
.exit(pytest
.main(args
))