]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospf: added a convergence test for link failure
authorRafael Zalamena <rzalamena@gmail.com>
Wed, 21 Jun 2017 21:08:00 +0000 (18:08 -0300)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 28 Nov 2018 01:22:12 +0000 (20:22 -0500)
This new test simulates a link failure in router 3 and expects the OSPF
routing table to converge accordingly in all nodes.

tests/topotests/ospf-topo1/r1/ospfroute_down.txt [new file with mode: 0644]
tests/topotests/ospf-topo1/r2/ospfroute_down.txt [new file with mode: 0644]
tests/topotests/ospf-topo1/r3/ospfroute_down.txt [new file with mode: 0644]
tests/topotests/ospf-topo1/r4/ospfroute_down.txt [new file with mode: 0644]
tests/topotests/ospf-topo1/test_ospf_topo1.py

diff --git a/tests/topotests/ospf-topo1/r1/ospfroute_down.txt b/tests/topotests/ospf-topo1/r1/ospfroute_down.txt
new file mode 100644 (file)
index 0000000..5c07d81
--- /dev/null
@@ -0,0 +1,13 @@
+============ OSPF network routing table ============
+N    10.0.1.0/24           [10] area: 0.0.0.0
+                           directly attached to r1-eth0
+N    10.0.2.0/24           [20] area: 0.0.0.0
+                           via 10.0.3.3, r1-eth1
+N    10.0.3.0/24           [10] area: 0.0.0.0
+                           directly attached to r1-eth1
+
+============ OSPF router routing table =============
+R    10.0.255.2            [10] area: 0.0.0.0, ASBR
+                           via 10.0.3.3, r1-eth1
+
+============ OSPF external routing table ===========
diff --git a/tests/topotests/ospf-topo1/r2/ospfroute_down.txt b/tests/topotests/ospf-topo1/r2/ospfroute_down.txt
new file mode 100644 (file)
index 0000000..b8411e1
--- /dev/null
@@ -0,0 +1,13 @@
+============ OSPF network routing table ============
+N    10.0.1.0/24           [20] area: 0.0.0.0
+                           via 10.0.3.2, r2-eth1
+N    10.0.2.0/24           [10] area: 0.0.0.0
+                           directly attached to r2-eth0
+N    10.0.3.0/24           [10] area: 0.0.0.0
+                           directly attached to r2-eth1
+
+============ OSPF router routing table =============
+R    10.0.255.1            [10] area: 0.0.0.0, ASBR
+                           via 10.0.3.2, r2-eth1
+
+============ OSPF external routing table ===========
diff --git a/tests/topotests/ospf-topo1/r3/ospfroute_down.txt b/tests/topotests/ospf-topo1/r3/ospfroute_down.txt
new file mode 100644 (file)
index 0000000..692a74a
--- /dev/null
@@ -0,0 +1,13 @@
+============ OSPF network routing table ============
+N    10.0.10.0/24          [10] area: 0.0.0.0
+                           directly attached to r3-eth1
+N    172.16.0.0/24         [10] area: 0.0.0.1
+                           directly attached to r3-eth2
+N    172.16.1.0/24         [20] area: 0.0.0.1
+                           via 172.16.0.1, r3-eth2
+
+============ OSPF router routing table =============
+R    10.0.255.4            [10] area: 0.0.0.1, ASBR
+                           via 172.16.0.1, r3-eth2
+
+============ OSPF external routing table ===========
diff --git a/tests/topotests/ospf-topo1/r4/ospfroute_down.txt b/tests/topotests/ospf-topo1/r4/ospfroute_down.txt
new file mode 100644 (file)
index 0000000..b0bd0ee
--- /dev/null
@@ -0,0 +1,13 @@
+============ OSPF network routing table ============
+N IA 10.0.10.0/24          [20] area: 0.0.0.1
+                           via 172.16.0.2, r4-eth0
+N    172.16.0.0/24         [10] area: 0.0.0.1
+                           directly attached to r4-eth0
+N    172.16.1.0/24         [10] area: 0.0.0.1
+                           directly attached to r4-eth1
+
+============ OSPF router routing table =============
+R    10.0.255.3            [10] area: 0.0.0.1, ABR, ASBR
+                           via 172.16.0.2, r4-eth0
+
+============ OSPF external routing table ===========
index 4cb569da8e3687b8eca917fc3854692bc42bfdbd..352e6dde66e6f5324fdbef3926c928b1fea6719d 100755 (executable)
@@ -105,27 +105,47 @@ def teardown_module(mod):
     tgen = get_topogen()
     tgen.stop_topology()
 
+# Shared test function to validate expected output.
+def compare_show_ip_ospf(rname, expected):
+    """
+    Calls 'show ip ospf route' for router `rname` and compare the obtained
+    result with the expected output.
+    """
+    tgen = get_topogen()
+    current = tgen.gears[rname].vtysh_cmd('show ip ospf route')
+    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):
+        router = 'r{}'.format(rnum)
+
+        # Load expected results from the command
+        reffile = os.path.join(CWD, '{}/ospfroute.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_ip_ospf, router, expected)
+        result, diff = topotest.run_and_expect(test_func, '',
+                                               count=20, wait=3)
+        assert result, 'OSPF did not converge on {}:\n{}'.format(router, diff)
+
+def test_ospf_link_down():
+    "Test OSPF convergence after a link goes down"
     tgen = get_topogen()
 
-    # Define test function
-    def compare_show_ip_ospf(rname, expected):
-        """
-        Calls 'show ip ospf route' for router `rname` and compare the obtained
-        result with the expected output.
-        """
-        current = tgen.gears[rname].vtysh_cmd('show ip ospf route')
-        return topotest.difflines(current, expected,
-                                  title1="Current output",
-                                  title2="Expected output")
-
-    # Run the file comparison for all routers
+    # Simulate a network down event on router3 switch3 interface.
+    router3 = tgen.gears['r3']
+    router3.peer_link_enable('r3-eth0', False)
+
+    # Expect convergence on all routers
     for rnum in range(1, 5):
         router = 'r{}'.format(rnum)
 
         # Load expected results from the command
-        reffile = os.path.join(CWD, '{}/ospfroute.txt'.format(router))
+        reffile = os.path.join(CWD, '{}/ospfroute_down.txt'.format(router))
         expected = open(reffile).read()
 
         # Run test function until we get an result. Wait at most 60 seconds.