CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 17s
CI / Test (jest) (push) Successful in 18s
CI / Security (npm audit) (push) Successful in 9s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m2s
CI / Integration (api) (push) Successful in 2m31s
CI / Lint (eslint) (pull_request) Successful in 16s
CI / Test (jest) (pull_request) Successful in 15s
CI / Security (npm audit) (pull_request) Successful in 7s
CI / UI (playwright) (push) Successful in 1m39s
CI / Deploy (push) Skipped
CI / Deploy worker (push) Skipped
CI / Notify (push) Skipped
CI / Integration (api) (pull_request) Successful in 1m51s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 1m24s
CI / UI screenshots (before/after) (pull_request) Successful in 6s
CI / UI (playwright) (pull_request) Successful in 2m21s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
- workflows.int.js (11): all-worker execute, failure stops the workflow, parse to route, false conditions skip, prompts (invalid option refused, routes on the answer), params (required, substituted, unsafe refused), dry run, endless goto detection, abort stays failed. - scheduler.int.js (5): a due schedule runs on its worker and advances next_run; disabled schedules don't run; admin-only and input checks. - Known bugs as test.failing (each verified to fail on its assertion): abort doesn't stop the engine (#8), goto to a missing step completes (#20), an offline worker's schedule leaves no trace (#9), and an invalid cron expression returns 500 instead of 400. - PULSE_SCHEDULER_TICK_MS (default 60 s, minimum 1 s) so the test stack ticks the scheduler every second. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
2.9 KiB
Bash
Executable File
80 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# Starts a throwaway Pulse stack for the integration and Playwright UI tests (#45):
|
|
# the server on PULSE_UI_PORT plus three local workers (node-01..03) that run
|
|
# real, harmless commands. The database must already exist; the server creates
|
|
# its tables on start.
|
|
#
|
|
# Used by the CI `ui` job (MariaDB service container) and locally:
|
|
# DB_HOST=127.0.0.1 DB_PORT=3399 DB_USER=pulse DB_PASSWORD=x DB_NAME=pulse \
|
|
# scripts/ci/ui-stack.sh start
|
|
# npm run test:ui
|
|
# scripts/ci/ui-stack.sh stop
|
|
#
|
|
# Every setting is passed explicitly, so a developer's .env never leaks in
|
|
# (dotenv does not override variables that are already set).
|
|
set -euo pipefail
|
|
|
|
ROOT=$(cd "$(dirname "$0")/../.." && pwd)
|
|
PORT=${PULSE_UI_PORT:-8400}
|
|
RUN=${PULSE_UI_RUN_DIR:-$ROOT/.ui-stack}
|
|
URL="http://127.0.0.1:$PORT"
|
|
|
|
export PORT HOST=127.0.0.1 NODE_ENV=test
|
|
export TRUSTED_PROXIES=127.0.0.1 # the tests send Authelia headers themselves
|
|
export WORKER_API_KEY=ui-test-worker-key WORKER_AUTH_ENFORCE=1
|
|
export GANDALF_API_KEY=ui-test-gandalf-key
|
|
export SECRET_KEY=ui-test-secret EXECUTION_RETENTION_DAYS=30
|
|
export PULSE_API_RATE_MAX=100000 PULSE_EXEC_RATE_MAX=100000 # one test client makes many requests
|
|
export PULSE_SCHEDULER_TICK_MS=1000 # scheduler tests shouldn't wait a minute
|
|
|
|
stop() {
|
|
for f in "$RUN"/*.pid; do
|
|
[ -e "$f" ] || continue
|
|
kill "$(cat "$f")" 2>/dev/null || true
|
|
rm -f "$f"
|
|
done
|
|
}
|
|
|
|
wait_for() { # wait_for <description> <seconds> <command...>
|
|
local what=$1 secs=$2; shift 2
|
|
for _ in $(seq 1 "$secs"); do
|
|
if "$@" >/dev/null 2>&1; then return 0; fi
|
|
sleep 1
|
|
done
|
|
echo "::error::timed out waiting for $what" >&2
|
|
tail -n 50 "$RUN"/*.log >&2 || true
|
|
return 1
|
|
}
|
|
|
|
# Node's fetch instead of curl: the Playwright CI image has node but maybe not curl.
|
|
healthz() { # healthz [<javascript test on the parsed body>]
|
|
node -e 'fetch(process.argv[1]).then(r => r.json()).then(h => process.exit(h.db && eval(process.argv[2] || "true") ? 0 : 1), () => process.exit(1))' \
|
|
"$URL/healthz" "${1:-true}"
|
|
}
|
|
workers_online() { healthz 'h.workers === 3'; }
|
|
|
|
start() {
|
|
: "${DB_HOST:?}" "${DB_PORT:?}" "${DB_USER:?}" "${DB_PASSWORD:?}" "${DB_NAME:?}"
|
|
export DB_HOST DB_PORT DB_USER DB_PASSWORD DB_NAME
|
|
stop
|
|
mkdir -p "$RUN"
|
|
# cwd is the run dir, so dotenv finds no .env there.
|
|
(cd "$RUN" && exec node "$ROOT/server.js" >"$RUN/server.log" 2>&1) &
|
|
echo $! >"$RUN/server.pid"
|
|
wait_for "the server and database" 60 healthz
|
|
|
|
for n in 1 2 3; do
|
|
(cd "$RUN" && WORKER_NAME=node-0$n PULSE_SERVER="$URL" PULSE_WS="ws://127.0.0.1:$PORT" \
|
|
HEARTBEAT_INTERVAL=5 exec node "$ROOT/worker/worker.js" >"$RUN/worker-$n.log" 2>&1) &
|
|
echo $! >"$RUN/worker-$n.pid"
|
|
done
|
|
wait_for "3 workers to connect" 60 workers_online
|
|
echo "Pulse UI stack is up at $URL with 3 workers"
|
|
}
|
|
|
|
case "${1:-}" in
|
|
start) start ;;
|
|
stop) stop ;;
|
|
*) echo "usage: $0 start|stop" >&2; exit 2 ;;
|
|
esac
|