diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:53:30 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:53:30 +0000 |
commit | 2c7cac91ed6e7db0f6937923d2b57f97dbdbc337 (patch) | |
tree | c05dc0f8e6aa3accc84e3e5cffc933ed94941383 /tests/topotests/eigrp_topo1 | |
parent | Initial commit. (diff) | |
download | frr-upstream.tar.xz frr-upstream.zip |
Adding upstream version 8.4.4.upstream/8.4.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/topotests/eigrp_topo1')
17 files changed, 864 insertions, 0 deletions
diff --git a/tests/topotests/eigrp_topo1/r1/eigrpd.conf b/tests/topotests/eigrp_topo1/r1/eigrpd.conf new file mode 100644 index 0000000..6c800ab --- /dev/null +++ b/tests/topotests/eigrp_topo1/r1/eigrpd.conf @@ -0,0 +1,8 @@ +log file eigrpd.log +! +router eigrp 1 + network 0.0.0.0/0 +! +line vty +! + diff --git a/tests/topotests/eigrp_topo1/r1/show_ip_eigrp.json b/tests/topotests/eigrp_topo1/r1/show_ip_eigrp.json new file mode 100644 index 0000000..be0fdcf --- /dev/null +++ b/tests/topotests/eigrp_topo1/r1/show_ip_eigrp.json @@ -0,0 +1,32 @@ +{ + "P": { + "192.168.1.0/24": { + "fd": "28160", + "interface": " r1-eth0", + "serno": "0", + "successors": "1", + "via": "Connected" + }, + "192.168.3.0/24": { + "fd": "33280", + "interface": " r1-eth1", + "serno": "0", + "successors": "1", + "via": "193.1.1.2 (33280/30720)" + }, + "193.1.1.0/26": { + "fd": "28160", + "interface": " r1-eth1", + "serno": "0", + "successors": "1", + "via": "Connected" + }, + "193.1.2.0/24": { + "fd": "30720", + "interface": " r1-eth1", + "serno": "0", + "successors": "1", + "via": "193.1.1.2 (30720/28160)" + } + } +} diff --git a/tests/topotests/eigrp_topo1/r1/show_ip_eigrp.ref b/tests/topotests/eigrp_topo1/r1/show_ip_eigrp.ref new file mode 100644 index 0000000..a2d7b33 --- /dev/null +++ b/tests/topotests/eigrp_topo1/r1/show_ip_eigrp.ref @@ -0,0 +1,14 @@ + +EIGRP Topology Table for AS(1)/ID(193.1.1.1) + +Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply + r - reply Status, s - sia Status + +P 193.1.1.0/26, 1 successors, FD is 28160, serno: 0 + via Connected, r1-eth1 +P 192.168.1.0/24, 1 successors, FD is 28160, serno: 0 + via Connected, r1-eth0 +P 193.1.2.0/24, 1 successors, FD is 30720, serno: 0 + via 193.1.1.2 (30720/28160), r1-eth1 +P 192.168.3.0/24, 1 successors, FD is 33280, serno: 0 + via 193.1.1.2 (33280/30720), r1-eth1 diff --git a/tests/topotests/eigrp_topo1/r1/show_ip_route.json_ref b/tests/topotests/eigrp_topo1/r1/show_ip_route.json_ref new file mode 100644 index 0000000..26fa7ca --- /dev/null +++ b/tests/topotests/eigrp_topo1/r1/show_ip_route.json_ref @@ -0,0 +1,90 @@ +{ + "192.168.1.0/24":[ + { + "prefix":"192.168.1.0/24", + "protocol":"eigrp", + "metric":28160, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"r1-eth0", + "active":true + } + ] + }, + { + "prefix":"192.168.1.0/24", + "protocol":"connected", + "selected":true, + "nexthops":[ + { + "fib":true, + "directlyConnected":true, + "interfaceName":"r1-eth0", + "active":true + } + ] + } + ], + "192.168.3.0/24":[ + { + "prefix":"192.168.3.0/24", + "protocol":"eigrp", + "selected":true, + "metric":33280, + "nexthops":[ + { + "fib":true, + "ip":"193.1.1.2", + "afi":"ipv4", + "interfaceName":"r1-eth1", + "active":true + } + ] + } + ], + "193.1.1.0/26":[ + { + "prefix":"193.1.1.0/26", + "protocol":"eigrp", + "metric":28160, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"r1-eth1", + "active":true + } + ] + }, + { + "prefix":"193.1.1.0/26", + "protocol":"connected", + "selected":true, + "nexthops":[ + { + "fib":true, + "directlyConnected":true, + "interfaceName":"r1-eth1", + "active":true + } + ] + } + ], + "193.1.2.0/24":[ + { + "prefix":"193.1.2.0/24", + "protocol":"eigrp", + "selected":true, + "metric":30720, + "nexthops":[ + { + "fib":true, + "ip":"193.1.1.2", + "afi":"ipv4", + "interfaceName":"r1-eth1", + "active":true + } + ] + } + ] +} diff --git a/tests/topotests/eigrp_topo1/r1/zebra.conf b/tests/topotests/eigrp_topo1/r1/zebra.conf new file mode 100644 index 0000000..51579a7 --- /dev/null +++ b/tests/topotests/eigrp_topo1/r1/zebra.conf @@ -0,0 +1,20 @@ +log file zebra.log +! debug zebra rib detail +! +hostname r1 +! +interface r1-eth0 + ip address 192.168.1.1/24 +! +interface r1-eth1 + description to sw2 - RIPv2 interface + ip address 193.1.1.1/26 + no link-detect +! +ip forwarding +ipv6 forwarding +! +! +line vty +! + diff --git a/tests/topotests/eigrp_topo1/r2/eigrpd.conf b/tests/topotests/eigrp_topo1/r2/eigrpd.conf new file mode 100644 index 0000000..56c747d --- /dev/null +++ b/tests/topotests/eigrp_topo1/r2/eigrpd.conf @@ -0,0 +1,7 @@ +log file eigrpd.log +! +! +router eigrp 1 + network 193.1.1.0/26 + network 193.1.2.0/24 + diff --git a/tests/topotests/eigrp_topo1/r2/show_ip_eigrp.json b/tests/topotests/eigrp_topo1/r2/show_ip_eigrp.json new file mode 100644 index 0000000..ae9f441 --- /dev/null +++ b/tests/topotests/eigrp_topo1/r2/show_ip_eigrp.json @@ -0,0 +1,32 @@ +{ + "P": { + "192.168.1.0/24": { + "fd": "30720", + "interface": " r2-eth0", + "serno": "0", + "successors": "1", + "via": "193.1.1.1 (30720/28160)" + }, + "192.168.3.0/24": { + "fd": "30720", + "interface": " r2-eth1", + "serno": "0", + "successors": "1", + "via": "193.1.2.2 (30720/28160)" + }, + "193.1.1.0/26": { + "fd": "28160", + "interface": " r2-eth0", + "serno": "0", + "successors": "1", + "via": "Connected" + }, + "193.1.2.0/24": { + "fd": "28160", + "interface": " r2-eth1", + "serno": "0", + "successors": "1", + "via": "Connected" + } + } +} diff --git a/tests/topotests/eigrp_topo1/r2/show_ip_eigrp.ref b/tests/topotests/eigrp_topo1/r2/show_ip_eigrp.ref new file mode 100644 index 0000000..cce49cd --- /dev/null +++ b/tests/topotests/eigrp_topo1/r2/show_ip_eigrp.ref @@ -0,0 +1,14 @@ + +EIGRP Topology Table for AS(1)/ID(193.1.2.1) + +Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply + r - reply Status, s - sia Status + +P 193.1.1.0/26, 1 successors, FD is 28160, serno: 0 + via Connected, r2-eth0 +P 192.168.1.0/24, 1 successors, FD is 30720, serno: 0 + via 193.1.1.1 (30720/28160), r2-eth0 +P 193.1.2.0/24, 1 successors, FD is 28160, serno: 0 + via Connected, r2-eth1 +P 192.168.3.0/24, 1 successors, FD is 30720, serno: 0 + via 193.1.2.2 (30720/28160), r2-eth1 diff --git a/tests/topotests/eigrp_topo1/r2/show_ip_route.json_ref b/tests/topotests/eigrp_topo1/r2/show_ip_route.json_ref new file mode 100644 index 0000000..71c931b --- /dev/null +++ b/tests/topotests/eigrp_topo1/r2/show_ip_route.json_ref @@ -0,0 +1,90 @@ +{ + "192.168.1.0/24":[ + { + "prefix":"192.168.1.0/24", + "protocol":"eigrp", + "selected":true, + "metric":30720, + "nexthops":[ + { + "fib":true, + "ip":"193.1.1.1", + "afi":"ipv4", + "interfaceName":"r2-eth0", + "active":true + } + ] + } + ], + "192.168.3.0/24":[ + { + "prefix":"192.168.3.0/24", + "protocol":"eigrp", + "selected":true, + "metric":30720, + "nexthops":[ + { + "fib":true, + "ip":"193.1.2.2", + "afi":"ipv4", + "interfaceName":"r2-eth1", + "active":true + } + ] + } + ], + "193.1.1.0/26":[ + { + "prefix":"193.1.1.0/26", + "protocol":"eigrp", + "metric":28160, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"r2-eth0", + "active":true + } + ] + }, + { + "prefix":"193.1.1.0/26", + "protocol":"connected", + "selected":true, + "nexthops":[ + { + "fib":true, + "directlyConnected":true, + "interfaceName":"r2-eth0", + "active":true + } + ] + } + ], + "193.1.2.0/24":[ + { + "prefix":"193.1.2.0/24", + "protocol":"eigrp", + "metric":28160, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"r2-eth1", + "active":true + } + ] + }, + { + "prefix":"193.1.2.0/24", + "protocol":"connected", + "selected":true, + "nexthops":[ + { + "fib":true, + "directlyConnected":true, + "interfaceName":"r2-eth1", + "active":true + } + ] + } + ] +} diff --git a/tests/topotests/eigrp_topo1/r2/zebra.conf b/tests/topotests/eigrp_topo1/r2/zebra.conf new file mode 100644 index 0000000..c440f3a --- /dev/null +++ b/tests/topotests/eigrp_topo1/r2/zebra.conf @@ -0,0 +1,21 @@ +log file zebra.log +! +hostname r2 +! +interface r2-eth0 + description to sw2 - RIPv2 interface + ip address 193.1.1.2/26 + no link-detect +! +interface r2-eth1 + description to sw3 - RIPv1 interface + ip address 193.1.2.1/24 + no link-detect +! +ip forwarding +ipv6 forwarding +! +! +line vty +! + diff --git a/tests/topotests/eigrp_topo1/r3/eigrpd.conf b/tests/topotests/eigrp_topo1/r3/eigrpd.conf new file mode 100644 index 0000000..53ad1bb --- /dev/null +++ b/tests/topotests/eigrp_topo1/r3/eigrpd.conf @@ -0,0 +1,6 @@ +log file eigrpd.log +! +! +router eigrp 1 + network 0.0.0.0/0 + diff --git a/tests/topotests/eigrp_topo1/r3/show_ip_eigrp.json b/tests/topotests/eigrp_topo1/r3/show_ip_eigrp.json new file mode 100644 index 0000000..83db66c --- /dev/null +++ b/tests/topotests/eigrp_topo1/r3/show_ip_eigrp.json @@ -0,0 +1,32 @@ +{ + "P": { + "192.168.1.0/24": { + "fd": "33280", + "interface": " r3-eth1", + "serno": "0", + "successors": "1", + "via": "193.1.2.1 (33280/30720)" + }, + "192.168.3.0/24": { + "fd": "28160", + "interface": " r3-eth0", + "serno": "0", + "successors": "1", + "via": "Connected" + }, + "193.1.1.0/26": { + "fd": "30720", + "interface": " r3-eth1", + "serno": "0", + "successors": "1", + "via": "193.1.2.1 (30720/28160)" + }, + "193.1.2.0/24": { + "fd": "28160", + "interface": " r3-eth1", + "serno": "0", + "successors": "1", + "via": "Connected" + } + } +} diff --git a/tests/topotests/eigrp_topo1/r3/show_ip_eigrp.ref b/tests/topotests/eigrp_topo1/r3/show_ip_eigrp.ref new file mode 100644 index 0000000..70f3d3f --- /dev/null +++ b/tests/topotests/eigrp_topo1/r3/show_ip_eigrp.ref @@ -0,0 +1,14 @@ + +EIGRP Topology Table for AS(1)/ID(193.1.2.2) + +Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply + r - reply Status, s - sia Status + +P 193.1.1.0/26, 1 successors, FD is 30720, serno: 0 + via 193.1.2.1 (30720/28160), r3-eth1 +P 192.168.1.0/24, 1 successors, FD is 33280, serno: 0 + via 193.1.2.1 (33280/30720), r3-eth1 +P 193.1.2.0/24, 1 successors, FD is 28160, serno: 0 + via Connected, r3-eth1 +P 192.168.3.0/24, 1 successors, FD is 28160, serno: 0 + via Connected, r3-eth0 diff --git a/tests/topotests/eigrp_topo1/r3/show_ip_route.json_ref b/tests/topotests/eigrp_topo1/r3/show_ip_route.json_ref new file mode 100644 index 0000000..5e0b79d --- /dev/null +++ b/tests/topotests/eigrp_topo1/r3/show_ip_route.json_ref @@ -0,0 +1,108 @@ +{ + "192.168.1.0/24":[ + { + "prefix":"192.168.1.0/24", + "protocol":"eigrp", + "selected":true, + "metric":33280, + "nexthops":[ + { + "fib":true, + "ip":"193.1.2.1", + "afi":"ipv4", + "interfaceName":"r3-eth1", + "active":true + } + ] + } + ], + "192.168.2.0/24":[ + { + "prefix":"192.168.2.0/24", + "protocol":"static", + "selected":true, + "distance":1, + "metric":0, + "nexthops":[ + { + "fib":true, + "ip":"192.168.3.10", + "afi":"ipv4", + "interfaceName":"r3-eth0", + "active":true + } + ] + } + ], + "192.168.3.0/24":[ + { + "prefix":"192.168.3.0/24", + "protocol":"eigrp", + "metric":28160, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"r3-eth0", + "active":true + } + ] + }, + { + "prefix":"192.168.3.0/24", + "protocol":"connected", + "selected":true, + "nexthops":[ + { + "fib":true, + "directlyConnected":true, + "interfaceName":"r3-eth0", + "active":true + } + ] + } + ], + "193.1.1.0/26":[ + { + "prefix":"193.1.1.0/26", + "protocol":"eigrp", + "selected":true, + "metric":30720, + "nexthops":[ + { + "fib":true, + "ip":"193.1.2.1", + "afi":"ipv4", + "interfaceName":"r3-eth1", + "active":true + } + ] + } + ], + "193.1.2.0/24":[ + { + "prefix":"193.1.2.0/24", + "protocol":"eigrp", + "metric":28160, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"r3-eth1", + "active":true + } + ] + }, + { + "prefix":"193.1.2.0/24", + "protocol":"connected", + "selected":true, + "nexthops":[ + { + "fib":true, + "directlyConnected":true, + "interfaceName":"r3-eth1", + "active":true + } + ] + } + ] +} diff --git a/tests/topotests/eigrp_topo1/r3/zebra.conf b/tests/topotests/eigrp_topo1/r3/zebra.conf new file mode 100644 index 0000000..7f145b4 --- /dev/null +++ b/tests/topotests/eigrp_topo1/r3/zebra.conf @@ -0,0 +1,22 @@ +log file zebra.log +! +hostname r3 +! +interface r3-eth0 + description to sw4 - Stub interface + ip address 192.168.3.1/24 + no link-detect +! +interface r3-eth1 + description to sw3 - RIPv2 interface + ip address 193.1.2.2/24 + no link-detect +! +ip route 192.168.2.0/24 192.168.3.10 +! +ip forwarding +ipv6 forwarding +! +! +line vty +! diff --git a/tests/topotests/eigrp_topo1/test_eigrp_topo1.dot b/tests/topotests/eigrp_topo1/test_eigrp_topo1.dot new file mode 100644 index 0000000..ca3a0fe --- /dev/null +++ b/tests/topotests/eigrp_topo1/test_eigrp_topo1.dot @@ -0,0 +1,62 @@ +## GraphViz file for test_eigrp_topo1 +## +## Color coding: +######################### +## Main FRR: #f08080 red +## Switches: #d0e0d0 gray +## RIP: #19e3d9 Cyan +## RIPng: #fcb314 dark yellow +## EIGRP: #696969 +## 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_eigrp_topo1 { + overlap=false; + constraint=false; + + // title + labelloc="t"; + label="Test Topologoy EIGRP Topo1"; + + ###################### + # Routers + ###################### + + # Main FRR Router with all protocols + R1 [shape=doubleoctagon, label="R1 FRR\nMain Router", fillcolor="#f08080", style=filled]; + + # EIGRP Routers + R2 [shape=doubleoctagon, label="R2 FRR\nEIGRP Router", fillcolor="#19e3d9", style=filled]; + R3 [shape=doubleoctagon, label="R3 FRR\nEIGRP Router", fillcolor="#19e3d9", style=filled]; + + ###################### + # Network Lists + ###################### + + SW1_R1_stub [label="SW1\n192.168.1.0/24", fillcolor="#d0e0d0", style=filled]; + + # EIGRP Networks + SW2_R1_R2 [label="SW2\nEIGRPv2\n193.1.1.0/26", fillcolor="#d0e0d0", style=filled]; + SW3_R2_R3 [label="SW3\nEIGRPv1\n193.1.2.0/24", fillcolor="#d0e0d0", style=filled]; + SW4_R3 [label="SW4\n192.168.3.0/24", fillcolor="#d0e0d0", style=filled]; + Net_R3_remote [label="Static Net\n192.168.2.0/24"]; + + ###################### + # Network Connections + ###################### + R1 -- SW1_R1_stub [label = "eth0\n.1\n::1"]; + + # EIGRP Network + R1 -- SW2_R1_R2 [label = "eth1\n.1"]; + SW2_R1_R2 -- R2 [label = "eth0\n.2"]; + R2 -- SW3_R2_R3 [label = "eth1\n.1"]; + SW3_R2_R3 -- R3 [label = "eth1\n.2"]; + R3 -- SW4_R3 [label = "eth0\n.1"]; + SW4_R3 -- Net_R3_remote [label = ".10"]; + +} diff --git a/tests/topotests/eigrp_topo1/test_eigrp_topo1.py b/tests/topotests/eigrp_topo1/test_eigrp_topo1.py new file mode 100644 index 0000000..8b7c9fc --- /dev/null +++ b/tests/topotests/eigrp_topo1/test_eigrp_topo1.py @@ -0,0 +1,292 @@ +#!/usr/bin/env python + +# +# test_eigrp_topo1.py +# +# Copyright (c) 2017 by +# Cumulus Networks, Inc. +# Donald Sharp +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose with or without fee is hereby granted, provided +# that the above copyright notice and this permission notice appear +# in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY +# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS +# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. +# + +""" +test_eigrp_topo1.py: Testing EIGRP + +""" + +import os +import re +import sys +import pytest +import json + +pytestmark = [pytest.mark.eigrpd] + +# Save the Current Working Directory to find configuration files. +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, "../")) + +# pylint: disable=C0413 +# Import topogen and topotest helpers +from lib import topotest +from lib.topogen import Topogen, TopoRouter, get_topogen +from lib.topolog import logger + +# Required to instantiate the topology builder class. + +##################################################### +## +## Network Topology Definition +## +##################################################### + + +def build_topo(tgen): + for routern in range(1, 4): + tgen.add_router("r{}".format(routern)) + + # 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 EIGRP + # switch 2 switch is for connection to EIGRP router + switch = tgen.add_switch("sw2") + switch.add_link(tgen.gears["r1"]) + switch.add_link(tgen.gears["r2"]) + + # switch 4 is stub on remote EIGRP router + switch = tgen.add_switch("sw4") + switch.add_link(tgen.gears["r3"]) + + # switch 3 is between EIGRP routers + switch = tgen.add_switch("sw3") + switch.add_link(tgen.gears["r2"]) + switch.add_link(tgen.gears["r3"]) + + +##################################################### +## +## Tests starting +## +##################################################### + + +def setup_module(module): + "Setup topology" + tgen = Topogen(build_topo, module.__name__) + tgen.start_topology() + + # This is a sample of configuration loading. + router_list = tgen.routers() + for rname, router in router_list.items(): + router.load_config( + TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) + ) + router.load_config( + TopoRouter.RD_EIGRP, os.path.join(CWD, "{}/eigrpd.conf".format(rname)) + ) + + tgen.start_router() + + +def teardown_module(_mod): + "Teardown the pytest environment" + tgen = get_topogen() + + # This function tears down the whole topology. + tgen.stop_topology() + + +def test_converge_protocols(): + "Wait for protocol convergence" + + tgen = get_topogen() + # Don't run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + topotest.sleep(5, "Waiting for EIGRP convergence") + + +def test_eigrp_routes(): + "Test EIGRP 'show ip eigrp'" + + tgen = get_topogen() + # Don't run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + # Verify EIGRP Status + logger.info("Verifying EIGRP routes") + + router_list = tgen.routers().values() + for router in router_list: + refTableFile = "{}/{}/show_ip_eigrp.json".format(CWD, router.name) + + # Read expected result from file + expected = json.loads(open(refTableFile).read()) + + # Actual output from router + actual = ip_eigrp_topo(router) + + assertmsg = '"show ip eigrp topo" mismatches on {}'.format(router.name) + assert topotest.json_cmp(actual, expected) is None, assertmsg + + +def test_zebra_ipv4_routingTable(): + "Test 'show ip route'" + + tgen = get_topogen() + # Don't run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + failures = 0 + router_list = tgen.routers().values() + for router in router_list: + output = router.vtysh_cmd("show ip route json", isjson=True) + refTableFile = "{}/{}/show_ip_route.json_ref".format(CWD, router.name) + expected = json.loads(open(refTableFile).read()) + + assertmsg = "Zebra IPv4 Routing Table verification failed for router {}".format( + router.name + ) + assert topotest.json_cmp(output, expected) is None, assertmsg + + +def test_shut_interface_and_recover(): + "Test shutdown of an interface and recovery of the interface" + + tgen = get_topogen() + router = tgen.gears["r1"] + router.run("ip link set r1-eth1 down") + topotest.sleep(5, "Waiting for EIGRP convergence") + router.run("ip link set r1-eth1 up") + + +def test_shutdown_check_stderr(): + if os.environ.get("TOPOTESTS_CHECK_STDERR") is None: + pytest.skip("Skipping test for Stderr output and memory leaks") + + tgen = get_topogen() + # Don't run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + logger.info("Verifying unexpected STDERR output from daemons") + + router_list = tgen.routers().values() + for router in router_list: + router.stop() + + log = tgen.net[router.name].getStdErr("eigrpd") + if log: + logger.error("EIGRPd StdErr Log:" + log) + log = tgen.net[router.name].getStdErr("zebra") + if log: + logger.error("Zebra StdErr Log:" + log) + + +if __name__ == "__main__": + args = ["-s"] + sys.argv[1:] + sys.exit(pytest.main(args)) + +# +# Auxiliary Functions +# +def ip_eigrp_topo(node): + """ + Parse 'show ip eigrp topo' from `node` and returns a dict with the + result. + + Example: + { + 'P': { + '192.168.1.0/24': { + 'sucessors': 1, + 'fd': 112233, + 'serno': 0, + 'via': 'Connected', + 'interface': 'eth0', + }, + '192.168.2.0/24': { + 'sucessors': 1, + 'fd': 112234, + 'serno': 0, + 'via': 'Connected', + 'interface': 'eth1', + } + } + } + """ + output = topotest.normalize_text(node.vtysh_cmd("show ip eigrp topo")).splitlines() + result = {} + for idx, line in enumerate(output): + columns = line.split(" ", 1) + + # Parse the following format into python dicts + # code A.B.C.D/E, X successors, FD is Y, serno: Z + # via FOO, interface-name + code = columns[0] + if code not in ["P", "A", "U", "Q", "R", "r", "s"]: + continue + + if code not in result: + result[code] = {} + + # Split network from the rest + columns = columns[1].split(",") + + # Parse first line data + network = columns[0] + result[code][network] = {} + for column in columns: + # Skip the network column + if column == columns[0]: + continue + + match = re.search(r"(\d+) successors", column) + if match is not None: + result[code][network]["successors"] = match.group(1) + continue + + match = re.search(r"FD is (\d+)", column) + if match is not None: + result[code][network]["fd"] = match.group(1) + continue + + match = re.search(r"serno: (\d+)", column) + if match is not None: + result[code][network]["serno"] = match.group(1) + continue + + # Parse second line data + nextline = output[idx + 1] + columns = topotest.normalize_text(nextline).split(",") + for column in columns: + match = re.search(r"via (.+)", column) + if match is not None: + result[code][network]["via"] = match.group(1) + continue + + match = re.search(r"(.+)", column) + if match is not None: + result[code][network]["interface"] = match.group(1) + continue + + return result |