Fix e2e tests

This commit is contained in:
Roman Meshko
2026-05-15 12:45:18 +03:00
parent 2eb5b5d8ad
commit 255ec36f8a
3 changed files with 11 additions and 3 deletions
+4 -3
View File
@@ -249,7 +249,7 @@ def _health(http_client):
def _health_ai_active(data: dict) -> bool: def _health_ai_active(data: dict) -> bool:
return data.get("aiAvailability") not in ("None", "Downloading", "Error") return data.get("aiAvailability") == "Enabled"
def _wait_for_ai_active(http_client, timeout: float = 30) -> dict | None: def _wait_for_ai_active(http_client, timeout: float = 30) -> dict | None:
@@ -324,7 +324,8 @@ def corrupt_image():
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def warm_engine(http_client, image_small, auth_headers): def warm_engine(http_client, image_small, auth_headers):
deadline = time.time() + 120 timeout = int(os.environ.get("E2E_ENGINE_WAIT_TIMEOUT", "900"))
deadline = time.time() + timeout
last_status = None last_status = None
consecutive_errors = 0 consecutive_errors = 0
@@ -403,4 +404,4 @@ def warm_engine(http_client, image_small, auth_headers):
th.join(timeout=1) th.join(timeout=1)
time.sleep(2) time.sleep(2)
pytest.fail(f"engine warm-up timed out after 120s (last status: {last_status})") pytest.fail(f"engine warm-up timed out after {timeout}s (last status: {last_status})")
+3
View File
@@ -72,6 +72,9 @@ def video_events(warm_engine, http_client, auth_headers):
**auth_headers, **auth_headers,
"X-Channel-Id": channel_id, "X-Channel-Id": channel_id,
"X-Filename": "video_test01.mp4", "X-Filename": "video_test01.mp4",
"X-Config": json.dumps(
{"model_batch_size": 1, "frame_period_recognition": 25}
),
"Content-Type": "application/octet-stream", "Content-Type": "application/octet-stream",
}, },
timeout=15, timeout=15,
+4
View File
@@ -515,6 +515,8 @@ async def detect_image(
_post_annotation_to_service(token_mgr, content_hash, annotation, dtos) _post_annotation_to_service(token_mgr, content_hash, annotation, dtos)
def run_sync(): def run_sync():
if not inf.is_engine_ready:
raise RuntimeError("Detection service unavailable")
inf.run_detect_image(image_bytes, ai_cfg, media_name, on_annotation) inf.run_detect_image(image_bytes, ai_cfg, media_name, on_annotation)
try: try:
@@ -609,6 +611,8 @@ async def detect_video_upload(
_post_annotation_to_service(token_mgr, mid, annotation, dtos) _post_annotation_to_service(token_mgr, mid, annotation, dtos)
def run_inference(): def run_inference():
if not inf.is_engine_ready:
raise RuntimeError("Detection service unavailable")
inf.run_detect_video_stream(buffer, ai_cfg, media_name, on_annotation, lambda *_: None) inf.run_detect_video_stream(buffer, ai_cfg, media_name, on_annotation, lambda *_: None)
inference_future = loop.run_in_executor(executor, run_inference) inference_future = loop.run_in_executor(executor, run_inference)