platform: modularize api/gui, add docs-tests-web foundation, and refresh root config
This commit is contained in:
43
tests/trace_append.sh
Executable file
43
tests/trace_append.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
API_URL="${API_URL:-http://127.0.0.1:8080}"
|
||||
SENT_LINE="test-trace-$(date +%s)-$RANDOM"
|
||||
TMP_JSON="$(mktemp)"
|
||||
trap 'rm -f "$TMP_JSON"' EXIT
|
||||
|
||||
resp="$(curl -sS --max-time 15 "${API_URL}/api/v1/trace/append" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"kind\":\"gui\",\"line\":\"${SENT_LINE}\"}")"
|
||||
python3 - "$resp" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
obj = json.loads(sys.argv[1])
|
||||
if obj.get("ok") is not True:
|
||||
print(f"[trace] append response not ok: {obj}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
PY
|
||||
|
||||
plain="$(curl -sS --max-time 15 "${API_URL}/api/v1/trace")"
|
||||
if ! grep -q -- "${SENT_LINE}" <<<"${plain}"; then
|
||||
echo "[trace] appended line not found in /api/v1/trace" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
curl -sS --max-time 15 "${API_URL}/api/v1/trace-json?mode=full" >"$TMP_JSON"
|
||||
python3 - "$TMP_JSON" "$SENT_LINE" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
file_path, needle = sys.argv[1], sys.argv[2]
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
obj = json.load(f)
|
||||
lines = obj.get("lines")
|
||||
if not isinstance(lines, list):
|
||||
print("[trace] /trace-json invalid payload: no lines[]", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
if not any(needle in line for line in lines if isinstance(line, str)):
|
||||
print("[trace] appended line not found in /trace-json", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
PY
|
||||
|
||||
echo "[trace] append and readback OK"
|
||||
Reference in New Issue
Block a user