diff --git a/Cargo.lock b/Cargo.lock index c97e816..d63c657 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1652,7 +1652,7 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" [[package]] name = "lesavka_client" -version = "0.16.13" +version = "0.16.14" dependencies = [ "anyhow", "async-stream", @@ -1686,7 +1686,7 @@ dependencies = [ [[package]] name = "lesavka_common" -version = "0.16.13" +version = "0.16.14" dependencies = [ "anyhow", "base64", @@ -1698,7 +1698,7 @@ dependencies = [ [[package]] name = "lesavka_server" -version = "0.16.13" +version = "0.16.14" dependencies = [ "anyhow", "base64", diff --git a/client/Cargo.toml b/client/Cargo.toml index 0caf2f7..622c9af 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -4,7 +4,7 @@ path = "src/main.rs" [package] name = "lesavka_client" -version = "0.16.13" +version = "0.16.14" edition = "2024" [dependencies] diff --git a/common/Cargo.toml b/common/Cargo.toml index 842121a..d83459e 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lesavka_common" -version = "0.16.13" +version = "0.16.14" edition = "2024" build = "build.rs" diff --git a/scripts/manual/local_av_stimulus.py b/scripts/manual/local_av_stimulus.py index ff81229..dfe2a3f 100755 --- a/scripts/manual/local_av_stimulus.py +++ b/scripts/manual/local_av_stimulus.py @@ -192,8 +192,10 @@ async function pollCommand() { } setInterval(pollCommand, 200); setInterval(() => postJson('/status', { ready: true, page_message: running ? 'running heartbeat' : 'ready heartbeat' }), 1000); -postJson('/status', { ready: true, page_message: 'page ready' }); -setStatus('ready\nPoint the real webcam at this window.\nKeep speakers audible to the selected microphone.'); +void postJson('/status', { ready: true, page_message: 'page ready' }); +setStatus(`ready +Point the real webcam at this window. +Keep speakers audible to the selected microphone.`); """ diff --git a/scripts/manual/run_upstream_mirrored_av_sync.sh b/scripts/manual/run_upstream_mirrored_av_sync.sh index 2c1a4da..b2c5085 100755 --- a/scripts/manual/run_upstream_mirrored_av_sync.sh +++ b/scripts/manual/run_upstream_mirrored_av_sync.sh @@ -100,6 +100,41 @@ sys.exit(1) PY } +wait_for_stimulus_page_ready() { + local timeout_seconds=$1 + local deadline=$(( $(date +%s) + timeout_seconds )) + local status_json="" + until status_json="$(curl -fsS "http://127.0.0.1:${STIMULUS_PORT}/status" 2>/dev/null)"; do + if (( $(date +%s) >= deadline )); then + echo "Timed out waiting for local stimulus status endpoint" >&2 + return 1 + fi + sleep 0.2 + done + while true; do + if STATUS_JSON="${status_json}" python3 - <<'PY' +import json +import os +import sys + +status = json.loads(os.environ["STATUS_JSON"]) +sys.exit(0 if status.get("ready") and status.get("page_message") != "booting" else 1) +PY + then + return 0 + fi + if (( $(date +%s) >= deadline )); then + echo "local stimulus page did not become ready before timeout" >&2 + echo "last stimulus status: ${status_json}" >&2 + echo "stimulus server log: ${ARTIFACT_DIR}/stimulus-server.log" >&2 + echo "stimulus browser log: ${ARTIFACT_DIR}/stimulus-browser.log" >&2 + return 1 + fi + sleep 0.5 + status_json="$(curl -fsS "http://127.0.0.1:${STIMULUS_PORT}/status" 2>/dev/null || true)" + done +} + start_server_tunnel_if_needed() { if [[ "${LESAVKA_SERVER_ADDR}" != "auto" ]]; then RESOLVED_LESAVKA_SERVER_ADDR="${LESAVKA_SERVER_ADDR}" @@ -150,6 +185,7 @@ PREFS "http://127.0.0.1:${STIMULUS_PORT}/" \ >"${ARTIFACT_DIR}/stimulus-browser.log" 2>&1 & STIMULUS_BROWSER_PID=$! + wait_for_stimulus_page_ready 15 echo "==> position check" echo " Point the real webcam at the stimulus window and keep the selected microphone hearing the tone." diff --git a/server/Cargo.toml b/server/Cargo.toml index bce8f7c..6aff42b 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -10,7 +10,7 @@ bench = false [package] name = "lesavka_server" -version = "0.16.13" +version = "0.16.14" edition = "2024" autobins = false diff --git a/testing/tests/client_manual_sync_script_contract.rs b/testing/tests/client_manual_sync_script_contract.rs index 5a9fbd4..bdcaa45 100644 --- a/testing/tests/client_manual_sync_script_contract.rs +++ b/testing/tests/client_manual_sync_script_contract.rs @@ -90,6 +90,7 @@ fn mirrored_sync_script_uses_real_client_capture_path() { "BROWSER_SYNC_DRIVER_COMMAND=\"${driver_command}\"", "SYNC_ANALYZE_EVENT_WIDTH_CODES=\"${PROBE_EVENT_WIDTH_CODES}\"", "run_upstream_browser_av_sync.sh", + "wait_for_stimulus_page_ready 15", "Point the real webcam at the stimulus window", ] { assert!( @@ -114,6 +115,7 @@ fn local_stimulus_matches_sync_analyzer_pulse_contract() { "event_width_codes", "widthCode", "oscillator.frequency.value = 880", + "setStatus(`ready", "Point the real webcam at this window", ] { assert!(