chore(tradein): browser-smoke.sh — verify tradein-browser /health + /fetch (#905)
Reusable smoke test for the camoufox HTTP service. Run from the deploy host: docker exec -i tradein-backend sh < tradein-mvp/scripts/browser-smoke.sh Reports health, byte count, preloadedState presence, firewall-block detection + first 200 bytes of the response. Avoids long one-line curl commands that get mangled on terminal paste. Refs #905, #883
This commit is contained in:
parent
4aeeef8c2d
commit
71f05308e9
1 changed files with 33 additions and 0 deletions
33
tradein-mvp/scripts/browser-smoke.sh
Normal file
33
tradein-mvp/scripts/browser-smoke.sh
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
# Smoke-test the tradein-browser service (camoufox HTTP wrapper, #905) from
|
||||
# inside the tradein docker network. Verifies /health and a real /fetch.
|
||||
#
|
||||
# Run from the deploy host (after `git pull`), piping the script into the
|
||||
# backend container (which shares the tradein-net with tradein-browser):
|
||||
#
|
||||
# docker exec -i tradein-backend sh < tradein-mvp/scripts/browser-smoke.sh
|
||||
#
|
||||
# Override the target URL:
|
||||
# URL=https://example.com docker exec -i -e URL tradein-backend sh < tradein-mvp/scripts/browser-smoke.sh
|
||||
set -eu
|
||||
|
||||
B="${BROWSER_HTTP_ENDPOINT:-http://tradein-browser:3000}"
|
||||
U="${URL:-https://www.avito.ru/ekaterinburg/kvartiry/prodam}"
|
||||
|
||||
printf 'health: '
|
||||
curl -s --max-time 10 "$B/health" || echo "(no response)"
|
||||
echo
|
||||
|
||||
echo "{\"url\":\"$U\"}" > /tmp/smoke_payload.json
|
||||
curl -s --max-time 120 -X POST "$B/fetch" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d @/tmp/smoke_payload.json \
|
||||
-o /tmp/smoke_result.html || true
|
||||
|
||||
echo "url: $U"
|
||||
echo "bytes: $(wc -c < /tmp/smoke_result.html 2>/dev/null || echo 0)"
|
||||
echo "preloaded: $(grep -c preloadedState /tmp/smoke_result.html 2>/dev/null || echo 0)"
|
||||
echo "firewall: $(grep -ci firewall-container /tmp/smoke_result.html 2>/dev/null || echo 0)"
|
||||
echo "--- first 200 bytes (error JSON shows here if /fetch failed) ---"
|
||||
head -c 200 /tmp/smoke_result.html 2>/dev/null || true
|
||||
echo
|
||||
Loading…
Add table
Reference in a new issue