Skip to content

Conversation

@sairon
Copy link
Member

@sairon sairon commented Jun 19, 2025

Add test that OS update works - use the whole stack using CLI to update to the latest stable version (unless executed manually on the latest stable release, this version should never be the same as the currently tested one).

With this test in place, we can also test command for switching the slots, so add an extra test for that too.

Fixes #4103

Summary by CodeRabbit

  • Tests
    • Introduced new automated tests to verify OS update functionality, including initial system readiness checks, OS update to the latest stable version, and boot slot switching validation.

Add test that OS update works - use the whole stack using CLI to update to the
latest stable version (unless executed manually on the latest stable release,
this version should never be the same as the currently tested one).

With this test in place, we can also test command for switching the slots, so
add an extra test for that too.

Fixes #4103
@sairon sairon requested a review from agners June 19, 2025 15:03
@sairon sairon added the build Build and CI related issues label Jun 19, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 19, 2025

📝 Walkthrough

Walkthrough

A new smoke test suite for OS update functionality has been added using pytest. The suite includes tests for system initialization, performing an OS update to the latest stable version, and switching the boot slot. The tests use shell commands, handle reboots, and verify system states and versions through JSON parsing and retries.

Changes

File(s) Change Summary
tests/smoke_test/test_os_update.py Added new pytest-based smoke test suite for OS update, including tests for init, update, and boot slot switching.

Sequence Diagram(s)

sequenceDiagram
    participant Tester
    participant Shell
    participant System
    participant RemoteServer

    Tester->>Shell: Wait for containers (homeassistant, hassio_supervisor)
    Shell->>System: Query container status
    Shell->>System: Query system status (ready, supervisor version)
    Tester->>RemoteServer: Fetch latest OS version (JSON)
    Tester->>Shell: Run OS update command to target version
    Shell->>System: Perform OS update
    System-->>Shell: Reboot
    Shell->>System: Wait for readiness after reboot
    Tester->>Shell: Switch boot slot
    Shell->>System: Switch slot and reboot
    Shell->>System: Wait for readiness and verify slot version
Loading

Assessment against linked issues

Objective Addressed Explanation
Add CI test for rauc updates (#4103)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were found.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (5)
tests/smoke_test/test_os_update.py (5)

6-6: Remove unused import.

The ExecutionError import is never used in the code.

-from labgrid.driver import ExecutionError

8-8: Consider removing unused logger.

The logger is defined but never used throughout the test file. Consider removing it or adding appropriate logging statements for better test observability.


31-31: Improve JSON parsing robustness.

The JSON parsing could be more robust. Consider using a try-catch block for better error handling.

-        supervisor_info = json.loads(supervisor_info) if supervisor_info.startswith("{") else None
+        try:
+            supervisor_info = json.loads(supervisor_info) if supervisor_info.startswith("{") else None
+        except json.JSONDecodeError:
+            supervisor_info = None

87-87: Remove unnecessary f-string prefix.

The f-string has no placeholders, so the f prefix is unnecessary.

-    shell.run_check(f"ha os boot-slot other --no-progress || true")
+    shell.run_check("ha os boot-slot other --no-progress || true")

44-78: Consider adding logging for better test observability.

Since this is a smoke test that involves system updates and reboots, adding logging statements would help with debugging test failures and understanding test progress.

 def test_os_update(shell, shell_json, target):
+    _LOGGER.info("Starting OS update test")
     # fetch version info and OTA URL
     shell.run_check("ha su reload --no-progress")
 
     # update OS to latest stable - in tests it should never be the same version
     stable_version = shell_json("curl -sSL https://version.home-assistant.io/stable.json")["hassos"]["ova"]
+    _LOGGER.info(f"Target stable version: {stable_version}")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 5e36e68 and 1d6d5ae.

📒 Files selected for processing (1)
  • tests/smoke_test/test_os_update.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.11.9)
tests/smoke_test/test_os_update.py

6-6: labgrid.driver.ExecutionError imported but unused

Remove unused import: labgrid.driver.ExecutionError

(F401)


87-87: f-string without any placeholders

Remove extraneous f prefix

(F541)

Copy link
Member

@agners agners left a comment

Choose a reason for hiding this comment

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

LGTM, nice!

while True:
output = "\n".join(shell.run_check(f"ha os update --no-progress --version {stable_version} || true", timeout=120))
if "Don't have an URL for OTA updates" in output:
shell.run_check("ha su reload --no-progress")
Copy link
Member

Choose a reason for hiding this comment

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

There is the /reload_updates API endpoint nowadays which is a bit more lightweight. But I think we have no CLI for that 😢

@sairon sairon merged commit 90d3614 into dev Jun 20, 2025
3 checks passed
@sairon sairon deleted the add-os-update-test branch June 20, 2025 08:20
sairon added a commit that referenced this pull request Jun 26, 2025
Add test that OS update works - use the whole stack using CLI to update to the
latest stable version (unless executed manually on the latest stable release,
this version should never be the same as the currently tested one).

With this test in place, we can also test command for switching the slots, so
add an extra test for that too.

Fixes #4103

(cherry picked from commit 90d3614)
@sairon sairon mentioned this pull request Jun 26, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jun 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

build Build and CI related issues cla-signed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CI test for rauc updates

3 participants