diff --git a/e2e/run_test.sh b/e2e/run_test.sh index 1b00b35..28d5f3b 100755 --- a/e2e/run_test.sh +++ b/e2e/run_test.sh @@ -19,6 +19,13 @@ case "$PROFILE" in esac COMPOSE="docker compose -f docker-compose.test.yml --profile $PROFILE" +RUNNER_ENV_ARGS=(-e E2E_PROFILE="$PROFILE") +if [[ "$PROFILE" == "jetson" ]]; then + RUNNER_ENV_ARGS+=( + -e E2E_WAIT_FOR_ENGINE_ENABLED="${E2E_WAIT_FOR_ENGINE_ENABLED:-1}" + -e E2E_ENGINE_WAIT_TIMEOUT="${E2E_ENGINE_WAIT_TIMEOUT:-900}" + ) +fi usage() { echo "Usage: $0 [pytest_args...]" @@ -54,7 +61,7 @@ done echo "--- Running: pytest $* -v -x -s --csv=/results/report.csv" set +e -$COMPOSE run --rm --build --no-deps e2e-runner pytest "$@" -v -x -s --csv=/results/report.csv +$COMPOSE run --rm --build --no-deps "${RUNNER_ENV_ARGS[@]}" e2e-runner pytest "$@" -v -x -s --csv=/results/report.csv EXIT_CODE=$? set -e diff --git a/e2e/tests/test_health_engine.py b/e2e/tests/test_health_engine.py index e160f52..4273175 100644 --- a/e2e/tests/test_health_engine.py +++ b/e2e/tests/test_health_engine.py @@ -1,4 +1,5 @@ import json +import os import threading import time import uuid @@ -7,6 +8,13 @@ import pytest import sseclient _DETECT_TIMEOUT = 60 +_ENGINE_WAIT_TIMEOUT = int(os.environ.get("E2E_ENGINE_WAIT_TIMEOUT", "900")) +_WAIT_FOR_ENGINE_ENABLED = os.environ.get("E2E_WAIT_FOR_ENGINE_ENABLED", "").lower() in ( + "1", + "true", + "yes", + "on", +) def _get_health(http_client): @@ -20,6 +28,24 @@ def _assert_active_ai(data): assert data["aiAvailability"] not in ("None", "Downloading") +def _wait_for_engine_enabled(http_client): + deadline = time.time() + _ENGINE_WAIT_TIMEOUT + last = None + while time.time() < deadline: + last = _get_health(http_client) + availability = last.get("aiAvailability") + if availability == "Enabled": + assert last.get("errorMessage") is None + return last + if availability == "Error": + pytest.fail(f"engine conversion failed: {last.get('errorMessage')}") + time.sleep(3) + pytest.fail( + f"engine did not become Enabled within {_ENGINE_WAIT_TIMEOUT}s " + f"(last health: {last})" + ) + + @pytest.mark.cpu class TestHealthEngineStep01PreInit: def test_ft_p_01_pre_init_health(self, http_client): @@ -92,8 +118,12 @@ class TestHealthEngineStep03Warmed: def _warm(self, warm_engine): pass + @pytest.mark.timeout(_ENGINE_WAIT_TIMEOUT + 30) def test_ft_p_02_post_init_health(self, http_client): - data = _get_health(http_client) + if _WAIT_FOR_ENGINE_ENABLED: + data = _wait_for_engine_enabled(http_client) + else: + data = _get_health(http_client) _assert_active_ai(data) assert data.get("errorMessage") is None