From: Renato Westphal Date: Mon, 13 Jun 2022 18:49:45 +0000 (-0300) Subject: tests: fix sporadic failures in the ldp_topo1 topotest X-Git-Tag: base_8.4~360^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=1c333cbed925dce20e94084226510278c2f56929;p=matthieu%2Ffrr.git tests: fix sporadic failures in the ldp_topo1 topotest 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 --- 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 index 0000000000..d9192f1104 --- /dev/null +++ b/tests/topotests/ldp_topo1/r1/show_ip_ospf_neighbor.json @@ -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 index 0000000000..ea78592bd5 --- /dev/null +++ b/tests/topotests/ldp_topo1/r2/show_ip_ospf_neighbor.json @@ -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 index 0000000000..d3c50247ea --- /dev/null +++ b/tests/topotests/ldp_topo1/r3/show_ip_ospf_neighbor.json @@ -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 index 0000000000..20751a2884 --- /dev/null +++ b/tests/topotests/ldp_topo1/r4/show_ip_ospf_neighbor.json @@ -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 + } + ] + } +} diff --git a/tests/topotests/ldp_topo1/test_ldp_topo1.py b/tests/topotests/ldp_topo1/test_ldp_topo1.py index 8d69787236..cb8adfb55d 100644 --- a/tests/topotests/ldp_topo1/test_ldp_topo1.py +++ b/tests/topotests/ldp_topo1/test_ldp_topo1.py @@ -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):