mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-04 06:12:10 +03:00
A base tinha base-red sistêmica herdada de PRs de outras sessões, bloqueando TODOS os PRs do ciclo (o TIA roda a suíte full em fail-safe p/ diffs hub). 4 Fast Quality Gates: - test-discovery (#4877): live-server-allowlist.test.ts em tests/unit/server/ (não-coletado) + vitest → nunca rodava. Convertido p/ node:test em tests/unit/security/. - any-budget:t11 (#4664): 3 explicit-any em tokenRefresh.ts tipados (sem crescer file-size). - docs-symbols (#4868): rotas inexistentes → /api/system/version e PUT /api/providers/{id} {isActive:false}. - docs-all fabricated-claim (#4868 + #4718): 5 bin/*.sh reais criados (rollback, snapshot-data, restore-data, restore-policies, cold-start-bench) + _ops-common.sh (snapshot VACUUM INTO, guards de confirmação/TTY, testes de contrato); NODE_EXTRA_CA_CERTS (env de runtime Node) na allowlist do checker. 7 testes unit base-red (de features alheias à quota): - oauth-providers-config (#4664): teste alinhado ao provider codebuddy-cn do registry. - antigravity-model-aliases (#4636): maxOutputTokens esperado 32769→16384 (cap intencional). - provider-request-capture #4091 (#4861): exemplo do teste trocado de mcp__ (que #4861 isenta de cloak por causa dos 400s de assimetria de histórico) para um tool de terceiro cloakável — preserva o invariante de #4091 SEM reverter #4861. - combo-error-response: convertido de vitest p/ node:test (era coletado pelo glob node:test e crashava); api/** e server/** removidos do vitest.config (config morta). Build MDX (dast-smoke, #4679): - docs/ops/RELEASE_GREEN.md não tinha frontmatter `title` → fumadocs-mdx rejeitava no webpack compile ("invalid frontmatter: title expected string"), quebrando o next build (e o deploy). Frontmatter title adicionado (único doc do collection sem ele). 17/17 Fast Quality Gates + suíte unit completa (17737 testes, 0 fail) + vitest verdes localmente. Co-authored-by: Diego Rodrigues de Sa e Souza <souzamiriamrodrigues790@gmail.com>
83 lines
3.2 KiB
Bash
Executable File
83 lines
3.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# bin/cold-start-bench.sh — measure OmniRoute cold-start against the budgets in
|
|
# docs/PERF_BUDGETS.md §5 (container start → HTTP listening ≤ 800 ms; first warm
|
|
# TTFB ≤ 200 ms). Boots the server on a throwaway port, times until
|
|
# /api/health/ping answers 200, measures a warm request, and reports PASS/FAIL.
|
|
set -euo pipefail
|
|
SCRIPT_NAME="cold-start-bench"
|
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_ops-common.sh"
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Usage: bin/cold-start-bench.sh [--port <n>] [--start-cmd "<cmd>"] [--url <base>]
|
|
[--listen-budget-ms <n>] [--ttfb-budget-ms <n>] [-h|--help]
|
|
|
|
Boots OmniRoute, times cold-start to the first /api/health/ping 200, measures
|
|
warm TTFB, and compares against the PERF_BUDGETS.md §5 budgets
|
|
(listen ≤ 800 ms, TTFB ≤ 200 ms). Exits non-zero if a budget is exceeded.
|
|
|
|
--url benches an already-running server instead of booting one (skips the boot
|
|
timing; only TTFB is measured).
|
|
EOF
|
|
}
|
|
|
|
PORT="${PORT:-21987}"
|
|
START_CMD=""
|
|
BASE_URL=""
|
|
LISTEN_BUDGET_MS=800
|
|
TTFB_BUDGET_MS=200
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
--port) PORT="${2:?--port needs a value}"; shift 2 ;;
|
|
--start-cmd) START_CMD="${2:?--start-cmd needs a value}"; shift 2 ;;
|
|
--url) BASE_URL="${2:?--url needs a value}"; shift 2 ;;
|
|
--listen-budget-ms) LISTEN_BUDGET_MS="${2:?}"; shift 2 ;;
|
|
--ttfb-budget-ms) TTFB_BUDGET_MS="${2:?}"; shift 2 ;;
|
|
-h | --help) usage; exit 0 ;;
|
|
*) ops_die "unknown argument: $1 (see --help)" ;;
|
|
esac
|
|
done
|
|
|
|
ops_require_cmd curl
|
|
|
|
now_ms() { date +%s%3N; } # ms since epoch (GNU date / Linux)
|
|
ping_ok() { curl -fsS -o /dev/null --max-time 2 "$1/api/health/ping" 2>/dev/null; }
|
|
|
|
SERVER_PID=""
|
|
cleanup() { [ -n "$SERVER_PID" ] && kill "$SERVER_PID" 2>/dev/null || true; }
|
|
trap cleanup EXIT
|
|
|
|
if [ -n "$BASE_URL" ]; then
|
|
ops_log "benching already-running server at $BASE_URL (boot timing skipped)"
|
|
listen_ms=""
|
|
else
|
|
BASE_URL="http://127.0.0.1:$PORT"
|
|
[ -n "$START_CMD" ] || START_CMD="npm start -- --port $PORT"
|
|
ops_log "booting: $START_CMD"
|
|
start_ms="$(now_ms)"
|
|
# shellcheck disable=SC2086
|
|
PORT="$PORT" $START_CMD >/tmp/omniroute-coldstart.log 2>&1 &
|
|
SERVER_PID="$!"
|
|
deadline=$(($(now_ms) + 30000))
|
|
until ping_ok "$BASE_URL"; do
|
|
kill -0 "$SERVER_PID" 2>/dev/null || ops_die "server process exited during boot (see /tmp/omniroute-coldstart.log)"
|
|
[ "$(now_ms)" -gt "$deadline" ] && ops_die "server did not answer /api/health/ping within 30s"
|
|
sleep 0.05
|
|
done
|
|
listen_ms=$(($(now_ms) - start_ms))
|
|
fi
|
|
|
|
ping_ok "$BASE_URL" || ops_die "server at $BASE_URL is not answering /api/health/ping"
|
|
ttfb_ms="$(curl -fsS -o /dev/null -w '%{time_starttransfer}' "$BASE_URL/api/health/ping" | awk '{printf "%d", $1 * 1000}')"
|
|
|
|
fail=0
|
|
if [ -n "$listen_ms" ]; then
|
|
echo "cold-start (start → listening): ${listen_ms} ms (budget ${LISTEN_BUDGET_MS} ms)"
|
|
[ "$listen_ms" -le "$LISTEN_BUDGET_MS" ] || { echo "FAIL: listen budget exceeded"; fail=1; }
|
|
fi
|
|
echo "warm TTFB: ${ttfb_ms} ms (budget ${TTFB_BUDGET_MS} ms)"
|
|
[ "$ttfb_ms" -le "$TTFB_BUDGET_MS" ] || { echo "FAIL: TTFB budget exceeded"; fail=1; }
|
|
[ "$fail" -eq 0 ] && echo "PASS: within cold-start budgets"
|
|
exit "$fail"
|