mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-08-16 17:40:58 +00:00

* Improve handling of timeouts in tests Make timeout handling in tests more transparent. Added a custom shell driver that allows to define global timeout for commands in the config file, and replaced for/sleep constructs with infinite loops that will be eventually terminated by pytest-timeout plugin. Current timeouts taken from last runs on Github CI with some extra headroom. * test_supervisor_is_updated shouldn't be skipped if no update was needed * Allow more time for system startup * Allow even more time for system startup
54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
import logging
|
|
from time import sleep
|
|
|
|
import pytest
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
@pytest.mark.dependency()
|
|
@pytest.mark.timeout(600)
|
|
def test_init(shell):
|
|
def check_container_running(container_name):
|
|
out = shell.run_check(
|
|
f"docker container inspect -f '{{{{.State.Status}}}}' {container_name} || true"
|
|
)
|
|
return "running" in out
|
|
|
|
# wait for important containers first
|
|
while True:
|
|
if check_container_running("homeassistant") and check_container_running("hassio_supervisor"):
|
|
break
|
|
|
|
sleep(1)
|
|
|
|
# wait for system ready
|
|
while True:
|
|
output = "\n".join(shell.run_check("ha os info || true"))
|
|
if "System is not ready" not in output:
|
|
break
|
|
|
|
sleep(1)
|
|
|
|
output = shell.run_check("ha os info")
|
|
_LOGGER.info("%s", "\n".join(output))
|
|
|
|
|
|
@pytest.mark.dependency(depends=["test_init"])
|
|
def test_dmesg(shell):
|
|
output = shell.run_check("dmesg")
|
|
_LOGGER.info("%s", "\n".join(output))
|
|
|
|
|
|
@pytest.mark.dependency(depends=["test_init"])
|
|
def test_supervisor_logs(shell):
|
|
output = shell.run_check("ha su logs")
|
|
_LOGGER.info("%s", "\n".join(output))
|
|
|
|
|
|
@pytest.mark.dependency(depends=["test_init"])
|
|
def test_systemctl_status(shell):
|
|
output = shell.run_check("systemctl --no-pager -l status -a || true")
|
|
_LOGGER.info("%s", "\n".join(output))
|