From b2779247e631ca35042e97d6e3a52d7e4de6c130 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Wed, 29 Nov 2023 14:28:08 +0100 Subject: [PATCH] topotests: use the Role field when testing ospf6 To handle the future change of naming in the ospf6 state, align the ospf6 tests with the new 'Role' nickname instead of the old 'state' value. Signed-off-by: Philippe Guibert --- tests/topotests/lib/ospf.py | 14 +++++++------- .../test_ospf6_ecmp_inter_area.py | 2 +- .../rt1/show_ipv6_ospf_neighbor.json | 2 +- .../rt2/show_ipv6_ospf_neighbor.json | 4 ++-- .../rt3/show_ipv6_ospf_neighbor.json | 6 +++--- .../rt4/show_ipv6_ospf_neighbor.json | 4 ++-- .../rt5/show_ipv6_ospf_neighbor.json | 2 +- .../rt6/show_ipv6_ospf_neighbor.json | 4 ++-- .../rt7/show_ipv6_ospf_neighbor.json | 2 +- .../test_ospf6_point_to_multipoint.py | 2 +- tests/topotests/ospf6_topo1/test_ospf6_topo1.py | 7 +------ tests/topotests/ospf6_topo2/test_ospf6_topo2.py | 3 +-- tests/topotests/ospf_topo1/test_ospf_topo1.py | 2 +- tests/topotests/ospf_topo2/test_ospf_topo2.py | 2 +- 14 files changed, 25 insertions(+), 31 deletions(-) diff --git a/tests/topotests/lib/ospf.py b/tests/topotests/lib/ospf.py index 5b18f8b679ce..1007faa9ec75 100644 --- a/tests/topotests/lib/ospf.py +++ b/tests/topotests/lib/ospf.py @@ -779,16 +779,16 @@ def verify_ospf6_neighbor(tgen, topo=None, dut=None, input_dict=None, lan=False) "ospf6": { "neighbors": { "r1": { - "state": "Full", - "role": "DR" + "role": "Full", + "nbrState": "DR" }, "r2": { - "state": "Full", - "role": "DROther" + "role": "Full", + "nbrState": "DROther" }, "r3": { - "state": "Full", - "role": "DROther" + "role": "Full", + "nbrState": "DROther" } } } @@ -970,7 +970,7 @@ def verify_ospf6_neighbor(tgen, topo=None, dut=None, input_dict=None, lan=False) for (index, d) in enumerate(show_ospf_json["neighbors"]) ) try: - nh_state = get_index_val.get(neighbor_ip)["state"] + nh_state = get_index_val.get(neighbor_ip)["role"] intf_state = get_index_val.get(neighbor_ip)["ifState"] except TypeError: errormsg = ( diff --git a/tests/topotests/ospf6_ecmp_inter_area/test_ospf6_ecmp_inter_area.py b/tests/topotests/ospf6_ecmp_inter_area/test_ospf6_ecmp_inter_area.py index 2eaccb8348d0..533709f04984 100644 --- a/tests/topotests/ospf6_ecmp_inter_area/test_ospf6_ecmp_inter_area.py +++ b/tests/topotests/ospf6_ecmp_inter_area/test_ospf6_ecmp_inter_area.py @@ -119,7 +119,7 @@ def expect_neighbor_full(router, neighbor): topotest.router_json_cmp, tgen.gears[router], "show ipv6 ospf6 neighbor json", - {"neighbors": [{"neighborId": neighbor, "state": "Full"}]}, + {"neighbors": [{"neighborId": neighbor, "role": "Full"}]}, ) _, result = topotest.run_and_expect(test_func, None, count=130, wait=1) assertmsg = '"{}" convergence failure'.format(router) diff --git a/tests/topotests/ospf6_gr_topo1/rt1/show_ipv6_ospf_neighbor.json b/tests/topotests/ospf6_gr_topo1/rt1/show_ipv6_ospf_neighbor.json index cb88358639e5..970d1240a4a7 100644 --- a/tests/topotests/ospf6_gr_topo1/rt1/show_ipv6_ospf_neighbor.json +++ b/tests/topotests/ospf6_gr_topo1/rt1/show_ipv6_ospf_neighbor.json @@ -3,7 +3,7 @@ { "neighborId":"2.2.2.2", "priority":1, - "state":"Full", + "role":"Full", "ifState":"PointToPoint", "interfaceName":"eth-rt2", "interfaceState":"PointToPoint" diff --git a/tests/topotests/ospf6_gr_topo1/rt2/show_ipv6_ospf_neighbor.json b/tests/topotests/ospf6_gr_topo1/rt2/show_ipv6_ospf_neighbor.json index e4f27bf37f7c..eaafee7fb873 100644 --- a/tests/topotests/ospf6_gr_topo1/rt2/show_ipv6_ospf_neighbor.json +++ b/tests/topotests/ospf6_gr_topo1/rt2/show_ipv6_ospf_neighbor.json @@ -3,7 +3,7 @@ { "neighborId":"3.3.3.3", "priority":1, - "state":"Full", + "role":"Full", "ifState":"PointToPoint", "interfaceName":"eth-rt3", "interfaceState":"PointToPoint" @@ -11,7 +11,7 @@ { "neighborId":"1.1.1.1", "priority":1, - "state":"Full", + "role":"Full", "ifState":"PointToPoint", "interfaceName":"eth-rt1", "interfaceState":"PointToPoint" diff --git a/tests/topotests/ospf6_gr_topo1/rt3/show_ipv6_ospf_neighbor.json b/tests/topotests/ospf6_gr_topo1/rt3/show_ipv6_ospf_neighbor.json index d0d7f45b0e18..f8167b3349c9 100644 --- a/tests/topotests/ospf6_gr_topo1/rt3/show_ipv6_ospf_neighbor.json +++ b/tests/topotests/ospf6_gr_topo1/rt3/show_ipv6_ospf_neighbor.json @@ -3,7 +3,7 @@ { "neighborId":"2.2.2.2", "priority":1, - "state":"Full", + "role":"Full", "ifState":"PointToPoint", "interfaceName":"eth-rt2", "interfaceState":"PointToPoint" @@ -11,7 +11,7 @@ { "neighborId":"4.4.4.4", "priority":1, - "state":"Full", + "role":"Full", "ifState":"PointToPoint", "interfaceName":"eth-rt4", "interfaceState":"PointToPoint" @@ -19,7 +19,7 @@ { "neighborId":"6.6.6.6", "priority":1, - "state":"Full", + "role":"Full", "ifState":"PointToPoint", "interfaceName":"eth-rt6", "interfaceState":"PointToPoint" diff --git a/tests/topotests/ospf6_gr_topo1/rt4/show_ipv6_ospf_neighbor.json b/tests/topotests/ospf6_gr_topo1/rt4/show_ipv6_ospf_neighbor.json index 36abba4f8750..1a0172cf0429 100644 --- a/tests/topotests/ospf6_gr_topo1/rt4/show_ipv6_ospf_neighbor.json +++ b/tests/topotests/ospf6_gr_topo1/rt4/show_ipv6_ospf_neighbor.json @@ -3,7 +3,7 @@ { "neighborId":"3.3.3.3", "priority":1, - "state":"Full", + "role":"Full", "ifState":"PointToPoint", "interfaceName":"eth-rt3", "interfaceState":"PointToPoint" @@ -11,7 +11,7 @@ { "neighborId":"5.5.5.5", "priority":1, - "state":"Full", + "role":"Full", "ifState":"PointToPoint", "interfaceName":"eth-rt5", "interfaceState":"PointToPoint" diff --git a/tests/topotests/ospf6_gr_topo1/rt5/show_ipv6_ospf_neighbor.json b/tests/topotests/ospf6_gr_topo1/rt5/show_ipv6_ospf_neighbor.json index 9b6ac911d15b..81afb32a0a97 100644 --- a/tests/topotests/ospf6_gr_topo1/rt5/show_ipv6_ospf_neighbor.json +++ b/tests/topotests/ospf6_gr_topo1/rt5/show_ipv6_ospf_neighbor.json @@ -3,7 +3,7 @@ { "neighborId":"4.4.4.4", "priority":1, - "state":"Full", + "role":"Full", "ifState":"PointToPoint", "interfaceName":"eth-rt4", "interfaceState":"PointToPoint" diff --git a/tests/topotests/ospf6_gr_topo1/rt6/show_ipv6_ospf_neighbor.json b/tests/topotests/ospf6_gr_topo1/rt6/show_ipv6_ospf_neighbor.json index aba181ba3f8d..604c9829fcb8 100644 --- a/tests/topotests/ospf6_gr_topo1/rt6/show_ipv6_ospf_neighbor.json +++ b/tests/topotests/ospf6_gr_topo1/rt6/show_ipv6_ospf_neighbor.json @@ -3,7 +3,7 @@ { "neighborId":"3.3.3.3", "priority":1, - "state":"Full", + "role":"Full", "ifState":"PointToPoint", "interfaceName":"eth-rt3", "interfaceState":"PointToPoint" @@ -11,7 +11,7 @@ { "neighborId":"7.7.7.7", "priority":1, - "state":"Full", + "role":"Full", "ifState":"PointToPoint", "interfaceName":"eth-rt7", "interfaceState":"PointToPoint" diff --git a/tests/topotests/ospf6_gr_topo1/rt7/show_ipv6_ospf_neighbor.json b/tests/topotests/ospf6_gr_topo1/rt7/show_ipv6_ospf_neighbor.json index 5548691ef375..e598d57e2398 100644 --- a/tests/topotests/ospf6_gr_topo1/rt7/show_ipv6_ospf_neighbor.json +++ b/tests/topotests/ospf6_gr_topo1/rt7/show_ipv6_ospf_neighbor.json @@ -3,7 +3,7 @@ { "neighborId":"6.6.6.6", "priority":1, - "state":"Full", + "role":"Full", "ifState":"PointToPoint", "interfaceName":"eth-rt6", "interfaceState":"PointToPoint" diff --git a/tests/topotests/ospf6_point_to_multipoint/test_ospf6_point_to_multipoint.py b/tests/topotests/ospf6_point_to_multipoint/test_ospf6_point_to_multipoint.py index 142acf1eb47d..d8717c9edd50 100644 --- a/tests/topotests/ospf6_point_to_multipoint/test_ospf6_point_to_multipoint.py +++ b/tests/topotests/ospf6_point_to_multipoint/test_ospf6_point_to_multipoint.py @@ -174,7 +174,7 @@ def expect_neighbor_full(router, neighbor): topotest.router_json_cmp, tgen.gears[router], "show ipv6 ospf6 neighbor json", - {"neighbors": [{"neighborId": neighbor, "state": "Full"}]}, + {"neighbors": [{"neighborId": neighbor, "role": "Full"}]}, ) _, result = topotest.run_and_expect(test_func, None, count=130, wait=1) assertmsg = '"{}" convergence failure'.format(router) diff --git a/tests/topotests/ospf6_topo1/test_ospf6_topo1.py b/tests/topotests/ospf6_topo1/test_ospf6_topo1.py index 5649757010c3..f4b5e721703f 100644 --- a/tests/topotests/ospf6_topo1/test_ospf6_topo1.py +++ b/tests/topotests/ospf6_topo1/test_ospf6_topo1.py @@ -174,7 +174,7 @@ def expect_neighbor_full(router, neighbor): topotest.router_json_cmp, tgen.gears[router], "show ipv6 ospf6 neighbor json", - {"neighbors": [{"neighborId": neighbor, "state": "Full"}]}, + {"neighbors": [{"neighborId": neighbor, "role": "Full"}]}, ) _, result = topotest.run_and_expect(test_func, None, count=130, wait=1) assertmsg = '"{}" convergence failure'.format(router) @@ -220,7 +220,6 @@ def compare_show_ipv6(rname, expected): def test_ospfv3_routingTable(): - tgen = get_topogen() if tgen.routers_have_failure(): pytest.skip("skipped because of router(s) failure") @@ -243,7 +242,6 @@ def test_ospfv3_routingTable(): def test_linux_ipv6_kernel_routingTable(): - tgen = get_topogen() if tgen.routers_have_failure(): @@ -335,7 +333,6 @@ def test_linux_ipv6_kernel_routingTable(): def test_ospfv3_routingTable_write_multiplier(): - tgen = get_topogen() if tgen.routers_have_failure(): pytest.skip("skipped because of router(s) failure") @@ -365,7 +362,6 @@ def test_ospfv3_routingTable_write_multiplier(): def test_shutdown_check_stderr(): - tgen = get_topogen() if tgen.routers_have_failure(): @@ -413,7 +409,6 @@ def test_shutdown_check_memleak(): if __name__ == "__main__": - # To suppress tracebacks, either use the following pytest call or # add "--tb=no" to cli # retval = pytest.main(["-s", "--tb=no"]) diff --git a/tests/topotests/ospf6_topo2/test_ospf6_topo2.py b/tests/topotests/ospf6_topo2/test_ospf6_topo2.py index f95f7bbe5e8b..07624fcac4a8 100644 --- a/tests/topotests/ospf6_topo2/test_ospf6_topo2.py +++ b/tests/topotests/ospf6_topo2/test_ospf6_topo2.py @@ -129,7 +129,6 @@ def setup_module(mod): router_list = tgen.routers() for rname, router in router_list.items(): - daemon_file = "{}/{}/zebra.conf".format(CWD, rname) if os.path.isfile(daemon_file): router.load_config(TopoRouter.RD_ZEBRA, daemon_file) @@ -157,7 +156,7 @@ def expect_neighbor_full(router, neighbor): topotest.router_json_cmp, tgen.gears[router], "show ipv6 ospf6 neighbor json", - {"neighbors": [{"neighborId": neighbor, "state": "Full"}]}, + {"neighbors": [{"neighborId": neighbor, "role": "Full"}]}, ) _, result = topotest.run_and_expect(test_func, None, count=130, wait=1) assertmsg = '"{}" convergence failure'.format(router) diff --git a/tests/topotests/ospf_topo1/test_ospf_topo1.py b/tests/topotests/ospf_topo1/test_ospf_topo1.py index a079f5698ff1..f573486d751b 100644 --- a/tests/topotests/ospf_topo1/test_ospf_topo1.py +++ b/tests/topotests/ospf_topo1/test_ospf_topo1.py @@ -154,7 +154,7 @@ def expect_ospfv3_neighbor_full(router, neighbor): topotest.router_json_cmp, tgen.gears[router], "show ipv6 ospf6 neighbor json", - {"neighbors": [{"neighborId": neighbor, "state": "Full"}]}, + {"neighbors": [{"neighborId": neighbor, "role": "Full"}]}, ) _, result = topotest.run_and_expect(test_func, None, count=130, wait=1) assertmsg = '"{}" convergence failure'.format(router) diff --git a/tests/topotests/ospf_topo2/test_ospf_topo2.py b/tests/topotests/ospf_topo2/test_ospf_topo2.py index 8be06e41aff2..19c369d7ecd0 100644 --- a/tests/topotests/ospf_topo2/test_ospf_topo2.py +++ b/tests/topotests/ospf_topo2/test_ospf_topo2.py @@ -167,7 +167,7 @@ def wait_for_ospf(router, ip_version, neighbors, timeout=60): if ip_version == 4: filter = {"converged": "Full"} else: - filter = {"state": "Full"} + filter = {"role": "Full"} def is_match(neighbor): for k, v in filter.items():