]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/isis_lsp_bits_topo1/test_isis_lsp_bits_topo1.py
2 # SPDX-License-Identifier: ISC
5 # test_isis_lsp_bits_topo1.py
6 # Part of NetDEF Topology Tests
8 # Copyright (c) 2021 by Volta Networks
12 test_isis_lsp_bits_topo1.py:
24 +---------+ | +---------+
26 | RT2 |eth-sw1 | eth-sw1| RT3 |
27 | 2.2.2.2 +----------+----------+ 3.3.3.3 |
28 | L1|L2 | 10.0.1.0/24 | L1|L2 |
29 +---------+ +---------+
32 10.0.2.0/24| |10.0.4.0/24
35 +---------+ +---------+
37 | RT4 | 10.0.6.0/24 | RT5 |
38 | 4.4.4.4 +---------------------+ 5.5.5.5 |
39 | L1|L2 |eth-rt5 eth-rt4| L1|L2 |
40 +---------+ +---------+
43 10.0.7.0/24| |10.0.8.0/24
47 +----------+ 6.6.6.6 +-----------+
56 from functools
import partial
58 # Save the Current Working Directory to find configuration files.
59 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
60 sys
.path
.append(os
.path
.join(CWD
, "../"))
62 # pylint: disable=C0413
63 # Import topogen and topotest helpers
64 from lib
import topotest
65 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
66 from lib
.topolog
import logger
68 # Required to instantiate the topology builder class.
70 pytestmark
= [pytest
.mark
.isisd
]
73 # Global multi-dimensional dictionary containing all expected outputs
83 for router
in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
84 tgen
.add_router(router
)
89 switch
= tgen
.add_switch("s1")
90 switch
.add_link(tgen
.gears
["rt1"], nodeif
="eth-sw1")
91 switch
.add_link(tgen
.gears
["rt2"], nodeif
="eth-sw1")
92 switch
.add_link(tgen
.gears
["rt3"], nodeif
="eth-sw1")
94 switch
= tgen
.add_switch("s2")
95 switch
.add_link(tgen
.gears
["rt2"], nodeif
="eth-rt4")
96 switch
.add_link(tgen
.gears
["rt4"], nodeif
="eth-rt2")
98 switch
= tgen
.add_switch("s4")
99 switch
.add_link(tgen
.gears
["rt3"], nodeif
="eth-rt5")
100 switch
.add_link(tgen
.gears
["rt5"], nodeif
="eth-rt3")
102 switch
= tgen
.add_switch("s6")
103 switch
.add_link(tgen
.gears
["rt4"], nodeif
="eth-rt5")
104 switch
.add_link(tgen
.gears
["rt5"], nodeif
="eth-rt4")
106 switch
= tgen
.add_switch("s7")
107 switch
.add_link(tgen
.gears
["rt4"], nodeif
="eth-rt6")
108 switch
.add_link(tgen
.gears
["rt6"], nodeif
="eth-rt4")
110 switch
= tgen
.add_switch("s8")
111 switch
.add_link(tgen
.gears
["rt5"], nodeif
="eth-rt6")
112 switch
.add_link(tgen
.gears
["rt6"], nodeif
="eth-rt5")
115 def setup_module(mod
):
116 "Sets up the pytest environment"
117 tgen
= Topogen(build_topo
, mod
.__name
__)
118 tgen
.start_topology()
120 router_list
= tgen
.routers()
122 # For all registered routers, load the zebra configuration file
123 for rname
, router
in router_list
.items():
125 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
128 TopoRouter
.RD_ISIS
, os
.path
.join(CWD
, "{}/isisd.conf".format(rname
))
134 def teardown_module(mod
):
135 "Teardown the pytest environment"
138 # This function tears down the whole topology.
142 def router_compare_json_output(rname
, command
, reference
):
143 "Compare router JSON output"
145 logger
.info('Comparing router "%s" "%s" output', rname
, command
)
148 filename
= "{}/{}/{}".format(CWD
, rname
, reference
)
149 expected
= json
.loads(open(filename
).read())
151 # Run test function until we get an result. Wait at most 60 seconds.
152 test_func
= partial(topotest
.router_json_cmp
, tgen
.gears
[rname
], command
, expected
)
153 _
, diff
= topotest
.run_and_expect(test_func
, None, count
=120, wait
=0.5)
154 assertmsg
= '"{}" JSON output mismatches the expected result'.format(rname
)
155 assert diff
is None, assertmsg
161 # Test initial network convergence
162 # Attach-bit defaults to on, so expect default route pointing to L1|L2 router
164 def test_isis_adjacencies_step1():
165 logger
.info("Test (step 1): check IS-IS adjacencies")
168 # Skip if previous fatal error condition is raised
169 if tgen
.routers_have_failure():
170 pytest
.skip(tgen
.errors
)
172 for rname
in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
173 router_compare_json_output(
175 "show yang operational-data /frr-interface:lib isisd",
176 "step1/show_yang_interface_isis_adjacencies.ref",
180 def test_rib_ipv4_step1():
181 logger
.info("Test (step 1): verify IPv4 RIB")
184 # Skip if previous fatal error condition is raised
185 if tgen
.routers_have_failure():
186 pytest
.skip(tgen
.errors
)
188 for rname
in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
189 router_compare_json_output(
190 rname
, "show ip route isis json", "step1/show_ip_route.ref"
194 def test_rib_ipv6_step1():
195 logger
.info("Test (step 1): verify IPv6 RIB")
198 # Skip if previous fatal error condition is raised
199 if tgen
.routers_have_failure():
200 pytest
.skip(tgen
.errors
)
202 for rname
in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
203 router_compare_json_output(
204 rname
, "show ipv6 route isis json", "step1/show_ipv6_route.ref"
212 # -Disable sending Attach bit on RT2 and RT4
215 # -RT1 should remove the default route pointing to RT2
216 # -RT6 should remove the default route pointing to RT4
218 def test_rib_ipv4_step2():
219 logger
.info("Test (step 2): verify IPv4 RIB")
222 # Skip if previous fatal error condition is raised
223 if tgen
.routers_have_failure():
224 pytest
.skip(tgen
.errors
)
226 logger
.info("Disabling setting the attached-bit on RT2 and RT4")
228 'vtysh -c "conf t" -c "router isis 1" -c "no attached-bit send"'
231 'vtysh -c "conf t" -c "router isis 1" -c "no attached-bit send"'
234 for rname
in ["rt1", "rt6"]:
235 router_compare_json_output(
236 rname
, "show ip route isis json", "step2/show_ip_route.ref"
240 def test_rib_ipv6_step2():
241 logger
.info("Test (step 2): verify IPv6 RIB")
244 # Skip if previous fatal error condition is raised
245 if tgen
.routers_have_failure():
246 pytest
.skip(tgen
.errors
)
248 for rname
in ["rt1", "rt6"]:
249 router_compare_json_output(
250 rname
, "show ipv6 route isis json", "step2/show_ipv6_route.ref"
258 # -restore attach-bit, enable sending attach-bit
259 # -disble processing a LSP with attach bit set
262 # -RT1 and RT6 should not install a default route
264 def test_rib_ipv4_step3():
265 logger
.info("Test (step 3): verify IPv4 RIB")
268 # Skip if previous fatal error condition is raised
269 if tgen
.routers_have_failure():
270 pytest
.skip(tgen
.errors
)
272 logger
.info("Enable setting the attached-bit on RT2 and RT4")
273 tgen
.net
["rt2"].cmd('vtysh -c "conf t" -c "router isis 1" -c "attached-bit send"')
274 tgen
.net
["rt4"].cmd('vtysh -c "conf t" -c "router isis 1" -c "attached-bit send"')
276 logger
.info("Disable processing received attached-bit in LSP on RT1 and RT6")
278 'vtysh -c "conf t" -c "router isis 1" -c "attached-bit receive ignore"'
281 'vtysh -c "conf t" -c "router isis 1" -c "attached-bit receive ignore"'
284 for rname
in ["rt1", "rt6"]:
285 router_compare_json_output(
286 rname
, "show ip route isis json", "step3/show_ip_route.ref"
290 def test_rib_ipv6_step3():
291 logger
.info("Test (step 3): verify IPv6 RIB")
294 # Skip if previous fatal error condition is raised
295 if tgen
.routers_have_failure():
296 pytest
.skip(tgen
.errors
)
298 for rname
in ["rt1", "rt6"]:
299 router_compare_json_output(
300 rname
, "show ipv6 route isis json", "step3/show_ipv6_route.ref"
308 # -restore back to default attach-bit config
311 # -RT1 and RT6 should add default route
312 # -no changes on other routers
314 def test_rib_ipv4_step4():
315 logger
.info("Test (step 4): verify IPv4 RIB")
318 # Skip if previous fatal error condition is raised
319 if tgen
.routers_have_failure():
320 pytest
.skip(tgen
.errors
)
323 "restore default processing on received attached-bit in LSP on RT1 and RT6"
326 'vtysh -c "conf t" -c "router isis 1" -c "no attached-bit receive ignore"'
329 'vtysh -c "conf t" -c "router isis 1" -c "no attached-bit receive ignore"'
332 for rname
in ["rt1", "rt6"]:
333 router_compare_json_output(
334 rname
, "show ip route isis json", "step4/show_ip_route.ref"
338 def test_rib_ipv6_step4():
339 logger
.info("Test (step 4): verify IPv6 RIB")
342 # Skip if previous fatal error condition is raised
343 if tgen
.routers_have_failure():
344 pytest
.skip(tgen
.errors
)
346 for rname
in ["rt1", "rt6"]:
347 router_compare_json_output(
348 rname
, "show ipv6 route isis json", "step4/show_ipv6_route.ref"
352 # Memory leak test template
353 def test_memory_leak():
354 "Run the memory leak test and report results."
356 if not tgen
.is_memleak_enabled():
357 pytest
.skip("Memory leak test/report is disabled")
359 tgen
.report_memory_leaks()
362 if __name__
== "__main__":
363 args
= ["-s"] + sys
.argv
[1:]
364 sys
.exit(pytest
.main(args
))