Skip to content

Commit 2b19383

Browse files
authored
Add sanity check command to debug PTF unreachable issue (#16444)
Add sanity check command to debug PTF unreachable issue. Why I did it TACACS test case failed because PTF device unreachable, need more info to debug.
1 parent fff1abd commit 2b19383

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

tests/common/dualtor/data_plane_utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ def run_test(
207207
return tor_IO
208208

209209

210-
def cleanup(ptfadapter, duthosts_list):
211-
print_logs(duthosts_list, print_dual_tor_logs=True)
210+
def cleanup(ptfadapter, duthosts_list, ptfhost):
211+
print_logs(duthosts_list, ptfhost, print_dual_tor_logs=True)
212212
# cleanup torIO
213213
ptfadapter.dataplane.flush()
214214
for duthost in duthosts_list:
@@ -303,7 +303,7 @@ def t1_to_server_io_test(activehost, tor_vlan_port=None,
303303

304304
yield t1_to_server_io_test
305305

306-
cleanup(ptfadapter, duthosts)
306+
cleanup(ptfadapter, duthosts, ptfhost)
307307

308308

309309
@pytest.fixture
@@ -373,7 +373,7 @@ def server_to_t1_io_test(activehost, tor_vlan_port=None,
373373

374374
yield server_to_t1_io_test
375375

376-
cleanup(ptfadapter, duthosts)
376+
cleanup(ptfadapter, duthosts, ptfhost)
377377

378378

379379
@pytest.fixture
@@ -402,7 +402,7 @@ def soc_to_t1_io_test(activehost, tor_vlan_port=None,
402402

403403
yield soc_to_t1_io_test
404404

405-
cleanup(ptfadapter, duthosts)
405+
cleanup(ptfadapter, duthosts, ptfhost)
406406

407407

408408
@pytest.fixture
@@ -433,7 +433,7 @@ def t1_to_soc_io_test(activehost, tor_vlan_port=None,
433433

434434
yield t1_to_soc_io_test
435435

436-
cleanup(ptfadapter, duthosts)
436+
cleanup(ptfadapter, duthosts, ptfhost)
437437

438438

439439
@pytest.fixture
@@ -479,4 +479,4 @@ def server_to_server_io_test(activehost, test_mux_ports, delay=0,
479479

480480
yield server_to_server_io_test
481481

482-
cleanup(ptfadapter, duthosts)
482+
cleanup(ptfadapter, duthosts, ptfhost)

tests/common/plugins/sanity_check/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _update_check_items(old_items, new_items, supported_items):
8080
return updated_items
8181

8282

83-
def print_logs(duthosts, print_dual_tor_logs=False):
83+
def print_logs(duthosts, ptfhost, print_dual_tor_logs=False):
8484
for dut in duthosts:
8585
logger.info("Run commands to print logs")
8686

@@ -90,6 +90,15 @@ def print_logs(duthosts, print_dual_tor_logs=False):
9090
cmds.remove(constants.PRINT_LOGS['mux_status'])
9191
cmds.remove(constants.PRINT_LOGS['mux_config'])
9292

93+
# check PTF device reachability
94+
if ptfhost.mgmt_ip:
95+
cmds.append("ping {} -c 1 -W 3".format(ptfhost.mgmt_ip))
96+
cmds.append("traceroute {}".format(ptfhost.mgmt_ip))
97+
98+
if ptfhost.mgmt_ipv6:
99+
cmds.append("ping6 {} -c 1 -W 3".format(ptfhost.mgmt_ipv6))
100+
cmds.append("traceroute6 {}".format(ptfhost.mgmt_ipv6))
101+
93102
results = dut.shell_cmds(cmds=cmds, module_ignore_errors=True, verbose=False)['results']
94103
outputs = []
95104
for res in results:
@@ -285,7 +294,7 @@ def sanity_check_full(ptfhost, prepare_parallel_run, localhost, duthosts, reques
285294
for item in set(pre_check_items):
286295
request.fixturenames.append(item)
287296
dual_tor = 'dualtor' in tbinfo['topo']['name']
288-
print_logs(duthosts, print_dual_tor_logs=dual_tor)
297+
print_logs(duthosts, ptfhost, print_dual_tor_logs=dual_tor)
289298

290299
check_results = do_checks(request, pre_check_items, stage=STAGE_PRE_TEST)
291300
logger.debug("Pre-test sanity check results:\n%s" %

0 commit comments

Comments
 (0)