mirror of
https://github.com/azaion/detections.git
synced 2026-04-22 10:56:32 +00:00
Update health endpoint and refine test documentation
- Modified the health endpoint to return "None" for AI availability when inference is not initialized, improving clarity on system status. - Enhanced the test documentation to include handling of skipped tests, emphasizing the need for investigation before proceeding. - Updated test assertions to ensure proper execution order and prevent premature engine initialization. - Refactored test cases to streamline performance testing and improve readability, removing unnecessary complexity. These changes aim to enhance the robustness of the health check and improve the overall testing framework.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import json
|
||||
import time
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -46,42 +45,6 @@ def test_nft_perf_01_single_image_latency_p95(
|
||||
assert p95 < 5000.0
|
||||
|
||||
|
||||
def _post_small(http_client, image_small):
|
||||
return http_client.post(
|
||||
"/detect",
|
||||
files={"file": ("img.jpg", image_small, "image/jpeg")},
|
||||
timeout=120,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.timeout(300)
|
||||
def test_nft_perf_02_concurrent_throughput_queuing(
|
||||
warm_engine, http_client, image_small
|
||||
):
|
||||
def run_two():
|
||||
t0 = time.monotonic()
|
||||
with ThreadPoolExecutor(max_workers=2) as ex:
|
||||
futs = [ex.submit(_post_small, http_client, image_small) for _ in range(2)]
|
||||
rs = [f.result() for f in futs]
|
||||
return time.monotonic() - t0, rs
|
||||
|
||||
def run_three():
|
||||
t0 = time.monotonic()
|
||||
with ThreadPoolExecutor(max_workers=3) as ex:
|
||||
futs = [ex.submit(_post_small, http_client, image_small) for _ in range(3)]
|
||||
rs = [f.result() for f in futs]
|
||||
return time.monotonic() - t0, rs
|
||||
|
||||
wall2, rs2 = run_two()
|
||||
assert all(r.status_code == 200 for r in rs2)
|
||||
wall3, rs3 = run_three()
|
||||
assert all(r.status_code == 200 for r in rs3)
|
||||
if wall2 < 4.0:
|
||||
pytest.skip("wall clock too small for queuing comparison")
|
||||
assert wall3 > wall2 + 0.25
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.timeout(300)
|
||||
def test_nft_perf_03_tiling_overhead_large_image(
|
||||
|
||||
Reference in New Issue
Block a user