test(unraid): add in-host validation runner
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
import json
|
||||||
|
import pathlib
|
||||||
|
import time
|
||||||
|
import urllib.error
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
from websockets.sync.client import connect
|
||||||
|
|
||||||
|
token = pathlib.Path("/run/secrets/api-token").read_text().strip()
|
||||||
|
headers = {"Authorization": "Bearer " + token}
|
||||||
|
|
||||||
|
|
||||||
|
def get(path):
|
||||||
|
req = urllib.request.Request("http://127.0.0.1:18120" + path, headers=headers)
|
||||||
|
with urllib.request.urlopen(req, timeout=10) as response:
|
||||||
|
return json.load(response)
|
||||||
|
|
||||||
|
|
||||||
|
health = get("/v1/health")
|
||||||
|
capabilities = get("/v1/capabilities")
|
||||||
|
with connect("ws://127.0.0.1:18120/v1/poses", additional_headers=headers, open_timeout=10) as ws:
|
||||||
|
messages = [json.loads(ws.recv(timeout=20)) for _ in range(10)]
|
||||||
|
|
||||||
|
frame_ids = [m["frame_id"] for m in messages]
|
||||||
|
summary = {
|
||||||
|
"tested_at_unix_ns": time.time_ns(),
|
||||||
|
"health": health,
|
||||||
|
"capabilities": capabilities,
|
||||||
|
"websocket": {
|
||||||
|
"messages": len(messages),
|
||||||
|
"frame_ids": frame_ids,
|
||||||
|
"strictly_increasing": all(b > a for a, b in zip(frame_ids, frame_ids[1:])),
|
||||||
|
"source_alive_all": all(m["source_alive"] for m in messages),
|
||||||
|
"people_counts": [len(m["people"]) for m in messages],
|
||||||
|
"coordinate_space_all": all(m["frame"]["coordinate_space"] == "ndi_buffer_unmodified" for m in messages),
|
||||||
|
"horizontal_flip_all_false": all(not m["frame"]["horizontal_flip_applied"] for m in messages),
|
||||||
|
"source_to_sent_ms": [round(m["timing"]["source_to_sent_ms"], 3) for m in messages],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
print(json.dumps(summary, ensure_ascii=False, indent=2))
|
||||||
|
|
||||||
@@ -96,3 +96,28 @@ services:
|
|||||||
retries: 6
|
retries: 6
|
||||||
start_period: 180s
|
start_period: 180s
|
||||||
|
|
||||||
|
validate:
|
||||||
|
image: tail2-pose-server:0.1.0
|
||||||
|
container_name: tail2-pose-validate
|
||||||
|
network_mode: host
|
||||||
|
gpus: all
|
||||||
|
restart: "no"
|
||||||
|
entrypoint: ["/bin/bash", "-lc"]
|
||||||
|
depends_on:
|
||||||
|
tail2-pose-server:
|
||||||
|
condition: service_healthy
|
||||||
|
volumes:
|
||||||
|
- /mnt/user/appdata/tail2-pose-server/app:/app:ro
|
||||||
|
- /mnt/user/appdata/tail2-pose-server/models:/models:ro
|
||||||
|
- /mnt/user/appdata/tail2-pose-server/secrets/api-token:/run/secrets/api-token:ro
|
||||||
|
- ./validation:/validation
|
||||||
|
command:
|
||||||
|
- |
|
||||||
|
set -euo pipefail
|
||||||
|
python -m pytest -q /opt/tail2-tests > /validation/unit-tests.txt 2>&1
|
||||||
|
python /app/tail2/validate_runtime.py > /validation/runtime.json
|
||||||
|
python -m pip freeze | sort > /validation/pip-freeze.txt
|
||||||
|
find / -xdev -type f -name 'libndi.so*' -print > /validation/ndi-runtime-files.txt 2>/dev/null || true
|
||||||
|
nvidia-smi --query-gpu=name,driver_version,memory.total,memory.used,temperature.gpu --format=csv,noheader > /validation/gpu.csv
|
||||||
|
sha256sum /models/*.pth > /validation/model-sha256.txt
|
||||||
|
chmod 0666 /validation/*.txt /validation/*.json /validation/*.csv
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
Reference in New Issue
Block a user