--- /dev/null
+============ 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 ===========
--- /dev/null
+============ 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 ===========
--- /dev/null
+============ 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 ===========
--- /dev/null
+============ 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 ===========
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.