]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: fix pim test to wait for actual OSPF route convergence
authorChristian Hopps <chopps@labn.net>
Wed, 29 May 2024 07:32:46 +0000 (03:32 -0400)
committerChristian Hopps <chopps@labn.net>
Fri, 31 May 2024 09:16:22 +0000 (05:16 -0400)
Signed-off-by: Christian Hopps <chopps@labn.net>
tests/topotests/pim_igmp_vrf/r1/ospf_blue_route.json [new file with mode: 0644]
tests/topotests/pim_igmp_vrf/r1/ospf_red_route.json [new file with mode: 0644]
tests/topotests/pim_igmp_vrf/r1/ospfd.conf
tests/topotests/pim_igmp_vrf/r1/pimd.conf
tests/topotests/pim_igmp_vrf/r11/ospfd.conf
tests/topotests/pim_igmp_vrf/r12/ospfd.conf
tests/topotests/pim_igmp_vrf/test_pim_vrf.py

diff --git a/tests/topotests/pim_igmp_vrf/r1/ospf_blue_route.json b/tests/topotests/pim_igmp_vrf/r1/ospf_blue_route.json
new file mode 100644 (file)
index 0000000..c5e89d1
--- /dev/null
@@ -0,0 +1,54 @@
+{
+  "blue": {
+    "vrfName": "blue",
+    "192.168.0.1/32": {
+      "routeType": "N",
+      "transit": false,
+      "cost": 0,
+      "area": "0.0.0.0",
+      "nexthops": [
+        {
+          "ip": " ",
+          "directlyAttachedTo": "blue"
+        }
+      ]
+    },
+    "192.168.0.11/32": {
+      "routeType": "N",
+      "transit": false,
+      "cost": 10,
+      "area": "0.0.0.0",
+      "nexthops": [
+        {
+          "ip": "192.168.101.11",
+          "via": "r1-eth1",
+          "advertisedRouter": "192.168.0.11"
+        }
+      ]
+    },
+    "192.168.100.0/24": {
+      "routeType": "N",
+      "transit": false,
+      "cost": 10,
+      "area": "0.0.0.0",
+      "nexthops": [
+        {
+          "ip": " ",
+          "directlyAttachedTo": "r1-eth0"
+        }
+      ]
+    },
+    "192.168.101.0/24": {
+      "routeType": "N",
+      "transit": true,
+      "cost": 10,
+      "area": "0.0.0.0",
+      "nexthops": [
+        {
+          "ip": " ",
+          "directlyAttachedTo": "r1-eth1"
+        }
+      ]
+    }
+  }
+}
diff --git a/tests/topotests/pim_igmp_vrf/r1/ospf_red_route.json b/tests/topotests/pim_igmp_vrf/r1/ospf_red_route.json
new file mode 100644 (file)
index 0000000..2fc340d
--- /dev/null
@@ -0,0 +1,54 @@
+{
+  "red": {
+    "vrfName": "red",
+    "192.168.0.1/32": {
+      "routeType": "N",
+      "transit": false,
+      "cost": 0,
+      "area": "0.0.0.0",
+      "nexthops": [
+        {
+          "ip": " ",
+          "directlyAttachedTo": "red"
+        }
+      ]
+    },
+    "192.168.0.12/32": {
+      "routeType": "N",
+      "transit": false,
+      "cost": 10,
+      "area": "0.0.0.0",
+      "nexthops": [
+        {
+          "ip": "192.168.101.12",
+          "via": "r1-eth3",
+          "advertisedRouter": "192.168.0.12"
+        }
+      ]
+    },
+    "192.168.100.0/24": {
+      "routeType": "N",
+      "transit": false,
+      "cost": 10,
+      "area": "0.0.0.0",
+      "nexthops": [
+        {
+          "ip": " ",
+          "directlyAttachedTo": "r1-eth2"
+        }
+      ]
+    },
+    "192.168.101.0/24": {
+      "routeType": "N",
+      "transit": true,
+      "cost": 10,
+      "area": "0.0.0.0",
+      "nexthops": [
+        {
+          "ip": " ",
+          "directlyAttachedTo": "r1-eth3"
+        }
+      ]
+    }
+  }
+}
index 88eb5a8a054c56495567ffa2daad2bbb45597997..9b9a261b1d31c8ba2b415112aaa69509d5648633 100644 (file)
@@ -1,6 +1,8 @@
 hostname r1
 !
 ! debug ospf event
