]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/isis_lsp_bits_topo1/test_isis_lsp_bits_topo1.py
9b4cd95110c756ba26c0b176864ad3fa03fb75bc
4 # test_isis_lsp_bits_topo1.py
5 # Part of NetDEF Topology Tests
7 # Copyright (c) 2021 by Volta Networks
9 # Permission to use, copy, modify, and/or distribute this software
10 # for any purpose with or without fee is hereby granted, provided
11 # that the above copyright notice and this permission notice appear
14 # THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
15 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
17 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
18 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
19 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
20 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
25 test_isis_lsp_bits_topo1.py:
37 +---------+ | +---------+
39 | RT2 |eth-sw1 | eth-sw1| RT3 |
40 | 2.2.2.2 +----------+----------+ 3.3.3.3 |
41 | L1|L2 | 10.0.1.0/24 | L1|L2 |
42 +---------+ +---------+
45 10.0.2.0/24| |10.0.4.0/24
48 +---------+ +---------+
50 | RT4 | 10.0.6.0/24 | RT5 |
51 | 4.4.4.4 +---------------------+ 5.5.5.5 |
52 | L1|L2 |eth-rt5 eth-rt4| L1|L2 |
53 +---------+ +---------+
56 10.0.7.0/24| |10.0.8.0/24
60 +----------+ 6.6.6.6 +-----------+
69 from functools
import partial
71 # Save the Current Working Directory to find configuration files.
72 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
73 sys
.path
.append(os
.path
.join(CWD
, "../"))
75 # pylint: disable=C0413
76 # Import topogen and topotest helpers
77 from lib
import topotest
78 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
79 from lib
.topolog
import logger
81 # Required to instantiate the topology builder class.
83 pytestmark
= [pytest
.mark
.isisd
]
86 # Global multi-dimensional dictionary containing all expected outputs
96 for router
in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
97 tgen
.add_router(router
)
102 switch
= tgen
.add_switch("s1")
103 switch
.add_link(tgen
.gears
["rt1"], nodeif
="eth-sw1")
104 switch
.add_link(tgen
.gears
["rt2"], nodeif
="eth-sw1")
105 switch
.add_link(tgen
.gears
["rt3"], nodeif
="eth-sw1")
107 switch
= tgen
.add_switch("s2")
108 switch
.add_link(tgen
.gears
["rt2"], nodeif
="eth-rt4")
109 switch
.add_link(tgen
.gears
["rt4"], nodeif
="eth-rt2")
111 switch
= tgen
.add_switch("s4")
112 switch
.add_link(tgen
.gears
["rt3"], nodeif
="eth-rt5")
113 switch
.add_link(tgen
.gears
["rt5"], nodeif
="eth-rt3")
115 switch
= tgen
.add_switch("s6")
116 switch
.add_link(tgen
.gears
["rt4"], nodeif
="eth-rt5")
117 switch
.add_link(tgen
.gears
["rt5"], nodeif
="eth-rt4")
119 switch
= tgen
.add_switch("s7")
120 switch
.add_link(tgen
.gears
["rt4"], nodeif
="eth-rt6")
121 switch
.add_link(tgen
.gears
["rt6"], nodeif
="eth-rt4")
123 switch
= tgen
.add_switch("s8")
124 switch
.add_link(tgen
.gears
["rt5"], nodeif
="eth-rt6")
125 switch
.add_link(tgen
.gears
["rt6"], nodeif
="eth-rt5")
128 def setup_module(mod
):
129 "Sets up the pytest environment"
130 tgen
= Topogen(build_topo
, mod
.__name
__)
131 tgen
.start_topology()
133 router_list
= tgen
.routers()
135 # For all registered routers, load the zebra configuration file
136 for rname
, router
in router_list
.items():
138 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
141 TopoRouter
.RD_ISIS
, os
.path
.join(CWD
, "{}/isisd.conf".format(rname
))
147 def teardown_module(mod
):
148 "Teardown the pytest environment"
151 # This function tears down the whole topology.
155 def router_compare_json_output(rname
, command
, reference
):
156 "Compare router JSON output"
158 logger
.info('Comparing router "%s" "%s" output', rname
, command
)
161 filename
= "{}/{}/{}".format(CWD
, rname
, reference
)
162 expected
= json
.loads(open(filename
).read())
164 # Run test function until we get an result. Wait at most 60 seconds.
165 test_func
= partial(topotest
.router_json_cmp
, tgen
.gears
[rname
], command
, expected
)
166 _
, diff
= topotest
.run_and_expect(test_func
, None, count
=120, wait
=0.5)
167 assertmsg
= '"{}" JSON output mismatches the expected result'.format(rname
)
168 assert diff
is None, assertmsg
174 # Test initial network convergence
175 # Attach-bit defaults to on, so expect default route pointing to L1|L2 router
177 def test_isis_adjacencies_step1():
178 logger
.info("Test (step 1): check IS-IS adjacencies")
181 # Skip if previous fatal error condition is raised
182 if tgen
.routers_have_failure():
183 pytest
.skip(tgen
.errors
)
185 for rname
in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
186 router_compare_json_output(
188 "show yang operational-data /frr-interface:lib isisd",
189 "step1/show_yang_interface_isis_adjacencies.ref",
193 def test_rib_ipv4_step1():
194 logger
.info("Test (step 1): verify IPv4 RIB")
197 # Skip if previous fatal error condition is raised
198 if tgen
.routers_have_failure():
199 pytest
.skip(tgen
.errors
)
201 for rname
in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
202 router_compare_json_output(
203 rname
, "show ip route isis json", "step1/show_ip_route.ref"
207 def test_rib_ipv6_step1():
208 logger
.info("Test (step 1): verify IPv6 RIB")
211 # Skip if previous fatal error condition is raised
212 if tgen
.routers_have_failure():
213 pytest
.skip(tgen
.errors
)
215 for rname
in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
216 router_compare_json_output(
217 rname
, "show ipv6 route isis json", "step1/show_ipv6_route.ref"
225 # -Disable sending Attach bit on RT2 and RT4
228 # -RT1 should remove the default route pointing to RT2
229 # -RT6 should remove the default route pointing to RT4
231 def test_rib_ipv4_step2():
232 logger
.info("Test (step 2): verify IPv4 RIB")
235 # Skip if previous fatal error condition is raised
236 if tgen
.routers_have_failure():
237 pytest
.skip(tgen
.errors
)
239 logger
.info("Disabling setting the attached-bit on RT2 and RT4")
241 'vtysh -c "conf t" -c "router isis 1" -c "no attached-bit send"'
244 'vtysh -c "conf t" -c "router isis 1" -c "no attached-bit send"'
247 for rname
in ["rt1", "rt6"]:
248 router_compare_json_output(
249 rname
, "show ip route isis json", "step2/show_ip_route.ref"
253 def test_rib_ipv6_step2():
254 logger
.info("Test (step 2): verify IPv6 RIB")
257 # Skip if previous fatal error condition is raised
258 if tgen
.routers_have_failure():
259 pytest
.skip(tgen
.errors
)
261 for rname
in ["rt1", "rt6"]:
262 router_compare_json_output(
263 rname
, "show ipv6 route isis json", "step2/show_ipv6_route.ref"
271 # -restore attach-bit, enable sending attach-bit
272 # -disble processing a LSP with attach bit set
275 # -RT1 and RT6 should not install a default route
277 def test_rib_ipv4_step3():
278 logger
.info("Test (step 3): verify IPv4 RIB")
281 # Skip if previous fatal error condition is raised
282 if tgen
.routers_have_failure():
283 pytest
.skip(tgen
.errors
)
285 logger
.info("Enable setting the attached-bit on RT2 and RT4")
286 tgen
.net
["rt2"].cmd('vtysh -c "conf t" -c "router isis 1" -c "attached-bit send"')
287 tgen
.net
["rt4"].cmd('vtysh -c "conf t" -c "router isis 1" -c "attached-bit send"')
289 logger
.info("Disable processing received attached-bit in LSP on RT1 and RT6")
291 'vtysh -c "conf t" -c "router isis 1" -c "attached-bit receive ignore"'
294 'vtysh -c "conf t" -c "router isis 1" -c "attached-bit receive ignore"'
297 for rname
in ["rt1", "rt6"]:
298 router_compare_json_output(
299 rname
, "show ip route isis json", "step3/show_ip_route.ref"
303 def test_rib_ipv6_step3():
304 logger
.info("Test (step 3): verify IPv6 RIB")
307 # Skip if previous fatal error condition is raised
308 if tgen
.routers_have_failure():
309 pytest
.skip(tgen
.errors
)
311 for rname
in ["rt1", "rt6"]:
312 router_compare_json_output(
313 rname
, "show ipv6 route isis json", "step3/show_ipv6_route.ref"
321 # -restore back to default attach-bit config
324 # -RT1 and RT6 should add default route
325 # -no changes on other routers
327 def test_rib_ipv4_step4():
328 logger
.info("Test (step 4): verify IPv4 RIB")
331 # Skip if previous fatal error condition is raised
332 if tgen
.routers_have_failure():
333 pytest
.skip(tgen
.errors
)
336 "restore default processing on received attached-bit in LSP on RT1 and RT6"
339 'vtysh -c "conf t" -c "router isis 1" -c "no attached-bit receive ignore"'
342 'vtysh -c "conf t" -c "router isis 1" -c "no attached-bit receive ignore"'
345 for rname
in ["rt1", "rt6"]:
346 router_compare_json_output(
347 rname
, "show ip route isis json", "step4/show_ip_route.ref"
351 def test_rib_ipv6_step4():
352 logger
.info("Test (step 4): verify IPv6 RIB")
355 # Skip if previous fatal error condition is raised
356 if tgen
.routers_have_failure():
357 pytest
.skip(tgen
.errors
)
359 for rname
in ["rt1", "rt6"]:
360 router_compare_json_output(
361 rname
, "show ipv6 route isis json", "step4/show_ipv6_route.ref"
365 # Memory leak test template
366 def test_memory_leak():
367 "Run the memory leak test and report results."
369 if not tgen
.is_memleak_enabled():
370 pytest
.skip("Memory leak test/report is disabled")
372 tgen
.report_memory_leaks()
375 if __name__
== "__main__":
376 args
= ["-s"] + sys
.argv
[1:]
377 sys
.exit(pytest
.main(args
))