]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/ldp-topo1/test_ldp_topo1.py
4 # test_bgp_multiview_topo1.py
5 # Part of NetDEF Topology Tests
7 # Copyright (c) 2016 by
8 # Network Device Education Foundation, Inc. ("NetDEF")
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
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
26 test_ldp_topo1.py: Simple FRR/Quagga LDP Test
45 r2-eth2 .2 | | .2 r2-eth1
48 ~~~~~~~~~~~~~ ~~~~~~~~~~~~~
50 ~~ 10.0.3.0/24 ~~ ~~ 10.0.2.0/24 ~~
51 ~~~~~~~~~~~~~ ~~~~~~~~~~~~~
55 r3-eth1 .3 | | .3 r3-eth0 | .4 r4-eth0
56 +----+--+---+ +----+----+
58 | 3.3.3.3 | | 4.4.4.4 |
59 +-----------+ +---------+
67 from time
import sleep
69 from mininet
.topo
import Topo
70 from mininet
.net
import Mininet
71 from mininet
.node
import Node
, OVSSwitch
, Host
72 from mininet
.log
import setLogLevel
, info
73 from mininet
.cli
import CLI
74 from mininet
.link
import Intf
76 sys
.path
.append(os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
77 from lib
import topotest
81 # Expected version of CLI Output - Appendix to filename
82 # empty string = current, latest output (default)
83 # "-1" ... "-NNN" previous versions (incrementing with each version)
87 #####################################################
89 ## Network Topology Definition
91 #####################################################
93 class NetworkTopo(Topo
):
96 def build(self
, **_opts
):
100 for i
in range(1, 5):
101 router
[i
] = topotest
.addRouter(self
, 'r%s' % i
)
103 # Setup Switches, add Interfaces and Connections
106 switch
[0] = self
.addSwitch('sw0', cls
=topotest
.LegacySwitch
)
107 self
.addLink(switch
[0], router
[1], intfName2
='r1-eth0', addr1
='80:AA:00:00:00:00', addr2
='00:11:00:01:00:00')
108 self
.addLink(switch
[0], router
[2], intfName2
='r2-eth0', addr1
='80:AA:00:00:00:01', addr2
='00:11:00:02:00:00')
110 switch
[1] = self
.addSwitch('sw1', cls
=topotest
.LegacySwitch
)
111 self
.addLink(switch
[1], router
[2], intfName2
='r2-eth1', addr1
='80:AA:00:01:00:00', addr2
='00:11:00:02:00:01')
112 self
.addLink(switch
[1], router
[3], intfName2
='r3-eth0', addr1
='80:AA:00:01:00:01', addr2
='00:11:00:03:00:00')
113 self
.addLink(switch
[1], router
[4], intfName2
='r4-eth0', addr1
='80:AA:00:01:00:02', addr2
='00:11:00:04:00:00')
115 switch
[2] = self
.addSwitch('sw2', cls
=topotest
.LegacySwitch
)
116 self
.addLink(switch
[2], router
[2], intfName2
='r2-eth2', addr1
='80:AA:00:02:00:00', addr2
='00:11:00:02:00:02')
117 self
.addLink(switch
[2], router
[3], intfName2
='r3-eth1', addr1
='80:AA:00:02:00:01', addr2
='00:11:00:03:00:01')
120 #####################################################
124 #####################################################
126 def setup_module(module
):
130 print("\n\n** %s: Setup Topology" % module
.__name
__)
131 print("******************************************\n")
133 print("Cleanup old Mininet runs")
134 os
.system('sudo mn -c > /dev/null 2>&1')
136 thisDir
= os
.path
.dirname(os
.path
.realpath(__file__
))
139 net
= Mininet(controller
=None, topo
=topo
)
143 for i
in range(1, 5):
144 net
['r%s' % i
].loadConf('zebra', '%s/r%s/zebra.conf' % (thisDir
, i
))
145 net
['r%s' % i
].loadConf('ospfd', '%s/r%s/ospfd.conf' % (thisDir
, i
))
146 net
['r%s' % i
].loadConf('ldpd', '%s/r%s/ldpd.conf' % (thisDir
, i
))
147 fatal_error
= net
['r%s' % i
].startRouter()
149 if fatal_error
!= "":
152 # For debugging after starting FRR/Quagga daemons, uncomment the next line
155 def teardown_module(module
):
158 print("\n\n** %s: Shutdown Topology" % module
.__name
__)
159 print("******************************************\n")
161 # End - Shutdown network
165 def test_router_running():
170 # Skip if previous fatal error condition is raised
171 if (fatal_error
!= ""):
172 pytest
.skip(fatal_error
)
174 print("\n\n** Check if FRR/Quagga is running on each Router node")
175 print("******************************************\n")
179 for i
in range(1, 5):
180 fatal_error
= net
['r%s' % i
].checkRouterRunning()
181 assert fatal_error
== "", fatal_error
184 # At this time, there are only 2 possible outputs, so simple check
185 output
= net
['r1'].cmd('vtysh -c "show mpls ldp discovery" 2> /dev/null').rstrip()
187 # Check if old or new format of CLI Output. Default is to current format
189 # Old (v1) output looks like this:
190 # Local LDP Identifier: 1.1.1.1:0
194 # LDP Id: 2.2.2.2:0, Transport address: 2.2.2.2
198 # Current (v0) output looks like this:
199 # AF ID Type Source Holdtime
200 # ipv4 2.2.2.2 Link r1-eth0 15
201 pattern
= re
.compile("^Local LDP Identifier.*")
202 if pattern
.match(output
):
205 # For debugging after starting FRR/Quagga daemons, uncomment the next line
208 def test_mpls_interfaces():
213 # Skip if previous fatal error condition is raised
214 if (fatal_error
!= ""):
215 pytest
.skip(fatal_error
)
217 thisDir
= os
.path
.dirname(os
.path
.realpath(__file__
))
219 # Verify OSPFv3 Routing Table
220 print("\n\n** Verifying MPLS Interfaces")
221 print("******************************************\n")
223 for i
in range(1, 5):
224 refTableFile
= '%s/r%s/show_mpls_ldp_interface.ref%s' % (thisDir
, i
, cli_version
)
225 if os
.path
.isfile(refTableFile
):
226 # Read expected result from file
227 expected
= open(refTableFile
).read().rstrip()
228 # Fix newlines (make them all the same)
229 expected
= ('\n'.join(expected
.splitlines()) + '\n').splitlines(1)
231 # Actual output from router
232 actual
= net
['r%s' % i
].cmd('vtysh -c "show mpls ldp interface" 2> /dev/null').rstrip()
233 # Mask out Timer in Uptime
234 actual
= re
.sub(r
" [0-9][0-9]:[0-9][0-9]:[0-9][0-9] ", " xx:xx:xx ", actual
)
235 # Fix newlines (make them all the same)
236 actual
= ('\n'.join(actual
.splitlines()) + '\n').splitlines(1)
239 diff
= ''.join(difflib
.context_diff(actual
, expected
,
240 fromfile
="actual MPLS LDP interface status",
241 tofile
="expected MPLS LDP interface status"))
243 # Empty string if it matches, otherwise diff contains unified diff
245 sys
.stderr
.write('r%s failed MPLS LDP Interface status Check:\n%s\n' % (i
, diff
))
251 fatal_error
= "MPLS LDP Interface status failed"
253 assert failures
== 0, "MPLS LDP Interface status failed for router r%s:\n%s" % (i
, diff
)
255 # For debugging after starting FRR/Quagga daemons, uncomment the next line
259 def test_mpls_ldp_neighbor_establish():
264 # Skip if previous fatal error condition is raised
265 if (fatal_error
!= ""):
266 pytest
.skip(fatal_error
)
268 # Wait for OSPF6 to converge (All Neighbors in either Full or TwoWay State)
269 print("\n\n** Verify MPLS LDP neighbors to establish")
270 print("******************************************\n")
273 print("Timeout in %s: " % timeout
),
275 # Look for any node not yet converged
276 for i
in range(1, 5):
277 established
= net
['r%s' % i
].cmd('vtysh -c "show mpls ldp neighbor" 2> /dev/null').rstrip()
278 if cli_version
!= "-1":
279 # On current version, we need to make sure they all turn to OPERATIONAL on all lines
281 lines
= ('\n'.join(established
.splitlines()) + '\n').splitlines(1)
282 # Check all lines to be either table header (starting with ^AF or show OPERATIONAL)
284 operational
= r
'^ip.*OPERATIONAL.*'
285 found_operational
= 0
286 for j
in range(1, len(lines
)):
287 if (not re
.search(header
, lines
[j
])) and (not re
.search(operational
, lines
[j
])):
288 established
= "" # Empty string shows NOT established
289 if re
.search(operational
, lines
[j
]):
290 found_operational
+= 1
291 if found_operational
< 1:
292 # Need at least one operational neighbor
293 established
= "" # Empty string shows NOT established
295 print('Waiting for r%s' %i)
305 # Bail out with error if a router fails to converge
306 fatal_error
= "MPLS LDP neighbors did not establish"
307 assert False, "MPLS LDP neighbors did not establish" % ospfStatus
309 print("MPLS LDP neighbors established.")
312 # Only wait if we actually went through a convergence
313 print("\nwaiting 15s for LDP sessions to establish")
317 def test_mpls_ldp_discovery():
322 # Skip if previous fatal error condition is raised
323 if (fatal_error
!= ""):
324 pytest
.skip(fatal_error
)
326 thisDir
= os
.path
.dirname(os
.path
.realpath(__file__
))
328 # Verify OSPFv3 Routing Table
329 print("\n\n** Verifying MPLS LDP discovery")
330 print("******************************************\n")
332 for i
in range(1, 5):
333 refTableFile
= '%s/r%s/show_mpls_ldp_discovery.ref%s' % (thisDir
, i
, cli_version
)
334 if os
.path
.isfile(refTableFile
):
335 # Actual output from router
336 actual
= net
['r%s' % i
].cmd('vtysh -c "show mpls ldp discovery" 2> /dev/null').rstrip()
338 # Read expected result from file
339 expected
= open(refTableFile
).read().rstrip()
340 # Fix newlines (make them all the same)
341 expected
= ('\n'.join(expected
.splitlines()) + '\n').splitlines(1)
343 # Actual output from router
344 actual
= net
['r%s' % i
].cmd('vtysh -c "show mpls ldp discovery" 2> /dev/null').rstrip()
346 # Fix newlines (make them all the same)
347 actual
= ('\n'.join(actual
.splitlines()) + '\n').splitlines(1)
350 diff
= ''.join(difflib
.context_diff(actual
, expected
,
351 fromfile
="actual MPLS LDP discovery output",
352 tofile
="expected MPLS LDP discovery output"))
354 # Empty string if it matches, otherwise diff contains unified diff
356 sys
.stderr
.write('r%s failed MPLS LDP discovery output Check:\n%s\n' % (i
, diff
))
361 assert failures
== 0, "MPLS LDP Interface discovery output for router r%s:\n%s" % (i
, diff
)
363 # For debugging after starting FRR/Quagga daemons, uncomment the next line
367 def test_mpls_ldp_neighbor():
372 # Skip if previous fatal error condition is raised
373 if (fatal_error
!= ""):
374 pytest
.skip(fatal_error
)
376 thisDir
= os
.path
.dirname(os
.path
.realpath(__file__
))
378 # Verify OSPFv3 Routing Table
379 print("\n\n** Verifying MPLS LDP neighbor")
380 print("******************************************\n")
382 for i
in range(1, 5):
383 refTableFile
= '%s/r%s/show_mpls_ldp_neighbor.ref%s' % (thisDir
, i
, cli_version
)
384 if os
.path
.isfile(refTableFile
):
385 # Read expected result from file
386 expected
= open(refTableFile
).read().rstrip()
387 # Fix newlines (make them all the same)
388 expected
= ('\n'.join(expected
.splitlines()) + '\n').splitlines(1)
390 # Actual output from router
391 actual
= net
['r%s' % i
].cmd('vtysh -c "show mpls ldp neighbor" 2> /dev/null').rstrip()
393 # Mask out changing parts in output
394 if cli_version
== "-1":
395 # Mask out Timer in Uptime
396 actual
= re
.sub(r
"Up time: [0-9][0-9]:[0-9][0-9]:[0-9][0-9]", "Up time: xx:xx:xx", actual
)
397 # Mask out Port numbers in TCP connection
398 actual
= re
.sub(r
"TCP connection: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]):[0-9]+ - ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]):[0-9]+",
399 r
"TCP connection: \1:xxx - \2:xxx", actual
)
403 # Mask out Timer in Uptime
404 actual
= re
.sub(r
"(ipv4 [0-9\.]+ +OPERATIONAL [0-9\.]+ +)[0-9][0-9]:[0-9][0-9]:[0-9][0-9]", r
"\1xx:xx:xx", actual
)
406 # Fix newlines (make them all the same)
407 actual
= ('\n'.join(actual
.splitlines()) + '\n').splitlines(1)
410 diff
= ''.join(difflib
.context_diff(actual
, expected
,
411 fromfile
="actual MPLS LDP neighbor output",
412 tofile
="expected MPLS LDP neighbor output"))
414 # Empty string if it matches, otherwise diff contains unified diff
416 sys
.stderr
.write('r%s failed MPLS LDP neighbor output Check:\n%s\n' % (i
, diff
))
421 assert failures
== 0, "MPLS LDP Interface neighbor output for router r%s:\n%s" % (i
, diff
)
423 # For debugging after starting FRR/Quagga daemons, uncomment the next line
427 def test_mpls_ldp_binding():
432 # Skip this test for now until proper sorting of the output
434 # pytest.skip("Skipping test_mpls_ldp_binding")
436 # Skip if previous fatal error condition is raised
437 if (fatal_error
!= ""):
438 pytest
.skip(fatal_error
)
440 thisDir
= os
.path
.dirname(os
.path
.realpath(__file__
))
442 # Verify OSPFv3 Routing Table
443 print("\n\n** Verifying MPLS LDP binding")
444 print("******************************************\n")
446 for i
in range(1, 5):
447 refTableFile
= '%s/r%s/show_mpls_ldp_binding.ref%s' % (thisDir
, i
, cli_version
)
448 if os
.path
.isfile(refTableFile
):
449 # Read expected result from file
450 expected
= open(refTableFile
).read().rstrip()
451 # Fix newlines (make them all the same)
452 expected
= ('\n'.join(expected
.splitlines()) + '\n').splitlines(1)
454 # Actual output from router
455 actual
= net
['r%s' % i
].cmd('vtysh -c "show mpls ldp binding" 2> /dev/null').rstrip()
457 # Mask out changing parts in output
458 if cli_version
== "-1":
460 actual
= re
.sub(r
"label: [0-9]+", "label: xxx", actual
)
461 actual
= re
.sub(r
"(\s+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[ ]+)[0-9]+", r
"\1xxx", actual
)
466 actual
= re
.sub(r
"(ipv4 [0-9\./]+ +[0-9\.]+ +)[0-9][0-9] (.*)", r
"\1xxx\2", actual
)
467 actual
= re
.sub(r
"(ipv4 [0-9\./]+ +[0-9\.]+ +[a-z\-]+ +)[0-9][0-9] (.*)", r
"\1xxx\2", actual
)
469 # Fix newlines (make them all the same)
470 actual
= ('\n'.join(actual
.splitlines()) + '\n').splitlines(1)
472 # Sort lines which start with "xx via inet "
473 pattern
= r
'^\s+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s+'
477 for j
in range(1, len(actual
)):
478 if re
.search(pattern
, actual
[j
]) and re
.search(pattern
, actual
[j
-1]):
479 if actual
[j
-1] > actual
[j
]:
481 actual
[j
-1] = actual
[j
]
486 diff
= ''.join(difflib
.context_diff(actual
, expected
,
487 fromfile
="actual MPLS LDP binding output",
488 tofile
="expected MPLS LDP binding output"))
490 # Empty string if it matches, otherwise diff contains unified diff
492 sys
.stderr
.write('r%s failed MPLS LDP binding output Check:\n%s\n' % (i
, diff
))
497 assert failures
== 0, "MPLS LDP Interface binding output for router r%s:\n%s" % (i
, diff
)
499 # For debugging after starting FRR/Quagga daemons, uncomment the next line
503 def test_zebra_ipv4_routingTable():
508 # Skip if previous fatal error condition is raised
509 if (fatal_error
!= ""):
510 pytest
.skip(fatal_error
)
512 thisDir
= os
.path
.dirname(os
.path
.realpath(__file__
))
514 # Verify OSPFv3 Routing Table
515 print("\n\n** Verifying Zebra IPv4 Routing Table")
516 print("******************************************\n")
518 for i
in range(1, 5):
519 refTableFile
= '%s/r%s/show_ipv4_route.ref%s' % (thisDir
, i
, cli_version
)
520 if os
.path
.isfile(refTableFile
):
521 # Read expected result from file
522 expected
= open(refTableFile
).read().rstrip()
523 # Fix newlines (make them all the same)
524 expected
= ('\n'.join(expected
.splitlines()) + '\n').splitlines(1)
526 # Actual output from router
527 actual
= net
['r%s' % i
].cmd('vtysh -c "show ip route" 2> /dev/null | grep "^O"').rstrip()
528 # Drop timers on end of line (older Quagga Versions)
529 actual
= re
.sub(r
", [0-2][0-9]:[0-5][0-9]:[0-5][0-9]", "", actual
)
531 actual
= re
.sub(r
" label [0-9]+", " label xxx", actual
)
532 # Add missing comma before label (for old version)
533 actual
= re
.sub(r
"([0-9]) label xxx", r
"\1, label xxx", actual
)
535 # Fix newlines (make them all the same)
536 actual
= ('\n'.join(actual
.splitlines()) + '\n').splitlines(1)
539 diff
= ''.join(difflib
.context_diff(actual
, expected
,
540 fromfile
="actual IPv4 zebra routing table",
541 tofile
="expected IPv4 zera routing table"))
543 # Empty string if it matches, otherwise diff contains unified diff
545 sys
.stderr
.write('r%s failed IPv4 Zebra Routing Table Check:\n%s\n' % (i
, diff
))
550 assert failures
== 0, "IPv4 Zebra Routing Table verification failed for router r%s:\n%s" % (i
, diff
)
552 # For debugging after starting FRR/Quagga daemons, uncomment the next line
556 def test_mpls_table():
561 # Skip if previous fatal error condition is raised
562 if (fatal_error
!= ""):
563 pytest
.skip(fatal_error
)
565 thisDir
= os
.path
.dirname(os
.path
.realpath(__file__
))
567 # Verify OSPFv3 Routing Table
568 print("\n\n** Verifying MPLS table")
569 print("******************************************\n")
571 for i
in range(1, 5):
572 refTableFile
= '%s/r%s/show_mpls_table.ref%s' % (thisDir
, i
, cli_version
)
573 if os
.path
.isfile(refTableFile
):
574 # Read expected result from file
575 expected
= open(refTableFile
).read().rstrip()
576 # Fix newlines (make them all the same)
577 expected
= ('\n'.join(expected
.splitlines()) + '\n').splitlines(1)
579 # Actual output from router
580 actual
= net
['r%s' % i
].cmd('vtysh -c "show mpls table" 2> /dev/null').rstrip()
582 # Fix inconsistent Label numbers at beginning of line
583 actual
= re
.sub(r
"(\s+)[0-9]+(\s+LDP)", r
"\1XX\2", actual
)
584 # Fix inconsistent Label numbers at end of line
585 actual
= re
.sub(r
"(\s+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s+)[0-9][0-9]", r
"\1XX", actual
)
587 # Fix newlines (make them all the same)
588 actual
= ('\n'.join(actual
.splitlines()) + '\n').splitlines(1)
590 # Sort lines which start with " XX LDP"
591 pattern
= r
'^\s+[0-9X]+\s+LDP'
595 for j
in range(1, len(actual
)):
596 if re
.search(pattern
, actual
[j
]) and re
.search(pattern
, actual
[j
-1]):
597 if actual
[j
-1] > actual
[j
]:
599 actual
[j
-1] = actual
[j
]
604 diff
= ''.join(difflib
.context_diff(actual
, expected
,
605 fromfile
="actual MPLS table output",
606 tofile
="expected MPLS table output"))
608 # Empty string if it matches, otherwise diff contains unified diff
610 sys
.stderr
.write('r%s failed MPLS table output Check:\n%s\n' % (i
, diff
))
615 assert failures
== 0, "MPLS table output for router r%s:\n%s" % (i
, diff
)
617 # For debugging after starting FRR/Quagga daemons, uncomment the next line
621 def test_linux_mpls_routes():
626 # Skip if previous fatal error condition is raised
627 if (fatal_error
!= ""):
628 pytest
.skip(fatal_error
)
630 thisDir
= os
.path
.dirname(os
.path
.realpath(__file__
))
632 # Verify OSPFv3 Routing Table
633 print("\n\n** Verifying Linux Kernel MPLS routes")
634 print("******************************************\n")
636 for i
in range(1, 5):
637 refTableFile
= '%s/r%s/ip_mpls_route.ref%s' % (thisDir
, i
, cli_version
)
638 if os
.path
.isfile(refTableFile
):
639 # Read expected result from file
640 expected
= open(refTableFile
).read().rstrip()
641 # Fix newlines (make them all the same)
642 expected
= ('\n'.join(expected
.splitlines()) + '\n').splitlines(1)
644 # Actual output from router
645 actual
= net
['r%s' % i
].cmd('ip -family mpls route 2> /dev/null').rstrip()
647 actual
= re
.sub(r
"[0-9][0-9] via inet ", "xx via inet ", actual
)
648 actual
= re
.sub(r
"[0-9][0-9] proto zebra", "xx proto zebra", actual
)
649 actual
= re
.sub(r
"[0-9][0-9] as to ", "xx as to ", actual
)
650 actual
= re
.sub(r
"proto zebra ", "proto zebra", actual
)
652 # Fix newlines (make them all the same)
653 actual
= ('\n'.join(actual
.splitlines()) + '\n').splitlines(1)
655 # Sort lines which start with "xx via inet "
656 pattern
= r
'^xx via inet '
660 for j
in range(1, len(actual
)):
661 if re
.search(pattern
, actual
[j
]) and re
.search(pattern
, actual
[j
-1]):
662 if actual
[j
-1] > actual
[j
]:
664 actual
[j
-1] = actual
[j
]
668 # Sort lines which start with " nexthopvia"
669 pattern
= r
'^\snexthopvia '
673 for j
in range(1, len(actual
)):
674 if re
.search(pattern
, actual
[j
]) and re
.search(pattern
, actual
[j
-1]):
675 if actual
[j
-1] > actual
[j
]:
677 actual
[j
-1] = actual
[j
]
681 # Sort Sections of "xx proto zebra" (with all the indented lines below)
682 pattern
= r
'^xx via inet '
683 # Join paragraphs first
685 temp
= [actual
[0].rstrip()]
686 for k
in range(1, len(actual
)):
687 if re
.search(r
'^\s', actual
[k
]):
689 temp
[j
] += '\n' + actual
[k
].rstrip()
692 temp
.append(actual
[k
].rstrip())
695 # Now write sort array back
697 for k
in range(0, len(temp
)):
698 actual
.extend(temp
[k
].splitlines())
699 # put \n back at line ends
700 actual
= ('\n'.join(actual
) + '\n').splitlines(1)
703 diff
= ''.join(difflib
.context_diff(actual
, expected
,
704 fromfile
="actual Linux Kernel MPLS route",
705 tofile
="expected Linux Kernel MPLS route"))
707 # Empty string if it matches, otherwise diff contains unified diff
709 sys
.stderr
.write('r%s failed Linux Kernel MPLS route output Check:\n%s\n' % (i
, diff
))
714 assert failures
== 0, "Linux Kernel MPLS route output for router r%s:\n%s" % (i
, diff
)
716 # For debugging after starting FRR/Quagga daemons, uncomment the next line
720 def test_shutdown_check_stderr():
724 # Skip if previous fatal error condition is raised
725 if (fatal_error
!= ""):
726 pytest
.skip(fatal_error
)
728 if os
.environ
.get('TOPOTESTS_CHECK_STDERR') is None:
729 print("SKIPPED final check on StdErr output: Disabled (TOPOTESTS_CHECK_STDERR undefined)\n")
730 pytest
.skip('Skipping test for Stderr output')
732 thisDir
= os
.path
.dirname(os
.path
.realpath(__file__
))
734 print("\n\n** Verifying unexpected STDERR output from daemons")
735 print("******************************************\n")
737 for i
in range(1, 5):
738 net
['r%s' % i
].stopRouter()
739 log
= net
['r%s' % i
].getStdErr('ldpd')
740 print("\nRouter r%s LDPd StdErr Log:\n%s" % (i
, log
))
741 log
= net
['r%s' % i
].getStdErr('ospfd')
742 print("\nRouter r%s OSPFd StdErr Log:\n%s" % (i
, log
))
743 log
= net
['r%s' % i
].getStdErr('zebra')
744 print("\nRouter r%s Zebra StdErr Log:\n%s" % (i
, log
))
747 def test_shutdown_check_memleak():
751 # Skip if previous fatal error condition is raised
752 if (fatal_error
!= ""):
753 pytest
.skip(fatal_error
)
755 if os
.environ
.get('TOPOTESTS_CHECK_MEMLEAK') is None:
756 print("SKIPPED final check on Memory leaks: Disabled (TOPOTESTS_CHECK_MEMLEAK undefined)\n")
757 pytest
.skip('Skipping test for memory leaks')
759 thisDir
= os
.path
.dirname(os
.path
.realpath(__file__
))
761 for i
in range(1, 5):
762 net
['r%s' % i
].stopRouter()
763 net
['r%s' % i
].report_memory_leaks(os
.environ
.get('TOPOTESTS_CHECK_MEMLEAK'), os
.path
.basename(__file__
))
766 if __name__
== '__main__':
769 # To suppress tracebacks, either use the following pytest call or add "--tb=no" to cli
770 # retval = pytest.main(["-s", "--tb=no"])
771 retval
= pytest
.main(["-s"])