54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
"""Smoke test: one camera worker against the local LiveKit server, ~20 s."""
|
|
import json
|
|
import signal
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
HERE = Path(__file__).parent
|
|
sys.path.insert(0, str(HERE))
|
|
|
|
from discovery import discover_cameras
|
|
from tokens import make_token
|
|
|
|
cams = discover_cameras()
|
|
if not cams:
|
|
raise SystemExit("no cameras discovered")
|
|
cam = cams[0]
|
|
url = "ws://127.0.0.1:7880"
|
|
tok = make_token(url, "devkey", "devsecret", "smoke", cam.identity)
|
|
|
|
p = subprocess.Popen(
|
|
[str(HERE / ".venv/bin/python"), str(HERE / "run_worker.py"),
|
|
"--camera-json", json.dumps({
|
|
"index": cam.index, "identity": cam.identity,
|
|
"video_device": cam.video_device, "audio_card": cam.audio_card,
|
|
"usb_port": cam.usb_port, "serial": cam.serial}),
|
|
"--room", "smoke", "--url", url, "--token", tok,
|
|
"--width", "640", "--height", "480", "--fps", "15",
|
|
"--audio-rate", "16000", "--enhance-mode", "force",
|
|
"--enhance-chunk-s", "1.0", "--enhance-hop-s", "0.2"],
|
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1,
|
|
)
|
|
t0 = time.time()
|
|
lines = []
|
|
while time.time() - t0 < 20:
|
|
line = p.stdout.readline()
|
|
if line:
|
|
lines.append(line.rstrip())
|
|
print(line.rstrip(), flush=True)
|
|
p.send_signal(signal.SIGTERM)
|
|
try:
|
|
rc = p.wait(timeout=15)
|
|
except subprocess.TimeoutExpired:
|
|
p.kill()
|
|
rc = "killed"
|
|
print(f"--- smoke test done: rc={rc}")
|
|
print("published markers:",
|
|
[l for l in lines if "published" in l or "status" in l or "UP" in l
|
|
or "backend" in l])
|
|
ok = any("audio backend: model" in l for l in lines) and any(
|
|
"published video+audio" in l or "status: UP" in l for l in lines)
|
|
sys.exit(0 if ok else 1)
|