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

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.
This commit is contained in:
Jan Čermák 2025-04-07 16:13:11 +02:00 committed by GitHub
parent cdbbfeaecc
commit 349b7e48ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View File

@ -87,6 +87,29 @@ def test_systemctl_no_cycles(shell):
assert not output, f"Found Systemd dependency cycles:\n{"\n".join(output)}"
def test_host_connectivity(shell):
output = shell.run_check("curl -f https://checkonline.home-assistant.io/online.txt")
assert "NetworkManager is online" in output
output = shell.run_check("nmcli network connectivity check")
assert "full" in output, f"Connectivity check failed, nmcli reports: {output}"
@pytest.mark.dependency(depends=["test_init"])
@pytest.mark.timeout(10)
def test_supervisor_connectivity(shell):
# checks URL used by connectivity checks via docker0 bridge
output = shell.run_check("docker exec -ti hassio_supervisor curl -f https://checkonline.home-assistant.io/online.txt")
assert "NetworkManager is online" in output
@pytest.mark.dependency(depends=["test_init"])
@pytest.mark.timeout(10)
def test_hassio_connectivity(shell):
# checks URL used by connectivity checks via hassio bridge
output = shell.run_check("docker exec -ti hassio_cli curl -f https://checkonline.home-assistant.io/online.txt")
assert "NetworkManager is online" in output
@pytest.mark.dependency(depends=["test_init"])
def test_custom_swap_size(shell, target):
output = shell.run_check("stat -c '%s' /mnt/data/swapfile")

View File

@ -59,7 +59,9 @@ def test_check_supervisor(shell_json):
def test_update_supervisor(shell_json):
supervisor_info = shell_json("ha supervisor info --no-progress --raw-json")
supervisor_version = supervisor_info.get("data").get("version")
if supervisor_version == supervisor_info.get("data").get("version_latest"):
supervisor_version_latest = supervisor_info.get("data").get("version_latest")
assert supervisor_version_latest, "Missing latest supervisor version info"
if supervisor_version == supervisor_version_latest:
logger.info("Supervisor is already up to date")
pytest.skip("Supervisor is already up to date")
else: