diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-09 13:16:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-09 13:16:35 +0000 |
commit | e2bbf175a2184bd76f6c54ccf8456babeb1a46fc (patch) | |
tree | f0b76550d6e6f500ada964a3a4ee933a45e5a6f1 /tests/topotests/ripng_topo1 | |
parent | Initial commit. (diff) | |
download | frr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.tar.xz frr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.zip |
Adding upstream version 9.1.upstream/9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/topotests/ripng_topo1')
18 files changed, 671 insertions, 0 deletions
diff --git a/tests/topotests/ripng_topo1/r1/ripng_status.ref b/tests/topotests/ripng_topo1/r1/ripng_status.ref new file mode 100644 index 0000000..d92ae05 --- /dev/null +++ b/tests/topotests/ripng_topo1/r1/ripng_status.ref @@ -0,0 +1,20 @@ +Routing Protocol is "RIPng" + Sending updates every 1 seconds with +/-50%, next due in XX seconds + Timeout after 180 seconds, garbage collect after 5 seconds + Outgoing update filter list for all interface is not set + Incoming update filter list for all interface is not set + Default redistribution metric is 1 + Redistributing: + Default version control: send version 1, receive version 1 + Interface Send Recv + r1-eth1 1 1 + r1-eth2 1 1 + r1-eth3 1 1 + Routing for Networks: + fc00:5::/64 + r1-eth2 + r1-eth3 + Routing Information Sources: + Gateway BadPackets BadRoutes Distance Last Update + fe80::XXXX:XXXX:XXXX:XXXX + 0 0 120 XX:XX:XX diff --git a/tests/topotests/ripng_topo1/r1/ripngd.conf b/tests/topotests/ripng_topo1/r1/ripngd.conf new file mode 100644 index 0000000..f96297b --- /dev/null +++ b/tests/topotests/ripng_topo1/r1/ripngd.conf @@ -0,0 +1,16 @@ +log file ripngd.log +! +! debug ripng events +! debug ripng packet +! debug ripng zebra +! +router ripng + timers basic 1 180 5 + network fc00:5::/64 + network r1-eth2 + network r1-eth3 + passive-interface r1-eth3 +! +line vty +! + diff --git a/tests/topotests/ripng_topo1/r1/show_ipv6_ripng.ref b/tests/topotests/ripng_topo1/r1/show_ipv6_ripng.ref new file mode 100644 index 0000000..30d0f31 --- /dev/null +++ b/tests/topotests/ripng_topo1/r1/show_ipv6_ripng.ref @@ -0,0 +1,18 @@ +Codes: R - RIPng, C - connected, S - Static, O - OSPF, B - BGP +Sub-codes: + (n) - normal, (s) - static, (d) - default, (r) - redistribute, + (i) - interface, (a/S) - aggregated/Suppressed + + Network Next Hop Via Metric Tag Time +C(i) fc00:5::/64 + :: self 1 0 +R(n) fc00:6::/62 + fe80::XXXX:XXXX:XXXX:XXXX r1-eth1 2 0 XX:XX +R(n) fc00:7::/64 + fe80::XXXX:XXXX:XXXX:XXXX r1-eth1 3 0 XX:XX +R(n) fc00:7:1111::/64 + fe80::XXXX:XXXX:XXXX:XXXX r1-eth1 3 0 XX:XX +C(i) fc00:98:0:1::/64 + :: self 1 0 +C(i) fc00:99:0:1::/64 + :: self 1 0 diff --git a/tests/topotests/ripng_topo1/r1/show_ipv6_route.ref b/tests/topotests/ripng_topo1/r1/show_ipv6_route.ref new file mode 100644 index 0000000..55fbbc3 --- /dev/null +++ b/tests/topotests/ripng_topo1/r1/show_ipv6_route.ref @@ -0,0 +1,3 @@ +R>* fc00:6::/62 [120/2] via fe80::XXXX:XXXX:XXXX:XXXX, r1-eth1, weight 1 +R>* fc00:7::/64 [120/3] via fe80::XXXX:XXXX:XXXX:XXXX, r1-eth1, weight 1 +R>* fc00:7:1111::/64 [120/3] via fe80::XXXX:XXXX:XXXX:XXXX, r1-eth1, weight 1 diff --git a/tests/topotests/ripng_topo1/r1/zebra.conf b/tests/topotests/ripng_topo1/r1/zebra.conf new file mode 100644 index 0000000..11c1cdc --- /dev/null +++ b/tests/topotests/ripng_topo1/r1/zebra.conf @@ -0,0 +1,25 @@ +log file zebra.log +! +hostname r1 +! +interface r1-eth0 + ipv6 address fc00:0:0:1::1/64 +! +interface r1-eth1 + description to sw2 - RIPng interface + ipv6 address fc00:5::1/64 + no link-detect +! +interface r1-eth2 + ipv6 address fc00:99:0:1::1/64 +! +interface r1-eth3 + ipv6 address fc00:98:0:1::1/64 +! +ip forwarding +ipv6 forwarding +! +! +line vty +! + diff --git a/tests/topotests/ripng_topo1/r2/ripng_status.ref b/tests/topotests/ripng_topo1/r2/ripng_status.ref new file mode 100644 index 0000000..de14b12 --- /dev/null +++ b/tests/topotests/ripng_topo1/r2/ripng_status.ref @@ -0,0 +1,20 @@ +Routing Protocol is "RIPng" + Sending updates every 1 seconds with +/-50%, next due in XX seconds + Timeout after 180 seconds, garbage collect after 5 seconds + Outgoing update filter list for all interface is not set + Incoming update filter list for all interface is not set + Default redistribution metric is 1 + Redistributing: + Default version control: send version 1, receive version 1 + Interface Send Recv + r2-eth0 1 1 + r2-eth1 1 1 + Routing for Networks: + fc00:5::/64 + fc00:6::/62 + Routing Information Sources: + Gateway BadPackets BadRoutes Distance Last Update + fe80::XXXX:XXXX:XXXX:XXXX + 0 0 120 XX:XX:XX + fe80::XXXX:XXXX:XXXX:XXXX + 0 0 120 XX:XX:XX diff --git a/tests/topotests/ripng_topo1/r2/ripngd.conf b/tests/topotests/ripng_topo1/r2/ripngd.conf new file mode 100644 index 0000000..7a6450e --- /dev/null +++ b/tests/topotests/ripng_topo1/r2/ripngd.conf @@ -0,0 +1,13 @@ +log file ripngd.log +! +! debug ripng events +! debug ripng packet +! debug ripng zebra +! +router ripng + timers basic 1 180 5 + network fc00:5::/64 + network fc00:6::/62 +! +line vty +! diff --git a/tests/topotests/ripng_topo1/r2/show_ipv6_ripng.ref b/tests/topotests/ripng_topo1/r2/show_ipv6_ripng.ref new file mode 100644 index 0000000..fe5bcc8 --- /dev/null +++ b/tests/topotests/ripng_topo1/r2/show_ipv6_ripng.ref @@ -0,0 +1,18 @@ +Codes: R - RIPng, C - connected, S - Static, O - OSPF, B - BGP +Sub-codes: + (n) - normal, (s) - static, (d) - default, (r) - redistribute, + (i) - interface, (a/S) - aggregated/Suppressed + + Network Next Hop Via Metric Tag Time +C(i) fc00:5::/64 + :: self 1 0 +C(i) fc00:6::/62 + :: self 1 0 +R(n) fc00:7::/64 + fe80::XXXX:XXXX:XXXX:XXXX r2-eth1 2 0 XX:XX +R(n) fc00:7:1111::/64 + fe80::XXXX:XXXX:XXXX:XXXX r2-eth1 2 0 XX:XX +R(n) fc00:98:0:1::/64 + fe80::XXXX:XXXX:XXXX:XXXX r2-eth0 2 0 XX:XX +R(n) fc00:99:0:1::/64 + fe80::XXXX:XXXX:XXXX:XXXX r2-eth0 2 0 XX:XX diff --git a/tests/topotests/ripng_topo1/r2/show_ipv6_route.ref b/tests/topotests/ripng_topo1/r2/show_ipv6_route.ref new file mode 100644 index 0000000..72e1f92 --- /dev/null +++ b/tests/topotests/ripng_topo1/r2/show_ipv6_route.ref @@ -0,0 +1,4 @@ +R>* fc00:7::/64 [120/2] via fe80::XXXX:XXXX:XXXX:XXXX, r2-eth1, weight 1 +R>* fc00:7:1111::/64 [120/2] via fe80::XXXX:XXXX:XXXX:XXXX, r2-eth1, weight 1 +R>* fc00:98:0:1::/64 [120/2] via fe80::XXXX:XXXX:XXXX:XXXX, r2-eth0, weight 1 +R>* fc00:99:0:1::/64 [120/2] via fe80::XXXX:XXXX:XXXX:XXXX, r2-eth0, weight 1 diff --git a/tests/topotests/ripng_topo1/r2/zebra.conf b/tests/topotests/ripng_topo1/r2/zebra.conf new file mode 100644 index 0000000..5900631 --- /dev/null +++ b/tests/topotests/ripng_topo1/r2/zebra.conf @@ -0,0 +1,21 @@ +log file zebra.log +! +hostname r2 +! +interface r2-eth0 + description to sw2 - RIPng interface + ipv6 address fc00:5::2/64 + no link-detect +! +interface r2-eth1 + description to sw3 - RIPng interface + ipv6 address fc00:6::1/62 + no link-detect +! +ip forwarding +ipv6 forwarding +! +! +line vty +! + diff --git a/tests/topotests/ripng_topo1/r3/ripng_status.ref b/tests/topotests/ripng_topo1/r3/ripng_status.ref new file mode 100644 index 0000000..bef2361 --- /dev/null +++ b/tests/topotests/ripng_topo1/r3/ripng_status.ref @@ -0,0 +1,16 @@ +Routing Protocol is "RIPng" + Sending updates every 1 seconds with +/-50%, next due in XX seconds + Timeout after 180 seconds, garbage collect after 5 seconds + Outgoing update filter list for all interface is not set + Incoming update filter list for all interface is not set + Default redistribution metric is 1 + Redistributing: connected static + Default version control: send version 1, receive version 1 + Interface Send Recv + r3-eth1 1 1 + Routing for Networks: + fc00:6::/62 + Routing Information Sources: + Gateway BadPackets BadRoutes Distance Last Update + fe80::XXXX:XXXX:XXXX:XXXX + 0 0 120 XX:XX:XX diff --git a/tests/topotests/ripng_topo1/r3/ripngd.conf b/tests/topotests/ripng_topo1/r3/ripngd.conf new file mode 100644 index 0000000..7a07080 --- /dev/null +++ b/tests/topotests/ripng_topo1/r3/ripngd.conf @@ -0,0 +1,15 @@ +log file ripngd.log +! +! debug ripng events +! debug ripng packet +! debug ripng zebra +! +router ripng + timers basic 1 180 5 + network fc00:6::/62 + redistribute connected + redistribute static +! +line vty +! + diff --git a/tests/topotests/ripng_topo1/r3/show_ipv6_ripng.ref b/tests/topotests/ripng_topo1/r3/show_ipv6_ripng.ref new file mode 100644 index 0000000..909ad66 --- /dev/null +++ b/tests/topotests/ripng_topo1/r3/show_ipv6_ripng.ref @@ -0,0 +1,18 @@ +Codes: R - RIPng, C - connected, S - Static, O - OSPF, B - BGP +Sub-codes: + (n) - normal, (s) - static, (d) - default, (r) - redistribute, + (i) - interface, (a/S) - aggregated/Suppressed + + Network Next Hop Via Metric Tag Time +R(n) fc00:5::/64 + fe80::XXXX:XXXX:XXXX:XXXX r3-eth1 2 0 XX:XX +C(i) fc00:6::/62 + :: self 1 0 +C(r) fc00:7::/64 + :: self 1 0 +S(r) fc00:7:1111::/64 + :: self 1 0 +R(n) fc00:98:0:1::/64 + fe80::XXXX:XXXX:XXXX:XXXX r3-eth1 3 0 XX:XX +R(n) fc00:99:0:1::/64 + fe80::XXXX:XXXX:XXXX:XXXX r3-eth1 3 0 XX:XX diff --git a/tests/topotests/ripng_topo1/r3/show_ipv6_route.ref b/tests/topotests/ripng_topo1/r3/show_ipv6_route.ref new file mode 100644 index 0000000..25a7440 --- /dev/null +++ b/tests/topotests/ripng_topo1/r3/show_ipv6_route.ref @@ -0,0 +1,3 @@ +R>* fc00:5::/64 [120/2] via fe80::XXXX:XXXX:XXXX:XXXX, r3-eth1, weight 1 +R>* fc00:98:0:1::/64 [120/3] via fe80::XXXX:XXXX:XXXX:XXXX, r3-eth1, weight 1 +R>* fc00:99:0:1::/64 [120/3] via fe80::XXXX:XXXX:XXXX:XXXX, r3-eth1, weight 1 diff --git a/tests/topotests/ripng_topo1/r3/zebra.conf b/tests/topotests/ripng_topo1/r3/zebra.conf new file mode 100644 index 0000000..b43ba69 --- /dev/null +++ b/tests/topotests/ripng_topo1/r3/zebra.conf @@ -0,0 +1,22 @@ +log file zebra.log +! +hostname r3 +! +interface r3-eth0 + description to sw2 - Stub interface + ipv6 address fc00:7::1/64 + no link-detect +! +interface r3-eth1 + description to sw3 - RIPng interface + ipv6 address fc00:6::2/62 + no link-detect +! +ipv6 route fc00:7:1111::/64 fc00:7::10 +! +ip forwarding +ipv6 forwarding +! +! +line vty +! diff --git a/tests/topotests/ripng_topo1/test_ripng_topo1.dot b/tests/topotests/ripng_topo1/test_ripng_topo1.dot new file mode 100644 index 0000000..7d66a2a --- /dev/null +++ b/tests/topotests/ripng_topo1/test_ripng_topo1.dot @@ -0,0 +1,59 @@ +## GraphViz file for test_all_protocol_topo1 +## +## Color coding: +######################### +## Main FRR: #f08080 red +## Switches: #d0e0d0 gray +## RIP: #19e3d9 Cyan +## RIPng: #fcb314 dark yellow +## OSPFv2: #32b835 Green +## OSPFv3: #19e3d9 Cyan +## ISIS IPv4 #fcb314 dark yellow +## ISIS IPv6 #9a81ec purple +## BGP IPv4 #eee3d3 beige +## BGP IPv6 #fdff00 yellow +##### Colors (see http://www.color-hex.com/) + +graph test_ripng_topo1 { + + // title + labelloc="t"; + label="Test Topologoy RIPng Topo1"; + + ###################### + # Routers + ###################### + + # Main FRR Router with all protocols + R1 [shape=doubleoctagon, label="R1 FRR\nMain Router", fillcolor="#f08080", style=filled]; + + # RIPng Routers + R2 [shape=doubleoctagon, label="R2 FRR\nRIPng Router", fillcolor="#fcb314", style=filled]; + R3 [shape=doubleoctagon, label="R3 FRR\nRIPng Router", fillcolor="#fcb314", style=filled]; + + ###################### + # Network Lists + ###################### + + SW1_R1_stub [label="SW1\nfc00:0:0:1::/64", fillcolor="#d0e0d0", style=filled]; + + # RIPng Networks + SW2_R1_R2 [label="SW2\nRIPng\nfc00:5:0:0::/64", fillcolor="#d0e0d0", style=filled]; + SW3_R2_R3 [label="SW3\nRIPng\nfc00:6:0:0::/62", fillcolor="#d0e0d0", style=filled]; + SW4_R3 [label="SW4\nfc00::7/128", fillcolor="#d0e0d0", style=filled]; + Net_R3_remote [label="Static Net\nfc00:7:1111::/64"]; + + ###################### + # Network Connections + ###################### + R1 -- SW1_R1_stub [label = "r1-eth0\n::1"]; + + # RIPng Network + R1 -- SW2_R1_R2 [label = "r1-eth1\n::1"]; + SW2_R1_R2 -- R2 [label = "r2-eth0\n::2"]; + R2 -- SW3_R2_R3 [label = "r2-eth1\n::1"]; + SW3_R2_R3 -- R3 [label = "r3-eth1\n::2"]; + R3 -- SW4_R3 [label = "r3-eth0\n::1"]; + SW4_R3 -- Net_R3_remote [label = ":10"]; + +} diff --git a/tests/topotests/ripng_topo1/test_ripng_topo1.pdf b/tests/topotests/ripng_topo1/test_ripng_topo1.pdf Binary files differnew file mode 100644 index 0000000..cb1adde --- /dev/null +++ b/tests/topotests/ripng_topo1/test_ripng_topo1.pdf diff --git a/tests/topotests/ripng_topo1/test_ripng_topo1.py b/tests/topotests/ripng_topo1/test_ripng_topo1.py new file mode 100644 index 0000000..6bebf60 --- /dev/null +++ b/tests/topotests/ripng_topo1/test_ripng_topo1.py @@ -0,0 +1,380 @@ +#!/usr/bin/env python +# SPDX-License-Identifier: ISC + +# +# test_ripng_topo1.py +# Part of NetDEF Topology Tests +# +# Copyright (c) 2017 by +# Network Device Education Foundation, Inc. ("NetDEF") +# + +""" +test_ripng_topo1.py: Test of RIPng Topology + +""" + +import os +import re +import sys +import pytest +from time import sleep +import functools + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from lib import topotest +from lib.topogen import Topogen, get_topogen + +fatal_error = "" + +pytestmark = [pytest.mark.ripd] + +##################################################### +## +## Network Topology Definition +## +##################################################### + + +def build_topo(tgen): + # Setup RIPng Routers + for i in range(1, 4): + tgen.add_router("r%s" % i) + + # + # On main router + # First switch is for a dummy interface (for local network) + switch = tgen.add_switch("sw1") + switch.add_link(tgen.gears["r1"]) + # + # Switches for RIPng + # switch 2 switch is for connection to RIP router + switch = tgen.add_switch("sw2") + switch.add_link(tgen.gears["r1"]) + switch.add_link(tgen.gears["r2"]) + # switch 3 is between RIP routers + switch = tgen.add_switch("sw3") + switch.add_link(tgen.gears["r2"]) + switch.add_link(tgen.gears["r3"], nodeif="r3-eth1") + # switch 4 is stub on remote RIP router + switch = tgen.add_switch("sw4") + switch.add_link(tgen.gears["r3"], nodeif="r3-eth0") + + switch = tgen.add_switch("sw5") + switch.add_link(tgen.gears["r1"]) + switch = tgen.add_switch("sw6") + switch.add_link(tgen.gears["r1"]) + + +##################################################### +## +## Tests starting +## +##################################################### + + +def setup_module(module): + print("\n\n** %s: Setup Topology" % module.__name__) + print("******************************************\n") + + thisDir = os.path.dirname(os.path.realpath(__file__)) + tgen = Topogen(build_topo, module.__name__) + tgen.start_topology() + + net = tgen.net + + # Starting Routers + # + for i in range(1, 4): + net["r%s" % i].loadConf("zebra", "%s/r%s/zebra.conf" % (thisDir, i)) + net["r%s" % i].loadConf("ripngd", "%s/r%s/ripngd.conf" % (thisDir, i)) + tgen.gears["r%s" % i].start() + + # For debugging after starting FRR daemons, uncomment the next line + # tgen.mininet_cli() + + +def teardown_module(module): + print("\n\n** %s: Shutdown Topology" % module.__name__) + print("******************************************\n") + tgen = get_topogen() + tgen.stop_topology() + + +def test_router_running(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + print("\n\n** Check if FRR is running on each Router node") + print("******************************************\n") + + # Starting Routers + for i in range(1, 4): + fatal_error = net["r%s" % i].checkRouterRunning() + assert fatal_error == "", fatal_error + + +def test_converge_protocols(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + print("\n\n** Waiting for protocols convergence") + print("******************************************\n") + + # Not really implemented yet - just sleep 11 secs for now + sleep(11) + + # Make sure that all daemons are running + for i in range(1, 4): + fatal_error = net["r%s" % i].checkRouterRunning() + assert fatal_error == "", fatal_error + + +def test_ripng_status(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + # Verify RIP Status + print("\n\n** Verifying RIPng status") + print("******************************************\n") + failures = 0 + for i in range(1, 4): + refTableFile = "%s/r%s/ripng_status.ref" % (thisDir, i) + if os.path.isfile(refTableFile): + # Read expected result from file + expected = open(refTableFile).read().rstrip() + # Fix newlines (make them all the same) + expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1) + + # Actual output from router + actual = ( + net["r%s" % i] + .cmd('vtysh -c "show ipv6 ripng status" 2> /dev/null') + .rstrip() + ) + # Mask out Link-Local mac address portion. They are random... + actual = re.sub(r" fe80::[0-9a-f:]+", " fe80::XXXX:XXXX:XXXX:XXXX", actual) + # Drop time in next due + actual = re.sub(r"in [0-9]+ seconds", "in XX seconds", actual) + # Drop time in last update + actual = re.sub(r" [0-2][0-9]:[0-5][0-9]:[0-5][0-9]", " XX:XX:XX", actual) + # Fix newlines (make them all the same) + actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1) + + # Generate Diff + diff = topotest.get_textdiff( + actual, + expected, + title1="actual IPv6 RIPng status", + title2="expected IPv6 RIPng status", + ) + + # Empty string if it matches, otherwise diff contains unified diff + if diff: + sys.stderr.write( + "r%s failed IPv6 RIPng status check:\n%s\n" % (i, diff) + ) + failures += 1 + else: + print("r%s ok" % i) + + assert failures == 0, "IPv6 RIPng status failed for router r%s:\n%s" % ( + i, + diff, + ) + + # Make sure that all daemons are running + for i in range(1, 4): + fatal_error = net["r%s" % i].checkRouterRunning() + assert fatal_error == "", fatal_error + + +def test_ripng_routes(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + # Verify RIPng Status + print("\n\n** Verifying RIPng routes") + print("******************************************\n") + failures = 0 + for i in range(1, 4): + refTableFile = "%s/r%s/show_ipv6_ripng.ref" % (thisDir, i) + if os.path.isfile(refTableFile): + # Read expected result from file + expected = open(refTableFile).read().rstrip() + # Fix newlines (make them all the same) + expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1) + + # Actual output from router + actual = ( + net["r%s" % i].cmd('vtysh -c "show ipv6 ripng" 2> /dev/null').rstrip() + ) + # Drop Time + actual = re.sub(r" [0-9][0-9]:[0-5][0-9]", " XX:XX", actual) + # Mask out Link-Local mac address portion. They are random... + actual = re.sub( + r" fe80::[0-9a-f: ]+", " fe80::XXXX:XXXX:XXXX:XXXX ", actual + ) + # Remove trailing spaces on all lines + actual = "\n".join([line.rstrip() for line in actual.splitlines()]) + + # Fix newlines (make them all the same) + actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1) + + # Generate Diff + diff = topotest.get_textdiff( + actual, + expected, + title1="actual SHOW IPv6 RIPng", + title2="expected SHOW IPv6 RIPng", + ) + + # Empty string if it matches, otherwise diff contains unified diff + if diff: + sys.stderr.write("r%s failed SHOW IPv6 RIPng check:\n%s\n" % (i, diff)) + failures += 1 + else: + print("r%s ok" % i) + + assert failures == 0, "SHOW IPv6 RIPng failed for router r%s:\n%s" % ( + i, + diff, + ) + + # Make sure that all daemons are running + for i in range(1, 4): + fatal_error = net["r%s" % i].checkRouterRunning() + assert fatal_error == "", fatal_error + + +def test_zebra_ipv6_routingTable(): + global fatal_error + net = get_topogen().net + + def _verify_ip_route(expected): + # Actual output from router + actual = ( + net["r%s" % i] + .cmd('vtysh -c "show ipv6 route" 2> /dev/null | grep "^R"') + .rstrip() + ) + # Mask out Link-Local mac address portion. They are random... + actual = re.sub(r" fe80::[0-9a-f:]+", " fe80::XXXX:XXXX:XXXX:XXXX", actual) + # Drop timers on end of line + actual = re.sub(r", [0-2][0-9]:[0-5][0-9]:[0-5][0-9]", "", actual) + # Fix newlines (make them all the same) + actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1) + + return topotest.get_textdiff( + actual, + expected, + title1="actual Zebra IPv6 routing table", + title2="expected Zebra IPv6 routing table", + ) + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + # Verify OSPFv3 Routing Table + print("\n\n** Verifying Zebra IPv6 Routing Table") + print("******************************************\n") + failures = 0 + for i in range(1, 4): + refTableFile = "%s/r%s/show_ipv6_route.ref" % (thisDir, i) + if os.path.isfile(refTableFile): + # Read expected result from file + expected = open(refTableFile).read().rstrip() + # Fix newlines (make them all the same) + expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1) + + test_func = functools.partial(_verify_ip_route, expected) + success, _ = topotest.run_and_expect(test_func, "", count=30, wait=1) + assert success, "Failed verifying IPv6 routes for r{}".format(i) + + # Make sure that all daemons are running + for i in range(1, 4): + fatal_error = net["r%s" % i].checkRouterRunning() + assert fatal_error == "", fatal_error + + +def test_shutdown_check_stderr(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + if os.environ.get("TOPOTESTS_CHECK_STDERR") is None: + print( + "SKIPPED final check on StdErr output: Disabled (TOPOTESTS_CHECK_STDERR undefined)\n" + ) + pytest.skip("Skipping test for Stderr output") + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + print("\n\n** Verifying unexpected STDERR output from daemons") + print("******************************************\n") + + net["r1"].stopRouter() + + log = net["r1"].getStdErr("ripngd") + if log: + print("\nRIPngd StdErr Log:\n" + log) + log = net["r1"].getStdErr("zebra") + if log: + print("\nZebra StdErr Log:\n" + log) + + +def test_shutdown_check_memleak(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + if os.environ.get("TOPOTESTS_CHECK_MEMLEAK") is None: + print( + "SKIPPED final check on Memory leaks: Disabled (TOPOTESTS_CHECK_MEMLEAK undefined)\n" + ) + pytest.skip("Skipping test for memory leaks") + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + net["r1"].stopRouter() + net["r1"].report_memory_leaks( + os.environ.get("TOPOTESTS_CHECK_MEMLEAK"), os.path.basename(__file__) + ) + + +if __name__ == "__main__": + # To suppress tracebacks, either use the following pytest call or add "--tb=no" to cli + # retval = pytest.main(["-s", "--tb=no"]) + retval = pytest.main(["-s"]) + sys.exit(retval) |