test(multiplayer): verify live assignment delivery

This commit is contained in:
Josh Creek
2026-09-01 15:25:36 +01:00
parent 79a6092b28
commit f096e8ff0b
5 changed files with 59 additions and 5 deletions
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail
# Assignment-specific variant of the real control-plane integration gate.
# It reuses the isolated PostgreSQL + testkit API fixture, but seeds a
# player-scoped assignment and drives the authenticated Godot assignment read.
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$root_dir"
ASSIGNMENT_SMOKE=1 bash scripts/verify_control_plane_integration.sh
+27 -2
View File
@@ -28,6 +28,7 @@ password="cosmic_clash_test"
pg_port="55434"
api_port="18099"
logs_dir="$(mktemp -d "${TMPDIR:-/tmp}/cosmic-clash-control-plane.XXXXXX")"
assignment_smoke="${ASSIGNMENT_SMOKE:-0}"
testkit_pid=""
cleanup() {
@@ -92,8 +93,32 @@ for attempt in $(seq 1 30); do
sleep 1
done
"$godot_bin" --headless --path Game res://tests/control_plane_smoke.tscn -- \
--control-plane-url="http://127.0.0.1:${api_port}" \
godot_args=(--control-plane-url="http://127.0.0.1:${api_port}")
if [ "$assignment_smoke" = "1" ]; then
# Seed one complete, player-scoped assignment behind the real API. The fake
# Steam provider derives the player ID from the supplied ticket, so this
# still exercises authenticated ownership and the PostgreSQL assignment
# adapter; no session or assignment state is injected into Godot.
assignment_ticket="assignment-smoke-web-api-ticket"
assignment_player_id="testkit-$(printf '%s' "$assignment_ticket" | shasum -a 256 | awk '{print substr($1,1,16)}')"
docker exec "$container_name" psql -v ON_ERROR_STOP=1 -U "$user" -d "$database" -c "
INSERT INTO identities (player_id, steam_id) VALUES ('$assignment_player_id', 'assignment-smoke-steam') ON CONFLICT (player_id) DO NOTHING;
INSERT INTO queue_tickets (ticket_id, player_id, playlist, state, client_build, protocol_version, enqueued_at, expires_at, revision)
VALUES ('assignment-smoke-ticket', '$assignment_player_id', 'casual', 'ASSIGNMENT_READY', 'smoke-build', 1, now(), now() + interval '1 hour', 1)
ON CONFLICT (ticket_id) DO NOTHING;
INSERT INTO matches (match_id, playlist, state, region, protocol_version, server_id, revision)
VALUES ('assignment-smoke-match', 'casual', 'ASSIGNMENT_READY', 'EU', 1, 'assignment-smoke-server', 1)
ON CONFLICT (match_id) DO NOTHING;
INSERT INTO match_participants (match_id, player_id, ticket_id, slot, team)
VALUES ('assignment-smoke-match', '$assignment_player_id', 'assignment-smoke-ticket', 0, 0)
ON CONFLICT (match_id, player_id) DO NOTHING;
INSERT INTO assignments (match_id, player_id, allocation_id, server_id, slot, region, client_build, protocol_version, transport, endpoint, join_authorisation, manifest_digest, expires_at, revision)
VALUES ('assignment-smoke-match', '$assignment_player_id', 'assignment-smoke-allocation', 'assignment-smoke-server', 0, 'EU', 'smoke-build', 1, 'enet', '127.0.0.1:30001', 'assignment-smoke-join-authorisation', decode('000102030405060708090a0b0c0d0e0f', 'hex'), now() + interval '1 hour', 1)
ON CONFLICT (match_id, player_id) DO NOTHING;"
godot_args+=(--assignment-match-id="assignment-smoke-match" --steam-ticket="$assignment_ticket")
fi
"$godot_bin" --headless --path Game res://tests/control_plane_smoke.tscn -- "${godot_args[@]}" \
>"$logs_dir/godot-client.log" 2>&1
status=$?