mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
fix(multiplayer): deploy reconnect abandonment maintenance
This commit is contained in:
@@ -63,6 +63,26 @@ for attempt in $(seq 1 60); do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# The deployed maintenance service owns the ranked reconnect deadline. Seed an
|
||||
# already-expired durable lease and require the real Compose process to record
|
||||
# its cooldown before exercising the rest of the allocation flow.
|
||||
"${compose[@]}" exec -T database psql -v ON_ERROR_STOP=1 -U cosmic_clash_test -d cosmic_clash_test <<'SQL'
|
||||
INSERT INTO identities (player_id, steam_id) VALUES ('compose-abandon-player', 'compose-abandon-steam');
|
||||
INSERT INTO queue_tickets (ticket_id, player_id, playlist, state, client_build, protocol_version, enqueued_at, expires_at)
|
||||
VALUES ('compose-abandon-ticket', 'compose-abandon-player', 'ranked', 'LIVE', 'build-1', 1, now() - interval '2 minutes', now() + interval '1 hour');
|
||||
INSERT INTO matches (match_id, playlist, state, region, protocol_version, server_id)
|
||||
VALUES ('compose-abandon-match', 'ranked', 'LIVE', 'EU', 1, 'compose-abandon-server');
|
||||
INSERT INTO match_participants (match_id, player_id, ticket_id, slot, team, connection_generation, connected_at, disconnected_at)
|
||||
VALUES ('compose-abandon-match', 'compose-abandon-player', 'compose-abandon-ticket', 0, 0, 1, now() - interval '2 minutes', now() - interval '61 seconds');
|
||||
SQL
|
||||
for attempt in $(seq 1 30); do
|
||||
abandoned="$(${compose[@]} exec -T database psql -At -U cosmic_clash_test -d cosmic_clash_test -c "SELECT count(*) FROM match_participants WHERE match_id = 'compose-abandon-match' AND abandoned_at IS NOT NULL" | tr -d '\r')"
|
||||
[[ "$abandoned" == 1 ]] && break
|
||||
[[ "$attempt" == 30 ]] && { "${compose[@]}" logs maintenance >&2; echo "maintenance did not record an expired ranked reconnect lease" >&2; exit 1; }
|
||||
sleep 1
|
||||
done
|
||||
"${compose[@]}" exec -T database psql -At -U cosmic_clash_test -d cosmic_clash_test -c "SELECT count(*) FROM penalties WHERE match_id = 'compose-abandon-match' AND kind = 'MATCH_ABANDONED'" | grep -qx 1
|
||||
|
||||
session_json="$(curl -fsS -X POST "$api_url/v1/session/steam" \
|
||||
-H 'Content-Type: application/json' -d '{"web_api_ticket":"compose-queue-ticket"}')"
|
||||
access_token="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["access_token"])' <<<"$session_json")"
|
||||
|
||||
Reference in New Issue
Block a user