+! debug ospf nsm
+! debug ospf packet hello
 !
 !
 interface r1-eth1
index 040c3d01b1d0c4debe50e55e4c5dc148b4f38dbc..c4ddced0227a94555fad1e9952d1e9f330e469af 100644 (file)
@@ -2,6 +2,7 @@ hostname r1
 !
 ! debug igmp events
 ! debug igmp packets
+! debug mroute detail
 ! debug pim events
 ! debug pim packets
 ! debug pim trace
index 86fb66db6175310ceff4ee8530dce4bfd5e32a9d..e52737cb18419cc282a36b0b44219f71c92351ea 100644 (file)
@@ -1,6 +1,8 @@
 hostname r11
 !
 ! debug ospf event
+! debug ospf nsm
+! debug ospf packet hello
 !
 interface r11-eth0
  ip ospf hello-interval 2
index f0dcabece2c3dd028c3455de7b84b76e5a0c64fb..cd944061f776aab04a1fa494a55b9b185e826195 100644 (file)
@@ -1,6 +1,8 @@
 hostname r12
 !
 ! debug ospf event
+! debug ospf nsm
+! debug ospf packet hello
 !
 interface r12-eth0
  ip ospf hello-interval 2
index ddc430330d3dbb5320b05f630b9428ce349f2464..01c496d70388f12bd3acbb048fd0fb75672a0f7c 100755 (executable)
@@ -60,7 +60,7 @@ TOPOLOGY = """
 +---------+                  +------------+         |        +---------+
 | Host H1 | 192.168.100.0/24 |            | .1      |    .11 | Host H2 |
 | receive |------------------|  VRF Blue  |---------+--------| PIM RP  |
-|IGMP JOIN| .10           .1 |            | 192.168.101.0/24 |         |  
+|IGMP JOIN| .10           .1 |            | 192.168.101.0/24 |         |
 +---------+                  |            |                  +---------+
                             =| = = R1 = = |=
 +---------+                  |            |                  +---------+
@@ -68,7 +68,7 @@ TOPOLOGY = """
 | receive |------------------|  VRF Red   |---------+--------| PIM RP  |
 |IGMP JOIN| .20           .1 |            | .1      |    .12 |         |
 +---------+                  +------------+         |        +---------+
-                                                 .4 | 
+                                                 .4 |
                                                +----------+
                                                |  Host H4 |
                                                |  Source  |
@@ -80,6 +80,7 @@ import functools
 import os
 import sys
 import pytest
+import logging
 
 # Save the Current Working Directory to find configuration files.
 CWD = os.path.dirname(os.path.realpath(__file__))
@@ -91,7 +92,7 @@ from lib import topotest
 from lib.topogen import Topogen, TopoRouter, get_topogen
 from lib.topolog import logger
 from lib.topotest import iproute2_is_vrf_capable
-from lib.common_config import required_linux_kernel_version
+from lib.common_config import required_linux_kernel_version, retry
 from lib.pim import McastTesterHelper
 
 
@@ -192,6 +193,17 @@ def setup_module(module):
 
     tgen.start_router()
 
+    # iproute2 needs to support VRFs for this suite to run.
+    if not iproute2_is_vrf_capable():
+        pytest.skip(
+            "Installed iproute2 version does not support VRFs", allow_module_level=True
+        )
+
+    if os.getenv("MROUTE_VRF_MISSING"):
+        pytest.skip(
+            "Kernel does not support vrf mroute tables.", allow_module_level=True
+        )
+
 
 def teardown_module(module):
     tgen = get_topogen()
@@ -202,16 +214,13 @@ def test_ospf_convergence():
     "Test for OSPFv2 convergence"
     tgen = get_topogen()
 
-    # iproute2 needs to support VRFs for this suite to run.
-    if not iproute2_is_vrf_capable():
-        pytest.skip("Installed iproute2 version does not support VRFs")
-
     # Skip if previous fatal error condition is raised
     if tgen.routers_have_failure():
         pytest.skip(tgen.errors)
 
     logger.info("Checking OSPFv2 convergence on router r1 for VRF blue")
 
