Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test_supervisor.py #3647

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions tests/supervisor_test/test_supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,36 @@ def check_container_running(container_name):
shell.run_check("docker inspect --format='{{.NetworkSettings.IPAddress}}' hassio_supervisor")
)

while True:
try:
if shell_json(f"curl -sSL http://{supervisor_ip}/supervisor/ping").get("result") == "ok":
break
except ExecutionError:
pass # avoid failure when the container is restarting

sleep(1)
MAX_WAIT_TIME = 120 # 2 minutes should be sufficient
+ retries = 0
+ # Wait for containers to start
+ while retries < MAX_WAIT_TIME:
+ if check_container_running("homeassistant") and check_container_running("hassio_supervisor"):
+ break
+ retries += 1
+ sleep(1)
+ else:
+ raise TimeoutError(
+ f"Containers did not start within {MAX_WAIT_TIME} seconds. "
+ "Container status: "
+ f"homeassistant={check_container_running('homeassistant')}, "
+ f"hassio_supervisor={check_container_running('hassio_supervisor')}"
+ )
+
+ # Wait for supervisor ping
+ retries = 0
+ while retries < MAX_WAIT_TIME:
+ try:
+ if shell_json(f"curl -sSL http://{supervisor_ip}/supervisor/ping").get("result") == "ok":
+ break
+ except ExecutionError:
+ pass # avoid failure when the container is restarting
+ retries += 1
+ sleep(1)
+ else:
+ raise TimeoutError(
+ f"Supervisor ping did not respond within {MAX_WAIT_TIME} seconds"
+ )


@pytest.mark.dependency(depends=["test_start_supervisor"])
Expand Down