From c287dfd25cac1963c86493976f0794cde312f7cf Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 23 Mar 2021 22:15:58 +0000 Subject: [PATCH 1/4] tests: provide sane default for --topology-only Fixes: /usr/lib/python3.9/site-packages/_pytest/config/__init__.py:1463: in getoption val = getattr(self.option, name) E AttributeError: 'Namespace' object has no attribute 'topology_only' The above exception was the direct cause of the following exception: /usr/lib/python3.9/site-packages/pluggy/manager.py:127: in register hook._maybe_apply_history(hookimpl) /usr/lib/python3.9/site-packages/pluggy/hooks.py:333: in _maybe_apply_history res = self._hookexec(self, [method], kwargs) /usr/lib/python3.9/site-packages/pluggy/manager.py:93: in _hookexec return self._inner_hookexec(hook, methods, kwargs) /usr/lib/python3.9/site-packages/pluggy/manager.py:84: in self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( tests/topotests/conftest.py:62: in pytest_configure if config.getoption("--topology-only"): /usr/lib/python3.9/site-packages/_pytest/config/__init__.py:1474: in getoption raise ValueError(f"no option named {name!r}") from e E ValueError: no option named 'topology_only' Signed-off-by: Quentin Young --- tests/topotests/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/topotests/conftest.py b/tests/topotests/conftest.py index 7ad5d8c9ab..e00bebdaeb 100755 --- a/tests/topotests/conftest.py +++ b/tests/topotests/conftest.py @@ -61,6 +61,7 @@ def pytest_addoption(parser): parser.addoption( "--topology-only", action="store_true", + default=False, help="Only set up this topology, don't run tests", ) From 8ab4625666c46bbc59ab5f6c0b0799031dbc3873 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 23 Mar 2021 22:49:15 +0000 Subject: [PATCH 2/4] tests: remove duplicate pim test function Twice defined Signed-off-by: Quentin Young --- tests/topotests/lib/pim.py | 46 +------------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/tests/topotests/lib/pim.py b/tests/topotests/lib/pim.py index d07b58a774..970367a882 100644 --- a/tests/topotests/lib/pim.py +++ b/tests/topotests/lib/pim.py @@ -384,50 +384,6 @@ def _enable_disable_pim(tgen, topo, input_dict, router, build=False): return result -def add_rp_interfaces_and_pim_config(tgen, topo, interface, rp, rp_mapping): - """ - Add physical interfaces tp RP for all the RPs - - Parameters - ---------- - * `tgen` : Topogen object - * `topo` : json file data - * `interface` : RP interface - * `rp` : rp for given topology - * `rp_mapping` : dictionary of all groups and RPs - - Returns - ------- - True or False - """ - result = False - logger.debug("Entering lib API: {}".format(sys._getframe().f_code.co_name)) - - try: - config_data = [] - - for group, rp_list in rp_mapping.items(): - for _rp in rp_list: - config_data.append("interface {}".format(interface)) - config_data.append("ip address {}".format(_rp)) - config_data.append("ip pim") - - result = create_common_configuration( - tgen, rp, config_data, "interface_config" - ) - if result is not True: - return False - - except InvalidCLIError: - # Traceback - errormsg = traceback.format_exc() - logger.error(errormsg) - return errormsg - - logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name)) - return result - - def find_rp_details(tgen, topo): """ Find who is RP in topology and returns list of RPs @@ -2080,7 +2036,7 @@ def add_rp_interfaces_and_pim_config(tgen, topo, interface, rp, rp_mapping): logger.error(errormsg) return errormsg - logger.debug("Exiting lib API: add_rp_interfaces_and_pim_config()") + logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name)) return result From 5aab262b744e1c91259c4d62fb131b9906892e97 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 23 Mar 2021 22:49:35 +0000 Subject: [PATCH 3/4] tests: fix improper format strings in pim lib Signed-off-by: Quentin Young --- tests/topotests/lib/pim.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/topotests/lib/pim.py b/tests/topotests/lib/pim.py index 970367a882..265449df21 100644 --- a/tests/topotests/lib/pim.py +++ b/tests/topotests/lib/pim.py @@ -1400,14 +1400,10 @@ def verify_pim_state( errormsg = ( "[DUT %s]: Verifying pim state for group" " %s, [FAILED]!! Expected: " - "(iif: %s, oil: %s, installed: %s) ", + "(iif: %s, oil: %s, installed: %s) " + % (dut, grp_addr, iif, oil, "1"), "Found: (iif: %s, oil: %s, installed: %s)" % ( - dut, - grp_addr, - iif, - oil, - "1", data["inboundInterface"], data["outboundInterface"], data["installed"], @@ -2688,7 +2684,7 @@ def verify_igmp_config(tgen, input_dict, stats_return=False): if statistics and report: show_ip_igmp_intf_json = run_frr_cmd( - rnode, "{} json".format(cmd, interface), isjson=True + rnode, "{} json".format(cmd), isjson=True ) intf_detail_json = show_ip_igmp_intf_json["global"] else: @@ -2764,7 +2760,6 @@ def verify_igmp_config(tgen, input_dict, stats_return=False): dut, interface, value, - intf_detail_json["reportV2"], ) ) return errormsg From 660c59ed6fb276336dbdd6958387342c79147930 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 23 Mar 2021 22:53:01 +0000 Subject: [PATCH 4/4] tests: fix use of undefined variable in pim lib Signed-off-by: Quentin Young --- tests/topotests/lib/pim.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/topotests/lib/pim.py b/tests/topotests/lib/pim.py index 265449df21..61a5705a5d 100644 --- a/tests/topotests/lib/pim.py +++ b/tests/topotests/lib/pim.py @@ -2377,8 +2377,7 @@ def verify_ip_pim_upstream_rpf(tgen, topo, dut, interface, group_addresses, rp=N if rp is None: rp_details = find_rp_details(tgen, topo) else: - rp_details = {dut: ip} - rp_details[dut] = rp + rp_details = {dut: rp} if dut in rp_details: pim_nh_intf_ip = topo["routers"][dut]["links"]["lo"]["ipv4"].split(