scopedvr-map-editor/tests/run_server_sektion_e2e.sh
2026-10-31 00:08:06 +01:00

53 lines
2 KiB
Bash
Executable file

#!/usr/bin/env bash
# E2E Server-Sektion: echter Match-Server (Admin-API an, kein Master) + das echte
# Editor-Panel (tests/server_sektion_e2e.gd). Environment: GODOT, MATCH_DIR
# (Default ../scopedvr-match-server), SRV_ADMIN_PORT (24591), SRV_GAME_PORT (24593).
set -u
GODOT="${GODOT:-/home/slyphax/godot/Godot_v4.7.2-stable_linux.x86_64}"
EDITOR_DIR="$(cd "$(dirname "$0")/.." && pwd)"
MATCH_DIR="${MATCH_DIR:-$(dirname "$EDITOR_DIR")/scopedvr-match-server}"
APORT="${SRV_ADMIN_PORT:-24591}"
GPORT="${SRV_GAME_PORT:-24593}"
export GODOT_SILENCE_ROOT_WARNING=1
LOGDIR="/tmp/svr_sektion_logs_$$"
mkdir -p "$LOGDIR/maps"
TOKEN="e2e$(head -c 12 /dev/urandom | od -An -tx1 | tr -d ' \n')"
"$GODOT" --headless --path "$MATCH_DIR" --import > "$LOGDIR/import_match.log" 2>&1
"$GODOT" --headless --path "$EDITOR_DIR" --import > "$LOGDIR/import_editor.log" 2>&1
cat > "$LOGDIR/admin.cfg" <<EOC
[server]
port=$GPORT
server_name="Admin E2E"
max_players=4
[match]
match_duration_seconds=300
team_size=4
scoreboard_seconds=1
[rotation]
maps="res://maps/testmap.tscn"
[master]
master_host=""
[admin]
enabled=true
bind="127.0.0.1"
port=$APORT
state_file="$LOGDIR/admin_state.cfg"
maps_dir="$LOGDIR/maps"
max_upload_mb=20
EOC
# Über das Start-Skript: der Neustart-Test braucht jemanden, der den Server wieder startet.
GODOT="$GODOT" MATCHD_ADMIN_TOKEN="$TOKEN" "$MATCH_DIR/tools/start_server.sh" --config "$LOGDIR/admin.cfg" > "$LOGDIR/server.log" 2>&1 &
SPID=$!
for i in $(seq 1 30); do grep -q "API lauscht" "$LOGDIR/server.log" 2>/dev/null && break; sleep 1; done
sleep 2
SRV_PORT="$APORT" SRV_TOKEN="$TOKEN" SRV_SVMAP="$MATCH_DIR/maps/example_valley.svmap" \
"$GODOT" --headless --path "$EDITOR_DIR" -s res://tests/server_sektion_e2e.gd 2>&1 | tee "$LOGDIR/editor.log" | grep -E "^ (ok|FAIL)|CHECKS|SCRIPT ERROR"
rc=${PIPESTATUS[0]}
kill "$SPID" 2>/dev/null; pkill -f -- "--config $LOGDIR/admin.cfg" 2>/dev/null; wait 2>/dev/null
grep -q "$TOKEN" "$LOGDIR/editor.log" && { echo "FAIL: Token im Editor-Log"; rc=1; } || echo "PASS: Token nicht im Editor-Log"
echo "--- Logs: $LOGDIR ---"
exit "$rc"