2023-10-17 18:23:29 +02:00
|
|
|
import logging
|
|
|
|
|
from time import sleep
|
|
|
|
|
|
2023-10-31 18:16:49 +01:00
|
|
|
import pytest
|
|
|
|
|
|
2023-10-17 18:23:29 +02:00
|
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
2023-10-31 18:16:49 +01:00
|
|
|
@pytest.mark.dependency()
|
|
|
|
|
@pytest.mark.timeout(600)
|
2023-10-31 10:12:10 +01:00
|
|
|
def test_init(shell):
|
2023-10-17 18:23:29 +02:00
|
|
|
def check_container_running(container_name):
|
2023-10-31 10:12:10 +01:00
|
|
|
out = shell.run_check(
|
2023-10-17 18:23:29 +02:00
|
|
|
f"docker container inspect -f '{{{{.State.Status}}}}' {container_name} || true"
|
|
|
|
|
)
|
|
|
|
|
return "running" in out
|
|
|
|
|
|
|
|
|
|
# wait for important containers first
|
2023-10-31 18:16:49 +01:00
|
|
|
while True:
|
2023-10-17 18:23:29 +02:00
|
|
|
if check_container_running("homeassistant") and check_container_running("hassio_supervisor"):
|
|
|
|
|
break
|
|
|
|
|
|
2023-10-31 18:16:49 +01:00
|
|
|
sleep(1)
|
2023-10-17 18:23:29 +02:00
|
|
|
|
|
|
|
|
# wait for system ready
|
2023-10-31 18:16:49 +01:00
|
|
|
while True:
|
2023-10-31 10:12:10 +01:00
|
|
|
output = "\n".join(shell.run_check("ha os info || true"))
|
2023-10-17 18:23:29 +02:00
|
|
|
if "System is not ready" not in output:
|
|
|
|
|
break
|
|
|
|
|
|
2023-10-31 18:16:49 +01:00
|
|
|
sleep(1)
|
2023-10-17 18:23:29 +02:00
|
|
|
|
2023-10-31 10:12:10 +01:00
|
|
|
output = shell.run_check("ha os info")
|
|
|
|
|
_LOGGER.info("%s", "\n".join(output))
|
|
|
|
|
|
2023-10-31 18:16:49 +01:00
|
|
|
|
|
|
|
|
@pytest.mark.dependency(depends=["test_init"])
|
2023-10-31 10:12:10 +01:00
|
|
|
def test_dmesg(shell):
|
|
|
|
|
output = shell.run_check("dmesg")
|
2023-10-17 18:23:29 +02:00
|
|
|
_LOGGER.info("%s", "\n".join(output))
|
|
|
|
|
|
|
|
|
|
|
2023-10-31 18:16:49 +01:00
|
|
|
@pytest.mark.dependency(depends=["test_init"])
|
2023-10-31 10:12:10 +01:00
|
|
|
def test_supervisor_logs(shell):
|
|
|
|
|
output = shell.run_check("ha su logs")
|
2023-10-17 18:23:29 +02:00
|
|
|
_LOGGER.info("%s", "\n".join(output))
|
|
|
|
|
|
|
|
|
|
|
2023-10-31 18:16:49 +01:00
|
|
|
@pytest.mark.dependency(depends=["test_init"])
|
2023-10-31 10:12:10 +01:00
|
|
|
def test_systemctl_status(shell):
|
2023-10-31 18:16:49 +01:00
|
|
|
output = shell.run_check("systemctl --no-pager -l status -a || true")
|
2023-10-17 18:23:29 +02:00
|
|
|
_LOGGER.info("%s", "\n".join(output))
|