+    # Check for blue neighbor
     router = tgen.gears["r1"]
     reffile = os.path.join(CWD, "r1/ospf_blue_neighbor.json")
     expected = json.loads(open(reffile).read())
@@ -223,7 +232,22 @@ def test_ospf_convergence():
         expected,
     )
     _, res = topotest.run_and_expect(test_func, None, count=60, wait=2)
-    assertmsg = "OSPF router R1 did not converge on VRF blue"
+    assertmsg = "OSPF router R1 did not converge on VRF blue (nbr)"
+    assert res is None, assertmsg
+
+    # Check for blue loopback route
+    router = tgen.gears["r1"]
+    reffile = os.path.join(CWD, "r1/ospf_blue_route.json")
+    expected = json.loads(open(reffile).read())
+
+    test_func = functools.partial(
+        topotest.router_json_cmp,
+        router,
+        "show ip ospf vrf blue route json",
+        expected,
+    )
+    _, res = topotest.run_and_expect(test_func, None, count=30, wait=2)
+    assertmsg = "OSPF router R1 did not converge on VRF blue (route)"
     assert res is None, assertmsg
 
     logger.info("Checking OSPFv2 convergence on router r1 for VRF red")
@@ -236,7 +260,22 @@ def test_ospf_convergence():
         topotest.router_json_cmp, router, "show ip ospf vrf red neighbor json", expected
     )
     _, res = topotest.run_and_expect(test_func, None, count=60, wait=2)
-    assertmsg = "OSPF router R1 did not converge on VRF red"
+    assertmsg = "OSPF router R1 did not converge on VRF red (nbr)"
+    assert res is None, assertmsg
+
+    # Check for red loopback route
+    router = tgen.gears["r1"]
+    reffile = os.path.join(CWD, "r1/ospf_red_route.json")
+    expected = json.loads(open(reffile).read())
+
+    test_func = functools.partial(
+        topotest.router_json_cmp,
+        router,
+        "show ip ospf vrf red route json",
+        expected,
+    )
+    _, res = topotest.run_and_expect(test_func, None, count=30, wait=2)
+    assertmsg = "OSPF router R1 did not converge on VRF red (route)"
     assert res is None, assertmsg
 
 
@@ -275,10 +314,13 @@ def test_pim_convergence():
     assert res is None, assertmsg
 
 
-def test_vrf_pimreg_interfaces():
+def _test_vrf_pimreg_interfaces():
     "Adding PIM RP in VRF information and verify pimreg interfaces"
     tgen = get_topogen()
 
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
     r1 = tgen.gears["r1"]
     r1.vtysh_cmd("conf\ninterface blue\nip pim")
     r1.vtysh_cmd("conf\nvrf blue\nip pim rp 192.168.0.11 239.100.0.1/32\nexit-vrf")
@@ -292,7 +334,7 @@ def test_vrf_pimreg_interfaces():
         "show ip pim vrf blue inter pimreg11 json",
         expected,
     )
-    _, res = topotest.run_and_expect(test_func, None, count=5, wait=2)
+    _, res = topotest.run_and_expect(test_func, None, count=15, wait=2)
     assertmsg = "PIM router R1, VRF blue (table 11) pimreg11 interface missing or incorrect status"
     assert res is None, assertmsg
 
@@ -308,10 +350,20 @@ def test_vrf_pimreg_interfaces():
         "show ip pim vrf red inter pimreg12 json",
         expected,
     )
-    _, res = topotest.run_and_expect(test_func, None, count=5, wait=2)
+    _, res = topotest.run_and_expect(test_func, None, count=15, wait=2)
     assertmsg = "PIM router R1, VRF red (table 12) pimreg12 interface missing or incorrect status"
     assert res is None, assertmsg
 
+def test_vrf_pimreg_interfaces():
+    tgen = get_topogen()
+    r1 = tgen.gears["r1"]
+    try:
+        _test_vrf_pimreg_interfaces()
+    except Exception:
+        # get some debug info.
+        output = r1.net.cmd_nostatus("ip -o link")
+        logging.error("ip link info after failure: %s", output)
+        raise
 
 ##################################
 ###  Test PIM / IGMP with VRF