Skip to content

[test/reboot] Replace clock-based reboot assertion with /proc/uptime check (#26591) - #1411

Merged
bingwang-ms merged 1 commit into
202512from
cherry-pick-26591-202512
Sep 11, 2026
Merged

bingwang-ms merged 1 commit into
202512from
cherry-pick-26591-202512

Conversation

@bingwang-ms

Copy link
Copy Markdown
Contributor

Description of PR

Summary:
Cherry-pick of sonic-net/sonic-mgmt#26591 to Azure/sonic-mgmt.msft:202512.

Replace the clock-based reboot assertion in tests/common/reboot.py with a /proc/uptime check. The old logic compared absolute timestamps across a reboot boundary and failed on platforms with RTC drift when NTP didn't sync within 120s. The new check is monotonic and immune to clock issues.

Fixes # (issue)

Type of change

  • Bug fix

Back port request

  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202512

Approach

What is the motivation for this PR?

RTC drift causes false "Device did not reboot" assertion on platforms where NTP doesn't sync within 120s of SSH availability.

How did you do it?

Cherry-picked sonic-net/sonic-mgmt#26591 (squash-merge commit 5a5e161), resolving conflicts caused by this branch not yet having the reboot_started_event/gNOI-smartswitch-signature feature from a separate, unrelated upstream commit. Kept this branch's existing reboot_smartswitch(duthost, pool, reboot_type) signature and perform_reboot invocation_type handling, while applying the core fix: replacing the wall-clock (get_now_time/get_up_time comparison) reboot assertion with a monotonic /proc/uptime-based check (reboot_start_time = time.monotonic() captured before reboot, compared against duthost.get_uptime() with a REBOOT_UPTIME_GRACE_SECONDS grace margin), and removing the now-unused positive_uptime helper. Also dropped the unrelated tests/ha/test_ha_npu_reboot.py change since that file does not exist on this branch.

How did you verify/test it?

Verified the resolved file has no leftover conflict markers, passes python3 -m py_compile / AST parse, and passes flake8 --max-line-length=120 (only pre-existing, unrelated warnings remain).

Any platform specific information?

Generic — affects any testbed running with RTC drift or slow NTP sync after boot.

Supported testbed topology if it's a new test case?

N/A — existing test case, topology unchanged.

Documentation

N/A

…check (#26591)

Replace the clock-based reboot assertion in `tests/common/reboot.py`
with a `/proc/uptime` check. The old logic compared absolute timestamps
across a reboot boundary and failed on platforms with RTC drift when NTP
didn't sync within 120s. The new check is monotonic and immune to clock
issues.

Observed failure: `test_cold_reboot[gnoi_based-]` device rebooted (tmpfs
file gone) but clock assertion fired due to 3.5min RTC drift.

- [x] Bug fix

- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505
- [x] 202511
- [ ] 202512
- [ ] 202605

- [x] master

- master: `test_cold_reboot[gnoi_based]` now passes `/proc/uptime` shows
~180s after reboot, well under the 420s threshold.

RTC drift causes false "Device did not reboot" assertion on platforms
where NTP doesn't sync within 120s of SSH availability.

Read `/proc/uptime` after reboot. A freshly-rebooted device must have
uptime < `timeout + wait`. This is independent of wall-clock accuracy.

Confirmed `/proc/uptime` reads ~180s on the affected DUT post-reboot.
All other reboot tests (cli_based, watchdog, continuous) unaffected.

Observed on Arista 7060X6 with ~3.5min RTC drift. Applies to any
platform with slow NTP sync after boot.

---------

Signed-off-by: Priyansh Tratiya <ptratiya@microsoft.com>
(cherry picked from commit 5a5e161)
Signed-off-by: bingwang <bingwang@microsoft.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.

@bingwang-ms
bingwang-ms merged commit 50f3bc9 into 202512 Sep 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants