Skip to content

Add tests for checking connectivity, fix Supervisor update test#4008

Merged
sairon merged 1 commit into
devfrom
add-connectivity-tests
Apr 7, 2025
Merged

Add tests for checking connectivity, fix Supervisor update test#4008
sairon merged 1 commit into
devfrom
add-connectivity-tests

Conversation

@sairon
Copy link
Copy Markdown
Member

@sairon sairon commented Apr 7, 2025

When there's a problem with connectivity, it may result in obscure errors later in the testing. Add checks testing three scenarions:

  • connectivity in host - both using curl and nmcli
  • connectivity in Supervisor container (uses docker0 as default via)
  • connectivity in CLI container (uses hassio as default via)

Also make sure that Supervisor upgrade isn't attempted when the version information is missing.

Summary by CodeRabbit

  • Tests
    • Added connectivity tests to verify system operations across host and container environments.
    • Enhanced supervisor version validation to ensure reliable update and status checks.

When there's a problem with connectivity, it may result in obscure errors later
in the testing. Add checks testing three scenarions:

* connectivity in host - both using curl and nmcli
* connectivity in Supervisor container (uses docker0 as default via)
* connectivity in CLI container (uses hassio as default via)

Also make sure that Supervisor upgrade isn't attempted when the version
information is missing.
@sairon sairon added the build Build and CI related issues label Apr 7, 2025
@sairon sairon requested a review from agners April 7, 2025 13:58
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 7, 2025

📝 Walkthrough

Walkthrough

The changes introduce three new connectivity test functions in the smoke test suite and enhance the supervisor version test. The new tests check host, supervisor, and Hass.io container connectivity using curl commands and nmcli. The supervisor test now retrieves the latest version information into a variable, asserts its presence, and conditionally skips the test if the supervisor is up to date.

Changes

File(s) Change Summary
tests/.../test_basic.py Added three new test functions: test_host_connectivity, test_supervisor_connectivity, and test_hassio_connectivity. These functions execute curl commands and nmcli checks to verify network connectivity for the host and Docker containers.
tests/.../test_supervisor.py Modified test_update_supervisor: introduced a new variable (supervisor_version_latest), added an assertion to verify its presence, and adjusted the conditional logic to skip the test if the version is current.

Sequence Diagram(s)

sequenceDiagram
    participant Runner as Test Runner
    participant Shell as Command Executor
    Runner->>Shell: Execute `curl` for host connectivity
    Shell-->>Runner: Return connectivity response
    Runner->>Shell: Run `nmcli` for connectivity check
    Shell-->>Runner: Return full connectivity status
Loading
sequenceDiagram
    participant Runner as Test Runner
    participant Supervisor as Supervisor Service
    Runner->>Supervisor: Retrieve latest supervisor version (supervisor_version_latest)
    Supervisor-->>Runner: Return version info
    alt Missing version info
        Runner->>Runner: Assert failure ("Latest supervisor version info missing")
    else Version info present
        Runner->>Runner: Compare supervisor_version with supervisor_version_latest
        alt Versions are equal
            Runner->>Runner: Log message and skip test
        else
            Runner->>Runner: Proceed with test validations
        end
    end
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 212796c and 38cb3c0.

📒 Files selected for processing (2)
  • tests/smoke_test/test_basic.py (1 hunks)
  • tests/supervisor_test/test_supervisor.py (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
tests/smoke_test/test_basic.py (2)
tests/conftest.py (1)
  • shell (46-50)
tests/qemu_shell_strategy.py (1)
  • run_check (26-27)
🔇 Additional comments (4)
tests/supervisor_test/test_supervisor.py (1)

62-66: Excellent enhancement to prevent unnecessary update attempts

This change properly checks for the existence of version information before attempting an update, and skips the test when the supervisor is already up to date. This prevents unnecessary update attempts and makes the test more robust.

tests/smoke_test/test_basic.py (3)

90-94: Good implementation of host connectivity test

The test correctly verifies network connectivity using both curl and nmcli, which provides redundancy in case one method fails. This aligns with the PR objectives to enhance testing by adding connectivity checks.


97-103: Well-structured supervisor container connectivity test

The test properly checks connectivity from within the supervisor container using docker exec and verifies against a known endpoint. The timeout and dependency on test_init are appropriate safeguards.


105-111: Effective CLI container connectivity test

The hassio_cli container connectivity test follows the same pattern as the supervisor test, providing consistency across the test suite. The comment explaining the purpose of the test is helpful for future maintenance.

✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@sairon sairon merged commit 349b7e4 into dev Apr 7, 2025
3 checks passed
@sairon sairon deleted the add-connectivity-tests branch April 7, 2025 14:13
This was referenced Apr 11, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 15, 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.

2 participants