]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: fix sporadic failures in the ldp_topo1 topotest 11407/head
authorRenato Westphal <renato@opensourcerouting.org>
Mon, 13 Jun 2022 18:49:45 +0000 (15:49 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 14 Jun 2022 15:21:30 +0000 (12:21 -0300)
The sporadic failures were happening because, under heavy load,
the r4 router could form an OSPF adjacency with r3 a few seconds
before doing the same with r2. In that interim, LDP could establish
a neighborship with r2 going through r3 (instead of connecting
directly). That would cause all label mappings received from r3
to be ignored since they can't be mapped to the routes' nexthops
received from zebra, causing all sorts of test failures. None of
this is erroneous behavior as LDP simply follows the IGP.

The fix consists of updating the test to ensure all expected OSPF
adjacencies fully converged before proceeding to the LDP checks.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
tests/topotests/ldp_topo1/r1/show_ip_ospf_neighbor.json [new file with mode: 0644]
tests/topotests/ldp_topo1/r2/show_ip_ospf_neighbor.json [new file with mode: 0644]
tests/topotests/ldp_topo1/r3/show_ip_ospf_neighbor.json [new file with mode: 0644]
tests/topotests/ldp_topo1/r4/show_ip_ospf_neighbor.json [new file with mode: 0644]
tests/topotests/ldp_topo1/test_ldp_topo1.py

diff --git a/tests/topotests/ldp_topo1/r1/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r1/show_ip_ospf_neighbor.json
new file mode 100644 (file)
index 0000000..d9192f1
--- /dev/null
@@ -0,0 +1,14 @@
+{
+  "neighbors": {
+    "2.2.2.2": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.1.2",
+        "requestCounter": 0
+      }
+    ]
+  }
+}
diff --git a/tests/topotests/ldp_topo1/r2/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r2/show_ip_ospf_neighbor.json
new file mode 100644 (file)
index 0000000..ea78592
--- /dev/null
@@ -0,0 +1,42 @@
+{
+  "neighbors": {
+    "1.1.1.1": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.1.1",
+        "requestCounter": 0
+      }
+    ],
+    "3.3.3.3": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.2.3",
+        "requestCounter": 0
+      },
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.3.3",
+        "requestCounter": 0
+      }
+    ],
+    "4.4.4.4": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.2.4",
+        "requestCounter": 0
+      }
+    ]
+  }
+}
diff --git a/tests/topotests/ldp_topo1/r3/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r3/show_ip_ospf_neighbor.json
new file mode 100644 (file)
index 0000000..d3c5024
--- /dev/null
@@ -0,0 +1,32 @@
+{
+  "neighbors": {
+    "2.2.2.2": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.2.2",
+        "requestCounter": 0
+      },
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.3.2",
+        "requestCounter": 0
+      }
+    ],
+    "4.4.4.4": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.2.4",
+        "requestCounter": 0
+      }
+    ]
+  }
+}
diff --git a/tests/topotests/ldp_topo1/r4/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r4/show_ip_ospf_neighbor.json
new file mode 100644 (file)
index 0000000..20751a2
--- /dev/null
@@ -0,0 +1,24 @@
+{
+  "neighbors": {
+    "2.2.2.2": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.2.2",
+        "requestCounter": 0
+      }
+    ],
+    "3.3.3.3": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.2.3",
+        "requestCounter": 0
+      }
+    ]
+  }
+}
index 8d69787236eddeb9fcd5f2366123830451a8edf9..cb8adfb55db693b200c6e691d61a4ae4ca8d3663 100644 (file)
@@ -63,9 +63,15 @@ import os
 import re
 import sys
 import pytest
+import json
+from functools import partial
 from time import sleep
 from lib.topolog import logger
 
+# Save the Current Working Directory to find configuration files.
+CWD = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(CWD, "../"))
+
 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 from lib import topotest
 from lib.topogen import Topogen, get_topogen
@@ -102,6 +108,29 @@ def build_topo(tgen):
     switch.add_link(tgen.gears["r3"])
 
 
+#####################################################
+##
+##   Helper functions
+##
+#####################################################
+
+
+def router_compare_json_output(rname, command, reference, count=60, wait=1):
+    "Compare router JSON output"
+
+    logger.info('Comparing router "%s" "%s" output', rname, command)
+
+    tgen = get_topogen()
+    filename = "{}/{}/{}".format(CWD, rname, reference)
+    expected = json.loads(open(filename).read())
+
+    # Run test function until we get an result.
+    test_func = partial(topotest.router_json_cmp, tgen.gears[rname], command, expected)
+    _, diff = topotest.run_and_expect(test_func, None, count, wait)
+    assertmsg = '"{}" JSON output mismatches the expected result'.format(rname)
+    assert diff is None, assertmsg
+
+
 #####################################################
 ##
 ##   Tests starting
@@ -218,6 +247,19 @@ def test_mpls_interfaces():
         assert fatal_error == "", fatal_error
 
 
+def test_ospf_convergence():
+    logger.info("Test: check OSPF adjacencies")
+
+    # Skip if previous fatal error condition is raised
+    if fatal_error != "":
+        pytest.skip(fatal_error)
+
+    for rname in ["r1", "r2", "r3", "r4"]:
+        router_compare_json_output(
+            rname, "show ip ospf neighbor json", "show_ip_ospf_neighbor.json"
+        )
+
+
 def test_mpls_ldp_neighbor_establish():
     global fatal_error
     net = get_topogen().net
@@ -510,9 +552,10 @@ def test_mpls_ldp_binding():
             else:
                 print("r%s ok" % i)
 
-            assert (
-                failures == 0
-            ), "MPLS LDP Interface binding output for router r%s:\n%s" % (i, diff)
+            assert failures == 0, "MPLS LDP binding output for router r%s:\n%s" % (
+                i,
+                diff,
+            )
 
     # Make sure that all daemons are running
     for i in range(1, 5):