load-test-realtime-subs.sh50 lines · main
| 1 | #!/usr/bin/env bash |
| 2 | # Realtime-subscriptions load test runner. |
| 3 | # |
| 4 | # Wraps infra/load-tests/realtime-subs.ts with sensible defaults so the |
| 5 | # Phase 2 exit criterion (1,000 concurrent subs on KVM4 with p99 fan-out |
| 6 | # under 500ms, zero connection failures) can be exercised with one |
| 7 | # command. Writes the run summary to ./tmp/load-tests/<utc-timestamp>.txt |
| 8 | # so subsequent runs are comparable. |
| 9 | # |
| 10 | # Required env: |
| 11 | # BRIVEN_RUNTIME_SHARED_SECRET — the shared secret the realtime |
| 12 | # service expects on subscribe; see infra/dokploy/.env on the host. |
| 13 | # BRIVEN_LOAD_TEST_PROJECT_ID — the project to fan out to. |
| 14 | # BRIVEN_LOAD_TEST_FUNCTION — a deployed function name (any cheap one). |
| 15 | # |
| 16 | # Optional: |
| 17 | # BRIVEN_LOAD_TEST_URL — wss URL. Defaults to wss://realtime.briven.tech. |
| 18 | # BRIVEN_LOAD_TEST_SUBS — concurrent connection count. Default 1000. |
| 19 | # BRIVEN_LOAD_TEST_DURATION — seconds to hold. Default 60. |
| 20 | |
| 21 | set -euo pipefail |
| 22 | |
| 23 | : "${BRIVEN_RUNTIME_SHARED_SECRET:?env required}" |
| 24 | : "${BRIVEN_LOAD_TEST_PROJECT_ID:?env required}" |
| 25 | : "${BRIVEN_LOAD_TEST_FUNCTION:?env required}" |
| 26 | |
| 27 | URL="${BRIVEN_LOAD_TEST_URL:-wss://realtime.briven.tech}" |
| 28 | SUBS="${BRIVEN_LOAD_TEST_SUBS:-1000}" |
| 29 | DURATION="${BRIVEN_LOAD_TEST_DURATION:-60}" |
| 30 | |
| 31 | OUT_DIR="tmp/load-tests" |
| 32 | mkdir -p "$OUT_DIR" |
| 33 | STAMP="$(date -u +%Y%m%dT%H%M%SZ)" |
| 34 | OUT_FILE="$OUT_DIR/${STAMP}.txt" |
| 35 | |
| 36 | echo "running: $SUBS subs against $URL for ${DURATION}s" |
| 37 | echo "output: $OUT_FILE" |
| 38 | echo |
| 39 | |
| 40 | bun run infra/load-tests/realtime-subs.ts \ |
| 41 | --url "$URL" \ |
| 42 | --secret "$BRIVEN_RUNTIME_SHARED_SECRET" \ |
| 43 | --project "$BRIVEN_LOAD_TEST_PROJECT_ID" \ |
| 44 | --function "$BRIVEN_LOAD_TEST_FUNCTION" \ |
| 45 | --subs "$SUBS" \ |
| 46 | --duration "$DURATION" \ |
| 47 | 2>&1 | tee "$OUT_FILE" |
| 48 | |
| 49 | echo |
| 50 | echo "summary saved to $OUT_FILE" |