From 6730b245b9530a4d94d4775bf0cedfc6d7e21a58 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Fri, 10 Jan 2025 14:47:53 +0800 Subject: [PATCH 1/6] Update __init__.py --- tests/common/plugins/sanity_check/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/common/plugins/sanity_check/__init__.py b/tests/common/plugins/sanity_check/__init__.py index b62be4ad7bc..0fcbc21f995 100644 --- a/tests/common/plugins/sanity_check/__init__.py +++ b/tests/common/plugins/sanity_check/__init__.py @@ -80,7 +80,7 @@ def _update_check_items(old_items, new_items, supported_items): return updated_items -def print_logs(duthosts, print_dual_tor_logs=False): +def print_logs(duthosts, ptfhost, print_dual_tor_logs=False): for dut in duthosts: logger.info("Run commands to print logs") @@ -90,6 +90,9 @@ def print_logs(duthosts, print_dual_tor_logs=False): cmds.remove(constants.PRINT_LOGS['mux_status']) cmds.remove(constants.PRINT_LOGS['mux_config']) + # check PTF device reachability + cmds.add("ping {} -c 1 -W 3".format(ptfhost.mgmt_ip)) + results = dut.shell_cmds(cmds=cmds, module_ignore_errors=True, verbose=False)['results'] outputs = [] for res in results: @@ -285,7 +288,7 @@ def sanity_check_full(ptfhost, prepare_parallel_run, localhost, duthosts, reques for item in set(pre_check_items): request.fixturenames.append(item) dual_tor = 'dualtor' in tbinfo['topo']['name'] - print_logs(duthosts, print_dual_tor_logs=dual_tor) + print_logs(duthosts, ptfhost, print_dual_tor_logs=dual_tor) check_results = do_checks(request, pre_check_items, stage=STAGE_PRE_TEST) logger.debug("Pre-test sanity check results:\n%s" % From 50ead3f4ba22dbb9600871e33139c25698d985a8 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Fri, 10 Jan 2025 14:52:12 +0800 Subject: [PATCH 2/6] Add traceroute command to sanity check --- tests/common/plugins/sanity_check/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/common/plugins/sanity_check/__init__.py b/tests/common/plugins/sanity_check/__init__.py index 0fcbc21f995..b617506ad45 100644 --- a/tests/common/plugins/sanity_check/__init__.py +++ b/tests/common/plugins/sanity_check/__init__.py @@ -92,6 +92,7 @@ def print_logs(duthosts, ptfhost, print_dual_tor_logs=False): # check PTF device reachability cmds.add("ping {} -c 1 -W 3".format(ptfhost.mgmt_ip)) + cmds.add("traceroute {}".format(ptfhost.mgmt_ip)) results = dut.shell_cmds(cmds=cmds, module_ignore_errors=True, verbose=False)['results'] outputs = [] From 9162c5959e7eec67bc1aa8170ec510cf453382af Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:21:54 +0800 Subject: [PATCH 3/6] Replace `add` with `append` for commands --- tests/common/plugins/sanity_check/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/common/plugins/sanity_check/__init__.py b/tests/common/plugins/sanity_check/__init__.py index b617506ad45..d24d8c1c046 100644 --- a/tests/common/plugins/sanity_check/__init__.py +++ b/tests/common/plugins/sanity_check/__init__.py @@ -91,8 +91,8 @@ def print_logs(duthosts, ptfhost, print_dual_tor_logs=False): cmds.remove(constants.PRINT_LOGS['mux_config']) # check PTF device reachability - cmds.add("ping {} -c 1 -W 3".format(ptfhost.mgmt_ip)) - cmds.add("traceroute {}".format(ptfhost.mgmt_ip)) + cmds.append("ping {} -c 1 -W 3".format(ptfhost.mgmt_ip)) + cmds.append("traceroute {}".format(ptfhost.mgmt_ip)) results = dut.shell_cmds(cmds=cmds, module_ignore_errors=True, verbose=False)['results'] outputs = [] From 35b7c13448e15bc79ca790156b7b94306c88078f Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Fri, 10 Jan 2025 17:36:32 +0800 Subject: [PATCH 4/6] Update data_plane_utils.py --- tests/common/dualtor/data_plane_utils.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/common/dualtor/data_plane_utils.py b/tests/common/dualtor/data_plane_utils.py index 1f7b00371b4..145282aecfd 100644 --- a/tests/common/dualtor/data_plane_utils.py +++ b/tests/common/dualtor/data_plane_utils.py @@ -207,8 +207,8 @@ def run_test( return tor_IO -def cleanup(ptfadapter, duthosts_list): - print_logs(duthosts_list, print_dual_tor_logs=True) +def cleanup(ptfadapter, duthosts_list, ptfhost): + print_logs(duthosts_list, ptfhost, print_dual_tor_logs=True) # cleanup torIO ptfadapter.dataplane.flush() for duthost in duthosts_list: @@ -303,7 +303,7 @@ def t1_to_server_io_test(activehost, tor_vlan_port=None, yield t1_to_server_io_test - cleanup(ptfadapter, duthosts) + cleanup(ptfadapter, duthosts, ptfhost) @pytest.fixture @@ -373,7 +373,7 @@ def server_to_t1_io_test(activehost, tor_vlan_port=None, yield server_to_t1_io_test - cleanup(ptfadapter, duthosts) + cleanup(ptfadapter, duthosts, ptfhost) @pytest.fixture @@ -402,7 +402,7 @@ def soc_to_t1_io_test(activehost, tor_vlan_port=None, yield soc_to_t1_io_test - cleanup(ptfadapter, duthosts) + cleanup(ptfadapter, duthosts, ptfhost) @pytest.fixture @@ -433,7 +433,7 @@ def t1_to_soc_io_test(activehost, tor_vlan_port=None, yield t1_to_soc_io_test - cleanup(ptfadapter, duthosts) + cleanup(ptfadapter, duthosts, ptfhost) @pytest.fixture @@ -479,4 +479,4 @@ def server_to_server_io_test(activehost, test_mux_ports, delay=0, yield server_to_server_io_test - cleanup(ptfadapter, duthosts) + cleanup(ptfadapter, duthosts, ptfhost) From 5611c15f19605c553ce838a18c9619424b4b5337 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Wed, 15 Jan 2025 10:49:29 +0800 Subject: [PATCH 5/6] Add IPv6 reachability checks for PTF device --- tests/common/plugins/sanity_check/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/common/plugins/sanity_check/__init__.py b/tests/common/plugins/sanity_check/__init__.py index d24d8c1c046..f83427f5b4c 100644 --- a/tests/common/plugins/sanity_check/__init__.py +++ b/tests/common/plugins/sanity_check/__init__.py @@ -91,8 +91,13 @@ def print_logs(duthosts, ptfhost, print_dual_tor_logs=False): cmds.remove(constants.PRINT_LOGS['mux_config']) # check PTF device reachability - cmds.append("ping {} -c 1 -W 3".format(ptfhost.mgmt_ip)) - cmds.append("traceroute {}".format(ptfhost.mgmt_ip)) + if not ptfhost.mgmt_ip: + cmds.append("ping {} -c 1 -W 3".format(ptfhost.mgmt_ip)) + cmds.append("traceroute {}".format(ptfhost.mgmt_ip)) + + if not ptfhost.mgmt_ipv6: + cmds.append("ping6 {} -c 1 -W 3".format(ptfhost.mgmt_ipv6)) + cmds.append("traceroute6 {}".format(ptfhost.mgmt_ipv6)) results = dut.shell_cmds(cmds=cmds, module_ignore_errors=True, verbose=False)['results'] outputs = [] From c0e44034c144076d88a8524113cfa34c2eabe35a Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Wed, 15 Jan 2025 19:30:04 +0800 Subject: [PATCH 6/6] Fix PTF device reachability check logic --- tests/common/plugins/sanity_check/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/common/plugins/sanity_check/__init__.py b/tests/common/plugins/sanity_check/__init__.py index f83427f5b4c..b041c6ce819 100644 --- a/tests/common/plugins/sanity_check/__init__.py +++ b/tests/common/plugins/sanity_check/__init__.py @@ -91,11 +91,11 @@ def print_logs(duthosts, ptfhost, print_dual_tor_logs=False): cmds.remove(constants.PRINT_LOGS['mux_config']) # check PTF device reachability - if not ptfhost.mgmt_ip: + if ptfhost.mgmt_ip: cmds.append("ping {} -c 1 -W 3".format(ptfhost.mgmt_ip)) cmds.append("traceroute {}".format(ptfhost.mgmt_ip)) - if not ptfhost.mgmt_ipv6: + if ptfhost.mgmt_ipv6: cmds.append("ping6 {} -c 1 -W 3".format(ptfhost.mgmt_ipv6)) cmds.append("traceroute6 {}".format(ptfhost.mgmt_ipv6))