1 #!/bin/bash
2 # Integration test runner for the morly relay.
3 #
4 # The layer above `make test-unit`: a real relay process, driven over HTTP and
5 # WebSocket. It needs no browser and no frontend build.
6 #
7 # Usage:
8 # ./test/run.sh # all integration tests
9 # ./test/run.sh --build # rebuild the relay first
10 # ./test/run.sh -k policy # only the policy tests
11 # ./test/run.sh -k roundtrip -v # verbose round-trip tests
12 #
13 # Prerequisites:
14 # pip install pytest websocket-client
15 #
16 # ORLY_STATIC_DIR points the relay at a frontend build (for the static-file
17 # checks); unset, they are not in play. stress_metrics.py is a separate load
18 # driver, not part of pytest - run it directly against a running relay.
19 20 set -euo pipefail
21 22 cd "$(dirname "$0")/.."
23 ROOT="$PWD"
24 MORLY_RELAY_BIN="${MORLY_RELAY_BIN:-$ROOT/morly}"
25 26 BUILD=false
27 PYTEST_ARGS=()
28 29 for arg in "$@"; do
30 case "$arg" in
31 --build) BUILD=true ;;
32 *) PYTEST_ARGS+=("$arg") ;;
33 esac
34 done
35 36 if $BUILD; then
37 make build
38 fi
39 40 if [ ! -x "$MORLY_RELAY_BIN" ]; then
41 echo "error: relay binary not found at $MORLY_RELAY_BIN. Run with --build or: make build" >&2
42 exit 1
43 fi
44 45 # A leftover store makes startup slower than the fixture's readiness wait and
46 # leaves tests reading events an earlier run wrote.
47 rm -rf /tmp/morly-test-data
48 49 exec env MORLY_RELAY_BIN="$MORLY_RELAY_BIN" \
50 python3 -m pytest test/ \
51 --tb=short \
52 "${PYTEST_ARGS[@]}"
53