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) diff --git a/tests/common/plugins/sanity_check/__init__.py b/tests/common/plugins/sanity_check/__init__.py index b62be4ad7bc..b041c6ce819 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,15 @@ 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 + if ptfhost.mgmt_ip: + cmds.append("ping {} -c 1 -W 3".format(ptfhost.mgmt_ip)) + cmds.append("traceroute {}".format(ptfhost.mgmt_ip)) + + if 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 = [] for res in results: @@ -285,7 +294,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" %