Skip to content

Adapt OS update test to Supervisor no longer auto-rebooting - #4906

Merged
agners merged 3 commits into
devfrom
fix/os-update-test-no-auto-reboot
Jul 18, 2026
Merged

agners merged 3 commits into
devfrom
fix/os-update-test-no-auto-reboot

Conversation

@agners

@agners agners commented Jul 18, 2026 •

Copy link
Copy Markdown
Member

The problem

The QEMU test job fails on the dev builds. Besides the offline test (see #4905), test_os_update fails: ha os update returns Command completed successfully but the test times out waiting for Booting \Slot โ€” and that cascades intotest_supervisor` (setup can't reach a shell).

Root cause

Since home-assistant/supervisor#6982 (merged 2026-06-30, an intentional breaking change) a successful /os/update no longer reboots the host automatically. Instead the Supervisor:

and leaves the reboot to the user. test_os_update still assumed the old "update โ†’ immediate reboot" behavior.

Timeline confirms it: the last green run (Jun 29) ran against a 2026.06 Supervisor (still auto-rebooted); the Jul 7 / Jul 10 failures ran against 2026.07 Supervisor (post-#6982). Since tests always pull the latest Supervisor, the test is what must adapt.

Reproduced and captured from the Supervisor log:

[supervisor.os.manager] Install of Home Assistant Operating System 18.1 success; reboot required
[supervisor.resolution.module] Create new suggestion execute_reboot - system / None
[supervisor.resolution.module] Create new issue reboot_required - system / None

No auto-reboot within 150s; version_pending: 18.1 persists.

The fix

Adapt test_os_update to the new flow:

  • run ha os update and wait until the update is installed as pending (version_pending == target), retrying only while the OTA URL isn't available yet (right after boot);
  • apply the pending update with ha host reboot and wait for the new slot to boot;
  • assert the new version is running and nothing is pending anymore.

Verification

Driven end-to-end in QEMU against the current dev image + latest Supervisor:

install update to 18.1  -> version_pending=18.1, booted_slot=A   (no reboot)
ha host reboot          -> Booting `Slot ' detected
AFTER REBOOT: version=18.1  version_pending=None  boot=B  A=18.2.dev  B=18.1
RESULT: PASS

Together with #4905 (offline ping fix) this should restore the QEMU test job.

Summary by CodeRabbit

  • Tests
    • Updated the OS update smoke test to align with the latest Supervisor OS update behavior.
    • Triggers the update and polls until the โ€œupdate pendingโ€ state reflects the target version.
    • Refreshes Supervisor state and retries while the pending version hasnโ€™t appeared.
    • Reboots, confirms the running OS matches the target version, and verifies no OS update remains pending.

Since Supervisor 2026.07 (home-assistant/supervisor#6982) a successful
/os/update no longer reboots the host automatically. It installs the
bundle to the other slot, marks it as the pending boot slot (exposed as
"version_pending", see home-assistant/supervisor#7006) and raises a
reboot-required repair issue, leaving the actual reboot to the user.

test_os_update still waited for an immediate "Booting `Slot " right after
`ha os update`, so when run against a 2026.07+ Supervisor it timed out and
failed (cascading into test_supervisor). This is why the QEMU test job
started failing on the dev builds built after 2026-06-30.

Adapt the test to the new flow:
- run `ha os update` and wait until the update is installed as pending
  (version_pending == target), retrying only while the OTA URL is not
  available yet; re-requesting an already-installed version is rejected.
- apply the pending update with `ha host reboot` and wait for the new
  slot to boot.
- assert the new version is running and nothing is pending anymore.

Verified end-to-end in QEMU against the current dev image with the latest
Supervisor: the update stages to slot B (version_pending=18.1, still
booted on A), `ha host reboot` boots slot B, and afterwards version=18.1
with version_pending cleared.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. ๐ŸŽ‰

โ„น๏ธ Recent review info
โš™๏ธ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 413185db-ac60-41be-842d-63dda97cb9da

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 2d95639 and 027c4e4.

๐Ÿ“’ Files selected for processing (1)
  • tests/smoke_test/test_os_update.py
๐Ÿšง Files skipped from review as they are similar to previous changes (1)
  • tests/smoke_test/test_os_update.py

๐Ÿ“ Walkthrough

Walkthrough

The OS update smoke test polls until Supervisor reports the target version as pending, reloads Supervisor when necessary, reboots to activate the update, and verifies both the running version and cleared pending state.

Changes

OS update validation

Layer / File(s) Summary
Poll, activate, and validate OS update
tests/smoke_test/test_os_update.py
The test waits for version_pending to match the target, reloads Supervisor and retries when needed, reboots into the updated slot, then validates the active version and absence of a pending update.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A bunny checks the pending byte,
Refreshes Supervisor through the night.
Then hops through rebootโ€™s glowing gate,
Finds the new slot awake and great.
No pending crumbs remain in sight!

๐Ÿšฅ Pre-merge checks | โœ… 5
โœ… Passed checks (5 passed)
Check name Status Explanation
Description Check โœ… Passed Check skipped - CodeRabbitโ€™s high-level summary is enabled.
Title check โœ… Passed The title clearly matches the main change: updating the OS update test for Supervisor behavior where reboot is no longer automatic.
Docstring Coverage โœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check โœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check โœ… Passed Check skipped because no linked issues were found for this pull request.
โœจ Finishing Touches
๐Ÿ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
๐Ÿงช Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/os-update-test-no-auto-reboot

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

๐Ÿค– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/smoke_test/test_os_update.py`:
- Around line 62-69: Update the polling loop around shell_json to use a bounded
iteration count, preventing indefinite hangs when the update never reaches
stable_version. Make the os info command tolerate transient CLI failures like
the existing defensive handling earlier in the test, and parse its output safely
so failed or incomplete responses trigger the existing reload-and-retry path
rather than crashing. Preserve the successful version_pending check and retry
behavior.
๐Ÿช„ Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

โ„น๏ธ Review info
โš™๏ธ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5713ba06-1ce7-4dcc-8e97-8df8da1c58aa

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 7c1099f and cc56368.

๐Ÿ“’ Files selected for processing (1)
  • tests/smoke_test/test_os_update.py

Comment thread tests/smoke_test/test_os_update.py Resolved

Copilot AI left a comment

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.

Pull request overview

Updates the QEMU smoke test for OS updates to match the new Supervisor behavior where /os/update installs to the other slot and marks it pending, but does not automatically reboot.

Changes:

  • Waits for the target version to appear as version_pending after ha os update.
  • Explicitly reboots the host (ha host reboot) to apply the pending slot.
  • Verifies the target version is running and that no update remains pending after reboot.

๐Ÿ’ก Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/smoke_test/test_os_update.py Resolved
Comment thread tests/smoke_test/test_os_update.py Resolved
- Bound the retry loop and fail with the last `ha os update` output instead
  of relying on the global test timeout when the update never installs.
- Tolerate a transient `ha os info` CLI failure (|| true + defensive JSON
  parse), matching the pattern already used in test_init.
- Use dict.get() for the post-reboot version_pending assertion.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

tests/smoke_test/test_os_update.py:65

  • This retry loop can exceed the test-level timeout (600s): shell.run_check(..., timeout=300) inside range(10) allows up to 3000s blocked time before even reaching the reboot/ready waits. Consider doing one long attempt and then only short retries (or fewer attempts) so the overall upper bound stays within the test timeout budget.
    for _ in range(10):
        update_output = "\n".join(
            shell.run_check(f"ha os update --no-progress --version {stable_version} || true", timeout=300)
        )

Comment thread tests/smoke_test/test_os_update.py Resolved
- `ha os info --raw-json` returns "data": null on an error result; coerce it
  to an empty dict so the version_pending lookup can't raise AttributeError.
- Lower the per-attempt timeout to 120s and the retry count to 4 so the
  loop's worst case stays within the test's 600s timeout budget.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@agners
agners merged commit 777638a into dev Jul 18, 2026
1 check passed
@agners
agners deleted the fix/os-update-test-no-auto-reboot branch July 18, 2026 18:05
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 26, 2026
@agners agners added the os label Jul 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants