]> git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/isis_topo1/test_isis_topo1.py
Merge pull request #12069 from opensourcerouting/fix/local-as_reset
[mirror_frr.git] / tests / topotests / isis_topo1 / test_isis_topo1.py
1 #!/usr/bin/env python
2
3 #
4 # test_isis_topo1.py
5 # Part of NetDEF Topology Tests
6 #
7 # Copyright (c) 2017 by
8 # Network Device Education Foundation, Inc. ("NetDEF")
9 #
10 # Permission to use, copy, modify, and/or distribute this software
11 # for any purpose with or without fee is hereby granted, provided
12 # that the above copyright notice and this permission notice appear
13 # in all copies.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
16 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
18 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
19 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
21 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22 # OF THIS SOFTWARE.
23 #
24
25 """
26 test_isis_topo1.py: Test ISIS topology.
27 """
28 import datetime
29 import functools
30 import json
31 import os
32 import re
33 import sys
34 import pytest
35
36 CWD = os.path.dirname(os.path.realpath(__file__))
37 sys.path.append(os.path.join(CWD, "../"))
38
39 # pylint: disable=C0413
40 from lib import topotest
41 from lib.common_config import (
42 retry,
43 stop_router,
44 start_router,
45 )
46 from lib.topogen import Topogen, TopoRouter, get_topogen
47 from lib.topolog import logger
48
49
50 pytestmark = [pytest.mark.isisd]
51
52 VERTEX_TYPE_LIST = [
53 "pseudo_IS",
54 "pseudo_TE-IS",
55 "IS",
56 "TE-IS",
57 "ES",
58 "IP internal",
59 "IP external",
60 "IP TE",
61 "IP6 internal",
62 "IP6 external",
63 "UNKNOWN",
64 ]
65
66
67 def build_topo(tgen):
68 "Build function"
69
70 # Add ISIS routers:
71 # r1 r2
72 # | sw1 | sw2
73 # r3 r4
74 # | |
75 # sw3 sw4
76 # \ /
77 # r5
78 for routern in range(1, 6):
79 tgen.add_router("r{}".format(routern))
80
81 # r1 <- sw1 -> r3
82 sw = tgen.add_switch("sw1")
83 sw.add_link(tgen.gears["r1"])
84 sw.add_link(tgen.gears["r3"])
85
86 # r2 <- sw2 -> r4
87 sw = tgen.add_switch("sw2")
88 sw.add_link(tgen.gears["r2"])
89 sw.add_link(tgen.gears["r4"])
90
91 # r3 <- sw3 -> r5
92 sw = tgen.add_switch("sw3")
93 sw.add_link(tgen.gears["r3"])
94 sw.add_link(tgen.gears["r5"])
95
96 # r4 <- sw4 -> r5
97 sw = tgen.add_switch("sw4")
98 sw.add_link(tgen.gears["r4"])
99 sw.add_link(tgen.gears["r5"])
100
101
102 def setup_module(mod):
103 "Sets up the pytest environment"
104 tgen = Topogen(build_topo, mod.__name__)
105 tgen.start_topology()
106
107 # For all registered routers, load the zebra configuration file
108 for rname, router in tgen.routers().items():
109 router.load_config(
110 TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
111 )
112 router.load_config(
113 TopoRouter.RD_ISIS, os.path.join(CWD, "{}/isisd.conf".format(rname))
114 )
115
116 # After loading the configurations, this function loads configured daemons.
117 tgen.start_router()
118
119
120 def teardown_module(mod):
121 "Teardown the pytest environment"
122 tgen = get_topogen()
123
124 # This function tears down the whole topology.
125 tgen.stop_topology()
126
127
128 def test_isis_convergence():
129 "Wait for the protocol to converge before starting to test"
130 tgen = get_topogen()
131 # Don't run this test if we have any failure.
132 if tgen.routers_have_failure():
133 pytest.skip(tgen.errors)
134
135 logger.info("waiting for ISIS protocol to converge")
136 # Code to generate the json files.
137 # for rname, router in tgen.routers().items():
138 # open('/tmp/{}_topology.json'.format(rname), 'w').write(
139 # json.dumps(show_isis_topology(router), indent=2, sort_keys=True)
140 # )
141
142 for rname, router in tgen.routers().items():
143 filename = "{0}/{1}/{1}_topology.json".format(CWD, rname)
144 expected = json.loads(open(filename).read())
145
146 def compare_isis_topology(router, expected):
147 "Helper function to test ISIS topology convergence."
148 actual = show_isis_topology(router)
149 return topotest.json_cmp(actual, expected)
150
151 test_func = functools.partial(compare_isis_topology, router, expected)
152 (result, diff) = topotest.run_and_expect(test_func, None, wait=0.5, count=120)
153 assert result, "ISIS did not converge on {}:\n{}".format(rname, diff)
154
155
156 def test_isis_route_installation():
157 "Check whether all expected routes are present"
158 tgen = get_topogen()
159 # Don't run this test if we have any failure.
160 if tgen.routers_have_failure():
161 pytest.skip(tgen.errors)
162
163 logger.info("Checking routers for installed ISIS routes")
164
165 # Check for routes in 'show ip route json'
166 for rname, router in tgen.routers().items():
167 filename = "{0}/{1}/{1}_route.json".format(CWD, rname)
168 expected = json.loads(open(filename, "r").read())
169
170 def compare_isis_installed_routes(router, expected):
171 "Helper function to test ISIS routes installed in rib."
172 actual = router.vtysh_cmd("show ip route json", isjson=True)
173 return topotest.json_cmp(actual, expected)
174
175 test_func = functools.partial(compare_isis_installed_routes, router, expected)
176 (result, diff) = topotest.run_and_expect(test_func, None, wait=1, count=10)
177 assertmsg = "Router '{}' routes mismatch".format(rname)
178 assert result, assertmsg
179
180
181 def test_isis_linux_route_installation():
182 "Check whether all expected routes are present and installed in the OS"
183 tgen = get_topogen()
184 # Don't run this test if we have any failure.
185 if tgen.routers_have_failure():
186 pytest.skip(tgen.errors)
187
188 logger.info("Checking routers for installed ISIS routes in OS")
189
190 # Check for routes in `ip route`
191 for rname, router in tgen.routers().items():
192 filename = "{0}/{1}/{1}_route_linux.json".format(CWD, rname)
193 expected = json.loads(open(filename, "r").read())
194 actual = topotest.ip4_route(router)
195 assertmsg = "Router '{}' OS routes mismatch".format(rname)
196 assert topotest.json_cmp(actual, expected) is None, assertmsg
197
198
199 def test_isis_route6_installation():
200 "Check whether all expected routes are present"
201 tgen = get_topogen()
202 # Don't run this test if we have any failure.
203 if tgen.routers_have_failure():
204 pytest.skip(tgen.errors)
205
206 logger.info("Checking routers for installed ISIS IPv6 routes")
207
208 # Check for routes in 'show ip route json'
209 for rname, router in tgen.routers().items():
210 filename = "{0}/{1}/{1}_route6.json".format(CWD, rname)
211 expected = json.loads(open(filename, "r").read())
212
213 def compare_isis_v6_installed_routes(router, expected):
214 "Helper function to test ISIS v6 routes installed in rib."
215 actual = router.vtysh_cmd("show ipv6 route json", isjson=True)
216 return topotest.json_cmp(actual, expected)
217
218 test_func = functools.partial(
219 compare_isis_v6_installed_routes, router, expected
220 )
221 (result, diff) = topotest.run_and_expect(test_func, None, wait=1, count=10)
222 assertmsg = "Router '{}' routes mismatch".format(rname)
223 assert result, assertmsg
224
225
226 def test_isis_linux_route6_installation():
227 "Check whether all expected routes are present and installed in the OS"
228 tgen = get_topogen()
229 # Don't run this test if we have any failure.
230 if tgen.routers_have_failure():
231 pytest.skip(tgen.errors)
232
233 logger.info("Checking routers for installed ISIS IPv6 routes in OS")
234
235 # Check for routes in `ip route`
236 for rname, router in tgen.routers().items():
237 filename = "{0}/{1}/{1}_route6_linux.json".format(CWD, rname)
238 expected = json.loads(open(filename, "r").read())
239 actual = topotest.ip6_route(router)
240 assertmsg = "Router '{}' OS routes mismatch".format(rname)
241 assert topotest.json_cmp(actual, expected) is None, assertmsg
242
243
244 def test_isis_summary_json():
245 "Check json struct in show isis summary json"
246
247 tgen = get_topogen()
248 # Don't run this test if we have any failure.
249 if tgen.routers_have_failure():
250 pytest.skip(tgen.errors)
251
252 logger.info("Checking 'show isis summary json'")
253 for rname, router in tgen.routers().items():
254 logger.info("Checking router %s", rname)
255 json_output = tgen.gears[rname].vtysh_cmd("show isis summary json", isjson=True)
256 assertmsg = "Test isis summary json failed in '{}' data '{}'".format(
257 rname, json_output
258 )
259 assert json_output["vrf"] == "default", assertmsg
260 assert json_output["areas"][0]["area"] == "1", assertmsg
261 assert json_output["areas"][0]["levels"][0]["id"] != "3", assertmsg
262
263
264 def test_isis_interface_json():
265 "Check json struct in show isis interface json"
266
267 tgen = get_topogen()
268 # Don't run this test if we have any failure.
269 if tgen.routers_have_failure():
270 pytest.skip(tgen.errors)
271
272 logger.info("Checking 'show isis interface json'")
273 for rname, router in tgen.routers().items():
274 logger.info("Checking router %s", rname)
275 json_output = tgen.gears[rname].vtysh_cmd(
276 "show isis interface json", isjson=True
277 )
278 assertmsg = "Test isis interface json failed in '{}' data '{}'".format(
279 rname, json_output
280 )
281 assert (
282 json_output["areas"][0]["circuits"][0]["interface"]["name"]
283 == rname + "-eth0"
284 ), assertmsg
285
286 for rname, router in tgen.routers().items():
287 logger.info("Checking router %s", rname)
288 json_output = tgen.gears[rname].vtysh_cmd(
289 "show isis interface detail json", isjson=True
290 )
291 assertmsg = "Test isis interface json failed in '{}' data '{}'".format(
292 rname, json_output
293 )
294 assert (
295 json_output["areas"][0]["circuits"][0]["interface"]["name"]
296 == rname + "-eth0"
297 ), assertmsg
298
299
300 def test_isis_neighbor_json():
301 "Check json struct in show isis neighbor json"
302
303 tgen = get_topogen()
304 # Don't run this test if we have any failure.
305 if tgen.routers_have_failure():
306 pytest.skip(tgen.errors)
307
308 # tgen.mininet_cli()
309 logger.info("Checking 'show isis neighbor json'")
310 for rname, router in tgen.routers().items():
311 logger.info("Checking router %s", rname)
312 json_output = tgen.gears[rname].vtysh_cmd(
313 "show isis neighbor json", isjson=True
314 )
315 assertmsg = "Test isis neighbor json failed in '{}' data '{}'".format(
316 rname, json_output
317 )
318 assert (
319 json_output["areas"][0]["circuits"][0]["interface"] == rname + "-eth0"
320 ), assertmsg
321
322 for rname, router in tgen.routers().items():
323 logger.info("Checking router %s", rname)
324 json_output = tgen.gears[rname].vtysh_cmd(
325 "show isis neighbor detail json", isjson=True
326 )
327 assertmsg = "Test isis neighbor json failed in '{}' data '{}'".format(
328 rname, json_output
329 )
330 assert (
331 json_output["areas"][0]["circuits"][0]["interface"]["name"]
332 == rname + "-eth0"
333 ), assertmsg
334
335
336 def test_isis_database_json():
337 "Check json struct in show isis database json"
338
339 tgen = get_topogen()
340 # Don't run this test if we have any failure.
341 if tgen.routers_have_failure():
342 pytest.skip(tgen.errors)
343
344 # tgen.mininet_cli()
345 logger.info("Checking 'show isis database json'")
346 for rname, router in tgen.routers().items():
347 logger.info("Checking router %s", rname)
348 json_output = tgen.gears[rname].vtysh_cmd(
349 "show isis database json", isjson=True
350 )
351 assertmsg = "Test isis database json failed in '{}' data '{}'".format(
352 rname, json_output
353 )
354 assert json_output["areas"][0]["area"]["name"] == "1", assertmsg
355 assert json_output["areas"][0]["levels"][0]["id"] != "3", assertmsg
356
357 for rname, router in tgen.routers().items():
358 logger.info("Checking router %s", rname)
359 json_output = tgen.gears[rname].vtysh_cmd(
360 "show isis database detail json", isjson=True
361 )
362 assertmsg = "Test isis database json failed in '{}' data '{}'".format(
363 rname, json_output
364 )
365 assert json_output["areas"][0]["area"]["name"] == "1", assertmsg
366 assert json_output["areas"][0]["levels"][0]["id"] != "3", assertmsg
367
368
369 def test_isis_overload_on_startup():
370 "Check that overload on startup behaves as expected"
371
372 tgen = get_topogen()
373 net = get_topogen().net
374 overload_time = 120
375
376 # Don't run this test if we have any failure.
377 if tgen.routers_have_failure():
378 pytest.skip(tgen.errors)
379
380 logger.info("Testing overload on startup behavior")
381
382 # Configure set-overload-bit on-startup on r3
383 r3 = tgen.gears["r3"]
384 r3.vtysh_cmd(
385 f"""
386 configure
387 router isis 1
388 set-overload-bit on-startup {overload_time}
389 """
390 )
391 # Restart r3
392 logger.info("Stop router")
393 stop_router(tgen, "r3")
394 logger.info("Start router")
395
396 tstamp_before_start_router = datetime.datetime.now()
397 start_router(tgen, "r3")
398 tstamp_after_start_router = datetime.datetime.now()
399 startup_router_time = (
400 tstamp_after_start_router - tstamp_before_start_router
401 ).total_seconds()
402
403 # Check that the overload bit is set in r3's LSP
404 check_lsp_overload_bit("r3", "r3.00-00", "0/0/1")
405 check_lsp_overload_bit("r1", "r3.00-00", "0/0/1")
406
407 # Attempt to unset overload bit while timer is still running
408 r3.vtysh_cmd(
409 """
410 configure
411 router isis 1
412 no set-overload-bit on-startup
413 no set-overload-bit
414 """
415 )
416
417 # Check overload bit is still set
418 check_lsp_overload_bit("r1", "r3.00-00", "0/0/1")
419
420 # Check that overload bit is unset after timer completes
421 check_lsp_overload_bit("r3", "r3.00-00", "0/0/0")
422 tstamp_after_bit_unset = datetime.datetime.now()
423 check_lsp_overload_bit("r1", "r3.00-00", "0/0/0")
424
425 # Collect time overloaded
426 time_overloaded = (
427 tstamp_after_bit_unset - tstamp_after_start_router
428 ).total_seconds()
429 logger.info(f"Time Overloaded: {time_overloaded}")
430
431 # Use time it took to startup router as lower bound
432 logger.info(
433 f"Assert that overload time falls in range: {overload_time - startup_router_time} < {time_overloaded} <= {overload_time}"
434 )
435 result = overload_time - startup_router_time < time_overloaded <= overload_time
436 assert result
437
438
439 def test_isis_overload_on_startup_cancel_timer():
440 "Check that overload on startup timer is cancelled when overload bit is set/unset"
441
442 tgen = get_topogen()
443 net = get_topogen().net
444 overload_time = 90
445
446 # Don't run this test if we have any failure.
447 if tgen.routers_have_failure():
448 pytest.skip(tgen.errors)
449
450 logger.info(
451 "Testing overload on startup behavior with set overload bit: cancel timer"
452 )
453
454 # Configure set-overload-bit on-startup on r3
455 r3 = tgen.gears["r3"]
456 r3.vtysh_cmd(
457 f"""
458 configure
459 router isis 1
460 set-overload-bit on-startup {overload_time}
461 set-overload-bit
462 """
463 )
464 # Restart r3
465 logger.info("Stop router")
466 stop_router(tgen, "r3")
467 logger.info("Start router")
468 start_router(tgen, "r3")
469
470 # Check that the overload bit is set in r3's LSP
471 check_lsp_overload_bit("r3", "r3.00-00", "0/0/1")
472
473 # Check that overload timer is running
474 check_overload_timer("r3", True)
475
476 # Unset overload bit while timer is running
477 r3.vtysh_cmd(
478 """
479 configure
480 router isis 1
481 no set-overload-bit
482 """
483 )
484
485 # Check that overload timer is cancelled
486 check_overload_timer("r3", False)
487
488 # Check overload bit is unset
489 check_lsp_overload_bit("r3", "r3.00-00", "0/0/0")
490
491
492 def test_isis_overload_on_startup_override_timer():
493 "Check that overload bit remains set after overload timer expires if overload bit is configured"
494
495 tgen = get_topogen()
496 net = get_topogen().net
497 overload_time = 60
498
499 # Don't run this test if we have any failure.
500 if tgen.routers_have_failure():
501 pytest.skip(tgen.errors)
502
503 logger.info(
504 "Testing overload on startup behavior with set overload bit: override timer"
505 )
506
507 # Configure set-overload-bit on-startup on r3
508 r3 = tgen.gears["r3"]
509 r3.vtysh_cmd(
510 f"""
511 configure
512 router isis 1
513 set-overload-bit on-startup {overload_time}
514 set-overload-bit
515 """
516 )
517 # Restart r3
518 logger.info("Stop router")
519 stop_router(tgen, "r3")
520 logger.info("Start router")
521 start_router(tgen, "r3")
522
523 # Check that the overload bit is set in r3's LSP
524 check_lsp_overload_bit("r3", "r3.00-00", "0/0/1")
525
526 # Check that overload timer is running
527 check_overload_timer("r3", True)
528
529 # Check that overload timer expired
530 check_overload_timer("r3", False)
531
532 # Check overload bit is still set
533 check_lsp_overload_bit("r3", "r3.00-00", "0/0/1")
534
535
536 @retry(retry_timeout=200)
537 def _check_lsp_overload_bit(router, overloaded_router_lsp, att_p_ol_expected):
538 "Verfiy overload bit in router's LSP"
539
540 tgen = get_topogen()
541 router = tgen.gears[router]
542 logger.info(f"check_overload_bit {router}")
543 isis_database_output = router.vtysh_cmd(
544 "show isis database {} json".format(overloaded_router_lsp)
545 )
546
547 database_json = json.loads(isis_database_output)
548 att_p_ol = database_json["areas"][0]["levels"][1]["att-p-ol"]
549 if att_p_ol == att_p_ol_expected:
550 return True
551 return "{} peer with expected att_p_ol {} got {} ".format(
552 router.name, att_p_ol_expected, att_p_ol
553 )
554
555
556 def check_lsp_overload_bit(router, overloaded_router_lsp, att_p_ol_expected):
557 "Verfiy overload bit in router's LSP"
558
559 assertmsg = _check_lsp_overload_bit(
560 router, overloaded_router_lsp, att_p_ol_expected
561 )
562 assert assertmsg is True, assertmsg
563
564
565 @retry(retry_timeout=200)
566 def _check_overload_timer(router, timer_expected):
567 "Verfiy overload bit in router's LSP"
568
569 tgen = get_topogen()
570 router = tgen.gears[router]
571 thread_output = router.vtysh_cmd("show thread timers")
572
573 timer_running = "set_overload_on_start_timer" in thread_output
574 if timer_running == timer_expected:
575 return True
576 return "Expected timer running status: {}".format(timer_expected)
577
578
579 def check_overload_timer(router, timer_expected):
580 "Verfiy overload bit in router's LSP"
581
582 assertmsg = _check_overload_timer(router, timer_expected)
583 assert assertmsg is True, assertmsg
584
585
586 def test_memory_leak():
587 "Run the memory leak test and report results."
588 tgen = get_topogen()
589 if not tgen.is_memleak_enabled():
590 pytest.skip("Memory leak test/report is disabled")
591
592 tgen.report_memory_leaks()
593
594
595 if __name__ == "__main__":
596 args = ["-s"] + sys.argv[1:]
597 sys.exit(pytest.main(args))
598
599
600 #
601 # Auxiliary functions
602 #
603
604
605 def dict_merge(dct, merge_dct):
606 """
607 Recursive dict merge. Inspired by :meth:``dict.update()``, instead of
608 updating only top-level keys, dict_merge recurses down into dicts nested
609 to an arbitrary depth, updating keys. The ``merge_dct`` is merged into
610 ``dct``.
611 :param dct: dict onto which the merge is executed
612 :param merge_dct: dct merged into dct
613 :return: None
614
615 Source:
616 https://gist.github.com/angstwad/bf22d1822c38a92ec0a9
617 """
618 for k, v in merge_dct.items():
619 if k in dct and isinstance(dct[k], dict) and topotest.is_mapping(merge_dct[k]):
620 dict_merge(dct[k], merge_dct[k])
621 else:
622 dct[k] = merge_dct[k]
623
624
625 def parse_topology(lines, level):
626 """
627 Parse the output of 'show isis topology level-X' into a Python dict.
628 """
629 areas = {}
630 area = None
631 ipv = None
632 vertex_type_regex = "|".join(VERTEX_TYPE_LIST)
633
634 for line in lines:
635 area_match = re.match(r"Area (.+):", line)
636 if area_match:
637 area = area_match.group(1)
638 if area not in areas:
639 areas[area] = {level: {"ipv4": [], "ipv6": []}}
640 ipv = None
641 continue
642 elif area is None:
643 continue
644
645 if re.match(r"IS\-IS paths to level-. routers that speak IPv6", line):
646 ipv = "ipv6"
647 continue
648 if re.match(r"IS\-IS paths to level-. routers that speak IP", line):
649 ipv = "ipv4"
650 continue
651
652 item_match = re.match(
653 r"([^\s]+) ([^\s]+) ([^\s]+) ([^\s]+) ([^\s]+) ([^\s]+)", line
654 )
655 if (
656 item_match is not None
657 and item_match.group(1) == "Vertex"
658 and item_match.group(2) == "Type"
659 and item_match.group(3) == "Metric"
660 and item_match.group(4) == "Next-Hop"
661 and item_match.group(5) == "Interface"
662 and item_match.group(6) == "Parent"
663 ):
664 # Skip header
665 continue
666
667 item_match = re.match(
668 r"([^\s]+) ({}) ([0]|([1-9][0-9]*)) ([^\s]+) ([^\s]+) ([^\s]+)".format(
669 vertex_type_regex
670 ),
671 line,
672 )
673 if item_match is not None:
674 areas[area][level][ipv].append(
675 {
676 "vertex": item_match.group(1),
677 "type": item_match.group(2),
678 "metric": item_match.group(3),
679 "next-hop": item_match.group(5),
680 "interface": item_match.group(6),
681 "parent": item_match.group(7),
682 }
683 )
684 continue
685
686 item_match = re.match(
687 r"([^\s]+) ({}) ([0]|([1-9][0-9]*)) ([^\s]+)".format(vertex_type_regex),
688 line,
689 )
690
691 if item_match is not None:
692 areas[area][level][ipv].append(
693 {
694 "vertex": item_match.group(1),
695 "type": item_match.group(2),
696 "metric": item_match.group(3),
697 "parent": item_match.group(5),
698 }
699 )
700 continue
701
702 item_match = re.match(r"([^\s]+)", line)
703 if item_match is not None:
704 areas[area][level][ipv].append({"vertex": item_match.group(1)})
705 continue
706
707 return areas
708
709
710 def show_isis_topology(router):
711 """
712 Get the ISIS topology in a dictionary format.
713
714 Sample:
715 {
716 'area-name': {
717 'level-1': [
718 {
719 'vertex': 'r1'
720 }
721 ],
722 'level-2': [
723 {
724 'vertex': '10.0.0.1/24',
725 'type': 'IP',
726 'parent': '0',
727 'metric': 'internal'
728 }
729 ]
730 },
731 'area-name-2': {
732 'level-2': [
733 {
734 "interface": "rX-ethY",
735 "metric": "Z",
736 "next-hop": "rA",
737 "parent": "rC(B)",
738 "type": "TE-IS",
739 "vertex": "rD"
740 }
741 ]
742 }
743 }
744 """
745 l1out = topotest.normalize_text(
746 router.vtysh_cmd("show isis topology level-1")
747 ).splitlines()
748 l2out = topotest.normalize_text(
749 router.vtysh_cmd("show isis topology level-2")
750 ).splitlines()
751
752 l1 = parse_topology(l1out, "level-1")
753 l2 = parse_topology(l2out, "level-2")
754
755 dict_merge(l1, l2)
756 return l1