From f175c4eb97e5be4848518b4fbf3fa531e214aa50 Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Fri, 30 Jun 2017 16:23:25 -0300 Subject: [PATCH] ospf: add IPv6 OSPF convergence test Add more tests to the ospf-topo1 to include IPv6 testing. Since both IP versions are running together, there is no need to wait OSPF convergence per IP version. --- tests/topotests/ospf-topo1/r1/ospf6d.conf | 10 +++ tests/topotests/ospf-topo1/r1/ospf6route.txt | 13 ++++ .../ospf-topo1/r1/ospf6route_down.txt | 5 ++ tests/topotests/ospf-topo1/r1/zebra.conf | 2 + tests/topotests/ospf-topo1/r2/ospf6d.conf | 10 +++ tests/topotests/ospf-topo1/r2/ospf6route.txt | 13 ++++ .../ospf-topo1/r2/ospf6route_down.txt | 5 ++ tests/topotests/ospf-topo1/r2/zebra.conf | 2 + tests/topotests/ospf-topo1/r3/ospf6d.conf | 11 ++++ tests/topotests/ospf-topo1/r3/ospf6route.txt | 12 ++++ .../ospf-topo1/r3/ospf6route_down.txt | 5 ++ tests/topotests/ospf-topo1/r3/zebra.conf | 3 + tests/topotests/ospf-topo1/r4/ospf6d.conf | 10 +++ tests/topotests/ospf-topo1/r4/ospf6route.txt | 13 ++++ .../ospf-topo1/r4/ospf6route_down.txt | 5 ++ tests/topotests/ospf-topo1/r4/zebra.conf | 2 + tests/topotests/ospf-topo1/test_ospf_topo1.py | 65 +++++++++++++++++++ 17 files changed, 186 insertions(+) create mode 100644 tests/topotests/ospf-topo1/r1/ospf6d.conf create mode 100644 tests/topotests/ospf-topo1/r1/ospf6route.txt create mode 100644 tests/topotests/ospf-topo1/r1/ospf6route_down.txt create mode 100644 tests/topotests/ospf-topo1/r2/ospf6d.conf create mode 100644 tests/topotests/ospf-topo1/r2/ospf6route.txt create mode 100644 tests/topotests/ospf-topo1/r2/ospf6route_down.txt create mode 100644 tests/topotests/ospf-topo1/r3/ospf6d.conf create mode 100644 tests/topotests/ospf-topo1/r3/ospf6route.txt create mode 100644 tests/topotests/ospf-topo1/r3/ospf6route_down.txt create mode 100644 tests/topotests/ospf-topo1/r4/ospf6d.conf create mode 100644 tests/topotests/ospf-topo1/r4/ospf6route.txt create mode 100644 tests/topotests/ospf-topo1/r4/ospf6route_down.txt diff --git a/tests/topotests/ospf-topo1/r1/ospf6d.conf b/tests/topotests/ospf-topo1/r1/ospf6d.conf new file mode 100644 index 0000000000..97779cf7c8 --- /dev/null +++ b/tests/topotests/ospf-topo1/r1/ospf6d.conf @@ -0,0 +1,10 @@ +log file /tmp/r1-ospf6d.log +! +router ospf6 + router-id 10.0.255.1 + redistribute kernel + redistribute connected + redistribute static + interface r1-eth0 area 0.0.0.0 + interface r1-eth1 area 0.0.0.0 +! diff --git a/tests/topotests/ospf-topo1/r1/ospf6route.txt b/tests/topotests/ospf-topo1/r1/ospf6route.txt new file mode 100644 index 0000000000..1bfd6942ea --- /dev/null +++ b/tests/topotests/ospf-topo1/r1/ospf6route.txt @@ -0,0 +1,13 @@ +*N IA 2001:db8:1::/64 :: r1-eth0 00:02:11 +*N IA 2001:db8:2::/64 fe80::b038:bcff:fe27:e2d6 r1-eth1 00:02:06 + N E1 2001:db8:2::/64 fe80::b038:bcff:fe27:e2d6 r1-eth1 00:02:06 +*N IA 2001:db8:3::/64 :: r1-eth1 00:02:11 + N E1 2001:db8:3::/64 fe80::50b7:d8ff:fe5f:8ff0 r1-eth1 00:02:06 + N E1 2001:db8:3::/64 fe80::b038:bcff:fe27:e2d6 r1-eth1 00:02:06 +*N IA 2001:db8:100::/64 fe80::50b7:d8ff:fe5f:8ff0 r1-eth1 00:02:06 + N E1 2001:db8:100::/64 fe80::50b7:d8ff:fe5f:8ff0 r1-eth1 00:02:06 +*N IE 2001:db8:200::/64 fe80::50b7:d8ff:fe5f:8ff0 r1-eth1 00:02:06 + N E1 2001:db8:200::/64 fe80::50b7:d8ff:fe5f:8ff0 r1-eth1 00:02:06 + N E1 2001:db8:200::/64 fe80::50b7:d8ff:fe5f:8ff0 r1-eth1 00:02:04 +*N IE 2001:db8:300::/64 fe80::50b7:d8ff:fe5f:8ff0 r1-eth1 00:02:04 + N E1 2001:db8:300::/64 fe80::50b7:d8ff:fe5f:8ff0 r1-eth1 00:02:04 diff --git a/tests/topotests/ospf-topo1/r1/ospf6route_down.txt b/tests/topotests/ospf-topo1/r1/ospf6route_down.txt new file mode 100644 index 0000000000..1ce96c86c0 --- /dev/null +++ b/tests/topotests/ospf-topo1/r1/ospf6route_down.txt @@ -0,0 +1,5 @@ +*N IA 2001:db8:1::/64 :: r1-eth0 00:01:51 +*N IA 2001:db8:2::/64 fe80::281a:23ff:fe22:8a40 r1-eth1 00:00:52 + N E1 2001:db8:2::/64 fe80::281a:23ff:fe22:8a40 r1-eth1 00:00:52 +*N IA 2001:db8:3::/64 :: r1-eth1 00:00:52 + N E1 2001:db8:3::/64 fe80::281a:23ff:fe22:8a40 r1-eth1 00:00:52 diff --git a/tests/topotests/ospf-topo1/r1/zebra.conf b/tests/topotests/ospf-topo1/r1/zebra.conf index 152d3c0a90..fd3acbe7e3 100644 --- a/tests/topotests/ospf-topo1/r1/zebra.conf +++ b/tests/topotests/ospf-topo1/r1/zebra.conf @@ -4,9 +4,11 @@ log file /tmp/r1-zebra.log ! interface r1-eth0 ip address 10.0.1.1/24 + ipv6 address 2001:db8:1::1/64 ! interface r1-eth1 ip address 10.0.3.2/24 + ipv6 address 2001:db8:3::2/64 ! ip forwarding ! diff --git a/tests/topotests/ospf-topo1/r2/ospf6d.conf b/tests/topotests/ospf-topo1/r2/ospf6d.conf new file mode 100644 index 0000000000..d9039ce90a --- /dev/null +++ b/tests/topotests/ospf-topo1/r2/ospf6d.conf @@ -0,0 +1,10 @@ +log file /tmp/r2-ospf6d.log +! +router ospf6 + router-id 10.0.255.2 + redistribute kernel + redistribute connected + redistribute static + interface r2-eth0 area 0.0.0.0 + interface r2-eth1 area 0.0.0.0 +! diff --git a/tests/topotests/ospf-topo1/r2/ospf6route.txt b/tests/topotests/ospf-topo1/r2/ospf6route.txt new file mode 100644 index 0000000000..7d3ce5b207 --- /dev/null +++ b/tests/topotests/ospf-topo1/r2/ospf6route.txt @@ -0,0 +1,13 @@ +*N IA 2001:db8:1::/64 fe80::b49b:4cff:fe80:4e87 r2-eth1 00:03:34 + N E1 2001:db8:1::/64 fe80::b49b:4cff:fe80:4e87 r2-eth1 00:03:34 +*N IA 2001:db8:2::/64 :: r2-eth0 00:03:39 +*N IA 2001:db8:3::/64 :: r2-eth1 00:03:34 + N E1 2001:db8:3::/64 fe80::b49b:4cff:fe80:4e87 r2-eth1 00:03:34 + N E1 2001:db8:3::/64 fe80::50b7:d8ff:fe5f:8ff0 r2-eth1 00:03:34 +*N IA 2001:db8:100::/64 fe80::50b7:d8ff:fe5f:8ff0 r2-eth1 00:03:34 + N E1 2001:db8:100::/64 fe80::50b7:d8ff:fe5f:8ff0 r2-eth1 00:03:34 +*N IE 2001:db8:200::/64 fe80::50b7:d8ff:fe5f:8ff0 r2-eth1 00:03:34 + N E1 2001:db8:200::/64 fe80::50b7:d8ff:fe5f:8ff0 r2-eth1 00:03:34 + N E1 2001:db8:200::/64 fe80::50b7:d8ff:fe5f:8ff0 r2-eth1 00:03:32 +*N IE 2001:db8:300::/64 fe80::50b7:d8ff:fe5f:8ff0 r2-eth1 00:03:32 + N E1 2001:db8:300::/64 fe80::50b7:d8ff:fe5f:8ff0 r2-eth1 00:03:32 diff --git a/tests/topotests/ospf-topo1/r2/ospf6route_down.txt b/tests/topotests/ospf-topo1/r2/ospf6route_down.txt new file mode 100644 index 0000000000..acfffc9f1c --- /dev/null +++ b/tests/topotests/ospf-topo1/r2/ospf6route_down.txt @@ -0,0 +1,5 @@ +*N IA 2001:db8:1::/64 fe80::fc0b:daff:fe31:6791 r2-eth1 00:06:19 + N E1 2001:db8:1::/64 fe80::fc0b:daff:fe31:6791 r2-eth1 00:06:19 +*N IA 2001:db8:2::/64 :: r2-eth0 00:07:17 +*N IA 2001:db8:3::/64 :: r2-eth1 00:06:27 + N E1 2001:db8:3::/64 fe80::fc0b:daff:fe31:6791 r2-eth1 00:06:19 diff --git a/tests/topotests/ospf-topo1/r2/zebra.conf b/tests/topotests/ospf-topo1/r2/zebra.conf index 35d9c96b54..e247d9e51b 100644 --- a/tests/topotests/ospf-topo1/r2/zebra.conf +++ b/tests/topotests/ospf-topo1/r2/zebra.conf @@ -4,9 +4,11 @@ log file /tmp/r2-zebra.log ! interface r2-eth0 ip address 10.0.2.1/24 + ipv6 address 2001:db8:2::1/64 ! interface r2-eth1 ip address 10.0.3.3/24 + ipv6 address 2001:db8:3::3/64 ! ip forwarding ! diff --git a/tests/topotests/ospf-topo1/r3/ospf6d.conf b/tests/topotests/ospf-topo1/r3/ospf6d.conf new file mode 100644 index 0000000000..6ea308ba28 --- /dev/null +++ b/tests/topotests/ospf-topo1/r3/ospf6d.conf @@ -0,0 +1,11 @@ +log file /tmp/r3-ospf6d.log +! +router ospf6 + router-id 10.0.255.3 + redistribute kernel + redistribute connected + redistribute static + interface r3-eth0 area 0.0.0.0 + interface r3-eth1 area 0.0.0.0 + interface r3-eth2 area 0.0.0.1 +! diff --git a/tests/topotests/ospf-topo1/r3/ospf6route.txt b/tests/topotests/ospf-topo1/r3/ospf6route.txt new file mode 100644 index 0000000000..b123c42650 --- /dev/null +++ b/tests/topotests/ospf-topo1/r3/ospf6route.txt @@ -0,0 +1,12 @@ +*N IA 2001:db8:1::/64 fe80::b49b:4cff:fe80:4e87 r3-eth0 00:04:03 + N E1 2001:db8:1::/64 fe80::b49b:4cff:fe80:4e87 r3-eth0 00:04:03 +*N IA 2001:db8:2::/64 fe80::b038:bcff:fe27:e2d6 r3-eth0 00:04:03 + N E1 2001:db8:2::/64 fe80::b038:bcff:fe27:e2d6 r3-eth0 00:04:03 +*N IA 2001:db8:3::/64 :: r3-eth0 00:04:08 + N E1 2001:db8:3::/64 fe80::b49b:4cff:fe80:4e87 r3-eth0 00:04:03 + N E1 2001:db8:3::/64 fe80::b038:bcff:fe27:e2d6 r3-eth0 00:04:03 +*N IA 2001:db8:100::/64 :: r3-eth1 00:04:08 +*N IA 2001:db8:200::/64 :: r3-eth2 00:04:05 + N E1 2001:db8:200::/64 fe80::78e0:deff:feb1:ec0 r3-eth2 00:04:00 +*N IA 2001:db8:300::/64 fe80::78e0:deff:feb1:ec0 r3-eth2 00:04:00 + N E1 2001:db8:300::/64 fe80::78e0:deff:feb1:ec0 r3-eth2 00:04:00 diff --git a/tests/topotests/ospf-topo1/r3/ospf6route_down.txt b/tests/topotests/ospf-topo1/r3/ospf6route_down.txt new file mode 100644 index 0000000000..ed69a8376b --- /dev/null +++ b/tests/topotests/ospf-topo1/r3/ospf6route_down.txt @@ -0,0 +1,5 @@ +*N IA 2001:db8:100::/64 :: r3-eth1 00:08:06 +*N IA 2001:db8:200::/64 :: r3-eth2 00:08:04 + N E1 2001:db8:200::/64 fe80::80a6:c3ff:fea9:88be r3-eth2 00:07:59 +*N IA 2001:db8:300::/64 fe80::80a6:c3ff:fea9:88be r3-eth2 00:07:59 + N E1 2001:db8:300::/64 fe80::80a6:c3ff:fea9:88be r3-eth2 00:07:59 diff --git a/tests/topotests/ospf-topo1/r3/zebra.conf b/tests/topotests/ospf-topo1/r3/zebra.conf index 7521a9b95b..49046a35cd 100644 --- a/tests/topotests/ospf-topo1/r3/zebra.conf +++ b/tests/topotests/ospf-topo1/r3/zebra.conf @@ -4,12 +4,15 @@ log file /tmp/r3-zebra.log ! interface r3-eth0 ip address 10.0.3.1/24 + ipv6 address 2001:db8:3::1/64 ! interface r3-eth1 ip address 10.0.10.1/24 + ipv6 address 2001:db8:100::1/64 ! interface r3-eth2 ip address 172.16.0.2/24 + ipv6 address 2001:db8:200::2/64 ! ip forwarding ! diff --git a/tests/topotests/ospf-topo1/r4/ospf6d.conf b/tests/topotests/ospf-topo1/r4/ospf6d.conf new file mode 100644 index 0000000000..35c046a9bd --- /dev/null +++ b/tests/topotests/ospf-topo1/r4/ospf6d.conf @@ -0,0 +1,10 @@ +log file /tmp/r4-ospf6d.log +! +router ospf6 + router-id 10.0.255.4 + redistribute kernel + redistribute connected + redistribute static + interface r4-eth0 area 0.0.0.1 + interface r4-eth1 area 0.0.0.1 +! diff --git a/tests/topotests/ospf-topo1/r4/ospf6route.txt b/tests/topotests/ospf-topo1/r4/ospf6route.txt new file mode 100644 index 0000000000..ceeee2cac8 --- /dev/null +++ b/tests/topotests/ospf-topo1/r4/ospf6route.txt @@ -0,0 +1,13 @@ +*N IE 2001:db8:1::/64 fe80::987b:baff:fe8a:c864 r4-eth0 00:04:25 + N E1 2001:db8:1::/64 fe80::987b:baff:fe8a:c864 r4-eth0 00:04:25 +*N IE 2001:db8:2::/64 fe80::987b:baff:fe8a:c864 r4-eth0 00:04:25 + N E1 2001:db8:2::/64 fe80::987b:baff:fe8a:c864 r4-eth0 00:04:25 +*N IE 2001:db8:3::/64 fe80::987b:baff:fe8a:c864 r4-eth0 00:04:25 + N E1 2001:db8:3::/64 fe80::987b:baff:fe8a:c864 r4-eth0 00:04:25 + N E1 2001:db8:3::/64 fe80::987b:baff:fe8a:c864 r4-eth0 00:04:25 + N E1 2001:db8:3::/64 fe80::987b:baff:fe8a:c864 r4-eth0 00:04:25 +*N IE 2001:db8:100::/64 fe80::987b:baff:fe8a:c864 r4-eth0 00:04:25 + N E1 2001:db8:100::/64 fe80::987b:baff:fe8a:c864 r4-eth0 00:04:25 +*N IA 2001:db8:200::/64 :: r4-eth0 00:04:30 + N E1 2001:db8:200::/64 fe80::987b:baff:fe8a:c864 r4-eth0 00:04:25 +*N IA 2001:db8:300::/64 :: r4-eth1 00:04:30 diff --git a/tests/topotests/ospf-topo1/r4/ospf6route_down.txt b/tests/topotests/ospf-topo1/r4/ospf6route_down.txt new file mode 100644 index 0000000000..4ad636dd98 --- /dev/null +++ b/tests/topotests/ospf-topo1/r4/ospf6route_down.txt @@ -0,0 +1,5 @@ +*N IE 2001:db8:100::/64 fe80::b44b:a1ff:fe48:3d69 r4-eth0 00:01:45 + N E1 2001:db8:100::/64 fe80::b44b:a1ff:fe48:3d69 r4-eth0 00:01:45 +*N IA 2001:db8:200::/64 :: r4-eth0 00:01:50 + N E1 2001:db8:200::/64 fe80::b44b:a1ff:fe48:3d69 r4-eth0 00:01:45 +*N IA 2001:db8:300::/64 :: r4-eth1 00:01:50 diff --git a/tests/topotests/ospf-topo1/r4/zebra.conf b/tests/topotests/ospf-topo1/r4/zebra.conf index d90bdc6cf4..fec7e36d4f 100644 --- a/tests/topotests/ospf-topo1/r4/zebra.conf +++ b/tests/topotests/ospf-topo1/r4/zebra.conf @@ -4,9 +4,11 @@ log file /tmp/r4-zebra.log ! interface r4-eth0 ip address 172.16.0.1/24 + ipv6 address 2001:db8:200::1/64 ! interface r4-eth1 ip address 172.16.1.100/24 + ipv6 address 2001:db8:300::100/64 ! ip forwarding ! diff --git a/tests/topotests/ospf-topo1/test_ospf_topo1.py b/tests/topotests/ospf-topo1/test_ospf_topo1.py index b801677af5..f5b2641ae5 100755 --- a/tests/topotests/ospf-topo1/test_ospf_topo1.py +++ b/tests/topotests/ospf-topo1/test_ospf_topo1.py @@ -27,6 +27,7 @@ test_ospf_topo1.py: Test the FRR/Quagga OSPF routing daemon. """ import os +import re import sys from functools import partial import pytest @@ -96,6 +97,10 @@ def setup_module(mod): TopoRouter.RD_OSPF, os.path.join(CWD, '{}/ospfd.conf'.format(rname)) ) + router.load_config( + TopoRouter.RD_OSPF6, + os.path.join(CWD, '{}/ospf6d.conf'.format(rname)) + ) # Initialize all routers. tgen.start_router() @@ -117,6 +122,31 @@ def compare_show_ip_ospf(rname, expected): title1="Current output", title2="Expected output") +def compare_show_ipv6_ospf6(rname, expected): + """ + Calls 'show ipv6 ospf6 route' for router `rname` and compare the obtained + result with the expected output. + """ + tgen = get_topogen() + current = tgen.gears[rname].vtysh_cmd('show ipv6 ospf6 route') + + # This output has space formating and random IPv6 link addresses, we have to + # remove them first before testing. + current = topotest.normalize_text(current) + expected = topotest.normalize_text(expected) + + # Remove the link addresses + current = re.sub(r'fe80:[^ ]+', '', current) + expected = re.sub(r'fe80:[^ ]+', '', expected) + + # Remove the time + current = re.sub(r'\d+:\d{2}:\d{2}', '', current) + expected = re.sub(r'\d+:\d{2}:\d{2}', '', expected) + + return topotest.difflines(current, expected, + title1="Current output", + title2="Expected output") + def test_ospf_convergence(): "Test OSPF daemon convergence" for rnum in range(1, 5): @@ -134,6 +164,23 @@ def test_ospf_convergence(): count=20, wait=3) assert result, 'OSPF did not converge on {}:\n{}'.format(router, diff) +def test_ospf6_convergence(): + "Test OSPF6 daemon convergence" + for rnum in range(1, 5): + router = 'r{}'.format(rnum) + + logger.info('Waiting for router "%s" IPv6 OSPF convergence', router) + + # Load expected results from the command + reffile = os.path.join(CWD, '{}/ospf6route.txt'.format(router)) + expected = open(reffile).read() + + # Run test function until we get an result. Wait at most 60 seconds. + test_func = partial(compare_show_ipv6_ospf6, router, expected) + result, diff = topotest.run_and_expect(test_func, '', + count=20, wait=3) + assert result, 'OSPF6 did not converge on {}:\n{}'.format(router, diff) + def test_ospf_json(): "Test 'show ip ospf json' output for coherency." tgen = get_topogen() @@ -226,6 +273,24 @@ def test_ospf_link_down(): count=20, wait=3) assert result, 'OSPF did not converge on {}:\n{}'.format(router, diff) +def test_ospf6_link_down(): + "Test OSPF6 daemon convergence after link goes down" + + for rnum in range(1, 5): + router = 'r{}'.format(rnum) + + logger.info('Waiting for router "%s" IPv6 OSPF convergence after link down', router) + + # Load expected results from the command + reffile = os.path.join(CWD, '{}/ospf6route_down.txt'.format(router)) + expected = open(reffile).read() + + # Run test function until we get an result. Wait at most 60 seconds. + test_func = partial(compare_show_ipv6_ospf6, router, expected) + result, diff = topotest.run_and_expect(test_func, '', + count=20, wait=3) + assert result, 'OSPF6 did not converge on {}:\n{}'.format(router, diff) + def test_memory_leak(): "Run the memory leak test and report results." tgen = get_topogen() -- 2.39.5