Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/common/reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,27 @@ def reboot(duthost, localhost, reboot_type='cold', delay=10,
pool.terminate()
dut_uptime = duthost.get_up_time(utc_timezone=True)
logger.info('DUT {} up since {}'.format(hostname, dut_uptime))
# some device does not have onchip clock and requires obtaining system time a little later from ntp
# or SUP to obtain the correct time so if the uptime is less than original device time, it means it
# is most likely due to this issue which we can wait a little more until the correct time is set in place.
if float(dut_uptime.strftime("%s")) < float(dut_datetime.strftime("%s")):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it be always be the case that the time drifted backwards and not ahead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly! that is why this change is needed. in most platforms that has on board clock chip, there should be time difference that is "positive". For platform that does not have clock chip and rely on time sync and "slow" we will always hit this check and causes the testcase to failed prematurely...

logger.info('DUT {} timestamp went backwards'.format(hostname))
wait_until(120, 5, 0, positive_uptime, duthost, dut_datetime)

dut_uptime = duthost.get_up_time()

assert float(dut_uptime.strftime("%s")) > float(dut_datetime.strftime("%s")), "Device {} did not reboot". \
format(hostname)


def positive_uptime(duthost, dut_datetime):
dut_uptime = duthost.get_up_time()
if float(dut_uptime.strftime("%s")) < float(dut_datetime.strftime("%s")):
return False

return True


def get_reboot_cause(dut):
"""
@summary: get the reboot cause on DUT.
Expand Down
5 changes: 4 additions & 1 deletion tests/platform_tests/test_reload_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ def test_reload_configuration_checks(duthosts, enum_rand_one_per_hwsku_hostname,
plt_reboot_ctrl_overwrite=False)

# Check if all database containers have started
wait_until(60, 1, 0, check_database_status, duthost)
# Some device after reboot may take some longer time to have database container started up
# we must give it a little longer or else it may falsely fail the test.
wait_until(360, 1, 0, check_database_status, duthost)

# Check if interfaces-config.service is exited
wait_until(60, 1, 0, check_interfaces_config_service_status, duthost)

Expand Down