Skip to content

Commit a2a055b

Browse files
committed
Wait for Core to install and start in Supervisor tests
Backup now fails after home-assistant/supervisor#6553 if Core isn't installed and started. Similarly to the tests in the Supervisor CI, wait until Core install finishes before proceeding with other tests in the suite.
1 parent d149b5a commit a2a055b

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

tests/supervisor_test/test_supervisor.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def stash() -> dict:
1616

1717

1818
@pytest.mark.dependency()
19-
@pytest.mark.timeout(120)
19+
@pytest.mark.timeout(360)
2020
def test_start_supervisor(shell, shell_json):
2121
def check_container_running(container_name):
2222
out = shell.run_check(f"docker container inspect -f '{{{{.State.Status}}}}' {container_name} || true")
@@ -42,6 +42,34 @@ def check_container_running(container_name):
4242
sleep(1)
4343

4444

45+
logger.info("Waiting for Home Assistant Core to be installed and started...")
46+
core_install_started = False
47+
while True:
48+
try:
49+
jobs_info = shell_json("ha jobs info --no-progress --raw-json")
50+
if jobs_info.get("result") != "ok":
51+
sleep(5)
52+
continue
53+
jobs = jobs_info.get("data", {}).get("jobs", [])
54+
core_installing = any(
55+
j.get("name") == "home_assistant_core_install" and not j.get("done")
56+
for j in jobs
57+
)
58+
if core_installing:
59+
# install is in progress
60+
if not core_install_started:
61+
logger.info("Home Assistant Core install job detected, waiting for completion...")
62+
core_install_started = True
63+
elif core_install_started:
64+
# started and not installing anymore means finished
65+
logger.info("Home Assistant Core install/start complete")
66+
break
67+
except ExecutionError:
68+
pass # avoid failure when the supervisor/CLI is restarting
69+
70+
sleep(5)
71+
72+
4573
@pytest.mark.dependency(depends=["test_start_supervisor"])
4674
def test_check_supervisor(shell_json):
4775
# check supervisor info

0 commit comments

Comments
 (0)