platform: modularize api/gui, add docs-tests-web foundation, and refresh root config
This commit is contained in:
89
tests/transport_recovery_runbook_smoke.sh
Executable file
89
tests/transport_recovery_runbook_smoke.sh
Executable file
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
API_URL="${API_URL:-http://127.0.0.1:8080}"
|
||||
RUNBOOK="${ROOT_DIR}/scripts/transport_runbook.py"
|
||||
RECOVERY="${ROOT_DIR}/scripts/transport_recovery_runbook.py"
|
||||
|
||||
for f in "$RUNBOOK" "$RECOVERY"; do
|
||||
if [[ ! -x "$f" ]]; then
|
||||
if [[ -f "$f" ]]; then
|
||||
chmod +x "$f"
|
||||
else
|
||||
echo "[transport_recovery_runbook_smoke] missing script: $f" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
ts="$(date +%s)"
|
||||
pid="$$"
|
||||
ok_id="smoke-recovery-ok-${ts}-${pid}"
|
||||
fail_id="smoke-recovery-fail-${ts}-${pid}"
|
||||
diag_ok="/tmp/${ok_id}.json"
|
||||
diag_fail="/tmp/${fail_id}.json"
|
||||
trap 'rm -f "$diag_ok" "$diag_fail"' EXIT
|
||||
|
||||
echo "[transport_recovery_runbook_smoke] API_URL=${API_URL}"
|
||||
|
||||
echo "[transport_recovery_runbook_smoke] case1: recovery success"
|
||||
env API_URL="${API_URL}" "$RUNBOOK" \
|
||||
--api-url "${API_URL}" \
|
||||
--client-id "${ok_id}" \
|
||||
--kind singbox \
|
||||
--name "Recovery OK ${ok_id}" \
|
||||
--config-json '{"runner":"mock","runtime_mode":"exec"}' \
|
||||
--actions "create"
|
||||
|
||||
env API_URL="${API_URL}" "$RECOVERY" \
|
||||
--api-url "${API_URL}" \
|
||||
--client-id "${ok_id}" \
|
||||
--max-restarts 1 \
|
||||
--provision-if-needed \
|
||||
--diagnostics-json "$diag_ok"
|
||||
|
||||
env API_URL="${API_URL}" "$RUNBOOK" \
|
||||
--api-url "${API_URL}" \
|
||||
--client-id "${ok_id}" \
|
||||
--actions "delete" \
|
||||
--force-delete
|
||||
|
||||
echo "[transport_recovery_runbook_smoke] case2: recovery fail-path with diagnostics"
|
||||
env API_URL="${API_URL}" "$RUNBOOK" \
|
||||
--api-url "${API_URL}" \
|
||||
--client-id "${fail_id}" \
|
||||
--kind phoenix \
|
||||
--name "Recovery FAIL ${fail_id}" \
|
||||
--config-json '{"runner":"mock","runtime_mode":"embedded"}' \
|
||||
--actions "create"
|
||||
|
||||
set +e
|
||||
env API_URL="${API_URL}" "$RECOVERY" \
|
||||
--api-url "${API_URL}" \
|
||||
--client-id "${fail_id}" \
|
||||
--max-restarts 1 \
|
||||
--provision-if-needed \
|
||||
--diagnostics-json "$diag_fail"
|
||||
rc=$?
|
||||
set -e
|
||||
if [[ "$rc" -eq 0 ]]; then
|
||||
echo "[transport_recovery_runbook_smoke] expected non-zero for fail-path case" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$rc" -ne 2 ]]; then
|
||||
echo "[transport_recovery_runbook_smoke] expected rc=2 for unrecovered case, got rc=${rc}" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -s "$diag_fail" ]]; then
|
||||
echo "[transport_recovery_runbook_smoke] diagnostics file was not produced: $diag_fail" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
env API_URL="${API_URL}" "$RUNBOOK" \
|
||||
--api-url "${API_URL}" \
|
||||
--client-id "${fail_id}" \
|
||||
--actions "delete" \
|
||||
--force-delete
|
||||
|
||||
echo "[transport_recovery_runbook_smoke] passed"
|
||||
Reference in New Issue
Block a user