From 17e8fa831adcf50935a386f8b6ac465e69876b27 Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Mon, 14 Nov 2022 12:49:05 +0100 Subject: [PATCH 1/2] tests: fix bfd in isis_lfa_topo1 step24 isis_lfa_topo1 topotests regularly fails at step 24. The test expects that the BFD session between rt1 and rt2 comes down after shutting the link between rt1 and rt2. Since the BFD is multihop, the BFD can get back through rt3. Set the BFD type to single-hop. Signed-off-by: Louis Scalbert --- tests/topotests/isis_lfa_topo1/rt1/bfdd.conf | 2 -- tests/topotests/isis_lfa_topo1/rt2/bfdd.conf | 2 -- .../isis_lfa_topo1/test_isis_lfa_topo1.py | 25 ++++++++++--------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/tests/topotests/isis_lfa_topo1/rt1/bfdd.conf b/tests/topotests/isis_lfa_topo1/rt1/bfdd.conf index 86cf68dd8d..ef67eae0cf 100644 --- a/tests/topotests/isis_lfa_topo1/rt1/bfdd.conf +++ b/tests/topotests/isis_lfa_topo1/rt1/bfdd.conf @@ -1,6 +1,4 @@ hostname rt1 ! bfd - peer 2001:db8:1000::2 multihop local-address 2001:db8:1000::1 - ! ! diff --git a/tests/topotests/isis_lfa_topo1/rt2/bfdd.conf b/tests/topotests/isis_lfa_topo1/rt2/bfdd.conf index 40357a4d03..25fa0d8a46 100644 --- a/tests/topotests/isis_lfa_topo1/rt2/bfdd.conf +++ b/tests/topotests/isis_lfa_topo1/rt2/bfdd.conf @@ -1,6 +1,4 @@ hostname rt2 ! bfd - peer 2001:db8:1000::1 multihop local-address 2001:db8:1000::2 - ! ! diff --git a/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py b/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py index f72942b607..f46f6bf9c3 100755 --- a/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py +++ b/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py @@ -941,14 +941,14 @@ def test_rib_ipv6_step23(): conf_file = os.path.join(CWD, "{}/bfdd.conf".format(rname)) tgen.net[rname].cmd("vtysh -f {}".format(conf_file)) - rname = "rt1" - expect = '[{"multihop":true,"peer":"2001:db8:1000::2","local":"2001:db8:1000::1","status":"up"}]' - router_compare_json_output(rname, "show bfd peers json", expect) - logger.info("Set ISIS BFD") tgen.net["rt1"].cmd('vtysh -c "conf t" -c "int eth-rt2" -c "isis bfd"') tgen.net["rt2"].cmd('vtysh -c "conf t" -c "int eth-rt1" -c "isis bfd"') + rname = "rt1" + expect = '[{"multihop":false,"interface":"eth-rt2","status":"up"}]' + router_compare_json_output(rname, "show bfd peers json", expect) + router_compare_json_output( rname, "show ipv6 route isis json", @@ -968,6 +968,11 @@ def test_rib_ipv6_step23(): # - Route switchover of routes via eth-rt2 # def test_rib_ipv6_step24(): + def _bfd_down(router): + output = json.loads(router.vtysh_cmd("show bfd peers json")) + expected = [] + return topotest.json_cmp(output, expected, exact=True) + logger.info("Test (step 24): verify IPv6 RIB") tgen = get_topogen() @@ -979,14 +984,10 @@ def test_rib_ipv6_step24(): tgen.net.cmd_raises("ip link set s1 down") rname = "rt1" - expect = '[{"multihop":true,"peer":"2001:db8:1000::2","local":"2001:db8:1000::1","status":"down"}]' - router_compare_json_output( - rname, - "show bfd peers json", - expect, - count=40, - wait=0.05, - ) + router = tgen.gears[rname] + test_func = partial(_bfd_down, router) + success, result = topotest.run_and_expect(test_func, None, count=30, wait=0.05) + assert result is None, 'BFD session is still up on "{}"'.format(router) router_compare_json_output( rname, From f2393c755332e635a2f32bd682182432aa043036 Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Mon, 21 Nov 2022 12:14:03 +0100 Subject: [PATCH 2/2] tests: do not use a custom expect function in isis_lfa_topo1 Replace the custom run and expect function by one from the library. Signed-off-by: Louis Scalbert --- .../isis_lfa_topo1/test_isis_lfa_topo1.py | 95 +++++++++++++++---- 1 file changed, 78 insertions(+), 17 deletions(-) diff --git a/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py b/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py index f46f6bf9c3..d01ba9da3f 100755 --- a/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py +++ b/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py @@ -758,6 +758,80 @@ def test_rib_ipv6_step17(): # - Route switchover of routes via eth-rt2 # def test_rib_ipv6_step18(): + def _rt2_neigh_down(router): + output = json.loads(router.vtysh_cmd("show isis neighbor rt2 json")) + + """ + Previous output was: + { + "areas":[ + { + "area":"1", + "circuits":[ + { + "circuit":0, + "adj":"rt2", + "interface":{ + "name":"eth-rt2", + "state":"Up", + "adj-flaps":1, + "last-ago":"21s", + "circuit-type":"L1", + "speaks":"IPv6", + "topologies":{ + "topo-0":"ipv6-unicast" + }, + "snpa":"2020.2020.2020", + "area-address":{ + "isonet":"49.0000" + }, + "ipv6-link-local":{ + "ipv6":"fe80::ac19:a8ff:fee5:f48f" + }, + "adj-sid":{ + } + }, + "level":1, + "expires-in":"2s" + }, + { + "circuit":0 + }, + { + "circuit":0 + }, + { + "circuit":0 + }, + { + "circuit":0 + }, + { + "circuit":0 + } + ] + } + ] + """ + + expected = { + "areas": [ + { + "area": "1", + "circuits": [ + {"circuit": 0}, + {"circuit": 0}, + {"circuit": 0}, + {"circuit": 0}, + {"circuit": 0}, + {"circuit": 0}, + ], + } + ] + } + + return topotest.json_cmp(output, expected, exact=True) + logger.info("Test (step 18): verify IPv6 RIB") tgen = get_topogen() @@ -769,23 +843,10 @@ def test_rib_ipv6_step18(): tgen.net.cmd_raises("ip link set s1 down") rname = "rt1" - - retry = 200 + 1 - - while retry: - retry -= 1 - output = tgen.gears[rname].vtysh_cmd("show isis neighbor json") - output_json = json.loads(output) - found = False - for neighbor in output_json["areas"][0]["circuits"]: - if "adj" in neighbor and neighbor["adj"] == "rt2": - found = True - break - if not found: - break - time.sleep(0.05) - - assert not found, "rt2 neighbor is still present" + router = tgen.gears[rname] + test_func = partial(_rt2_neigh_down, router) + success, result = topotest.run_and_expect(test_func, None, count=200, wait=0.05) + assert result is None, 'rt2 neighbor is still present on "{}"'.format(router) router_compare_json_output( rname,