@@ -271,6 +271,10 @@ def reboot(duthost, localhost, reboot_type='cold', delay=10,
271271 # Create a temporary file in tmpfs before reboot
272272 logger .info ('DUT {} create a file /dev/shm/test_reboot before rebooting' .format (hostname ))
273273 duthost .command ('sudo touch /dev/shm/test_reboot' )
274+ # Get reboot-cause history before reboot
275+ prev_reboot_cause_history = duthost .show_and_parse ("show reboot-cause history" )
276+ reboot_res , dut_datetime = perform_reboot (duthost , pool , reboot_command , reboot_helper , reboot_kwargs , reboot_type )
277+
274278 wait_conlsole_connection = 5
275279 console_thread_res = pool .apply_async (
276280 collect_console_log , args = (duthost , localhost , timeout + wait_conlsole_connection ))
@@ -332,14 +336,20 @@ def reboot(duthost, localhost, reboot_type='cold', delay=10,
332336 # some device does not have onchip clock and requires obtaining system time a little later from ntp
333337 # or SUP to obtain the correct time so if the uptime is less than original device time, it means it
334338 # is most likely due to this issue which we can wait a little more until the correct time is set in place.
335- if float (dut_uptime .strftime ("%s" )) < float (dut_datetime .strftime ("%s" )):
336- logger .info ('DUT {} timestamp went backwards' .format (hostname ))
337- wait_until (120 , 5 , 0 , positive_uptime , duthost , dut_datetime )
338339
339- dut_uptime = duthost .get_up_time ()
340+ # Use an alternative reboot check if T2 device and REBOOT_TYPE_POWEROFF
341+ if duthost .get_facts ().get ("modular_chassis" ) and reboot_type == REBOOT_TYPE_POWEROFF :
342+ curr_reboot_cause_history = duthost .show_and_parse ("show reboot-cause history" )
343+ pytest_assert (prev_reboot_cause_history != curr_reboot_cause_history , "No new input into history-queue" )
344+ else :
345+ if float (dut_uptime .strftime ("%s" )) < float (dut_datetime .strftime ("%s" )):
346+ logger .info ('DUT {} timestamp went backwards' .format (hostname ))
347+ wait_until (120 , 5 , 0 , positive_uptime , duthost , dut_datetime )
348+
349+ dut_uptime = duthost .get_up_time ()
340350
341- assert float (dut_uptime .strftime ("%s" )) > float (dut_datetime .strftime ("%s" )), "Device {} did not reboot" . \
342- format (hostname )
351+ assert float (dut_uptime .strftime ("%s" )) > float (dut_datetime .strftime ("%s" )), "Device {} did not reboot" . \
352+ format (hostname )
343353
344354
345355def positive_uptime (duthost , dut_datetime ):
0 commit comments