]> git.proxmox.com Git - mirror_frr.git/blobdiff - tests/topotests/ospf_topo1/test_ospf_topo1.py
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / tests / topotests / ospf_topo1 / test_ospf_topo1.py
index 175b75f903fe63c7908d08619fde7c44d0d21b9a..a079f5698ff1113d1e942d522c758831cb73309c 100644 (file)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# SPDX-License-Identifier: ISC
 
 #
 # test_ospf_topo1.py
@@ -7,20 +8,6 @@
 # Copyright (c) 2017 by
 # Network Device Education Foundation, Inc. ("NetDEF")
 #
-# 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_ospf_topo1.py: Test the FRR OSPF routing daemon.
@@ -30,6 +17,7 @@ import os
 import re
 import sys
 from functools import partial
+from time import sleep
 import pytest
 
 # Save the Current Working Directory to find configuration files.
@@ -43,7 +31,6 @@ from lib.topogen import Topogen, TopoRouter, get_topogen
 from lib.topolog import logger
 
 # Required to instantiate the topology builder class.
-from lib.micronet_compat import Topo
 
 pytestmark = [pytest.mark.ospfd]
 
@@ -136,7 +123,7 @@ def test_wait_protocol_convergence():
             )
             if (
                 topotest.json_cmp(
-                    result, {"neighbors": {neighbor: [{"state": "Full/DR"}]}}
+                    result, {"neighbors": {neighbor: [{"converged": "Full"}]}}
                 )
                 is None
             ):
@@ -144,14 +131,14 @@ def test_wait_protocol_convergence():
 
             if (
                 topotest.json_cmp(
-                    result, {"neighbors": {neighbor: [{"state": "Full/DROther"}]}}
+                    result, {"neighbors": {neighbor: [{"converged": "Full"}]}}
                 )
                 is None
             ):
                 return None
 
             return topotest.json_cmp(
-                result, {"neighbors": {neighbor: [{"state": "Full/Backup"}]}}
+                result, {"neighbors": {neighbor: [{"converged": "Full"}]}}
             )
 
         _, result = topotest.run_and_expect(
@@ -316,17 +303,26 @@ def test_ospf6_kernel_route():
     for router in rlist:
         logger.info('Checking OSPF IPv6 kernel routes in "%s"', router.name)
 
-        routes = topotest.ip6_route(router)
-        expected = {
-            "2001:db8:1::/64": {},
-            "2001:db8:2::/64": {},
-            "2001:db8:3::/64": {},
-            "2001:db8:100::/64": {},
-            "2001:db8:200::/64": {},
-            "2001:db8:300::/64": {},
-        }
+        def _routes_in_fib6():
+            routes = topotest.ip6_route(router)
+            expected = {
+                "2001:db8:1::/64": {},
+                "2001:db8:2::/64": {},
+                "2001:db8:3::/64": {},
+                "2001:db8:100::/64": {},
+                "2001:db8:200::/64": {},
+                "2001:db8:300::/64": {},
+            }
+            logger.info("Routes:")
+            logger.info(routes)
+            logger.info(topotest.json_cmp(routes, expected))
+            logger.info("ENd:")
+            return topotest.json_cmp(routes, expected)
+
+        _, result = topotest.run_and_expect(_routes_in_fib6, None, count=20, wait=1)
+
         assertmsg = 'OSPF IPv6 route mismatch in router "{}"'.format(router.name)
-        assert topotest.json_cmp(routes, expected) is None, assertmsg
+        assert result is None, assertmsg
 
 
 def test_ospf_json():
@@ -337,6 +333,7 @@ def test_ospf_json():
 
     for rnum in range(1, 5):
         router = tgen.gears["r{}".format(rnum)]
+        logger.info(router.vtysh_cmd("show ip ospf database"))
         logger.info('Comparing router "%s" "show ip ospf json" output', router.name)
         expected = {
             "routerId": "10.0.255.{}".format(rnum),
@@ -476,7 +473,18 @@ def test_ospf_link_down_kernel_route():
         assertmsg = 'OSPF IPv4 route mismatch in router "{}" after link down'.format(
             router.name
         )
-        assert topotest.json_cmp(routes, expected) is None, assertmsg
+        count = 0
+        not_found = True
+        while not_found and count < 10:
+            not_found = topotest.json_cmp(routes, expected)
+            if not_found:
+                sleep(1)
+                routes = topotest.ip4_route(router)
+                count += 1
+            else:
+                not_found = False
+                break
+        assert not_found is False, assertmsg
 
 
 def test_ospf6_link_down():
@@ -548,7 +556,19 @@ def test_ospf6_link_down_kernel_route():
         assertmsg = 'OSPF IPv6 route mismatch in router "{}" after link down'.format(
             router.name
         )
-        assert topotest.json_cmp(routes, expected) is None, assertmsg
+        count = 0
+        not_found = True
+        while not_found and count < 10:
+            not_found = topotest.json_cmp(routes, expected)
+            if not_found:
+                sleep(1)
+                routes = topotest.ip6_route(router)
+                count += 1
+            else:
+                not_found = False
+                break
+
+        assert not_found is False, assertmsg
 
 
 def test_memory_leak():