mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
test(multiplayer): cover compose queue lifecycle
This commit is contained in:
@@ -63,6 +63,37 @@ for attempt in $(seq 1 60); do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
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")"
|
||||
queue_body='{"ticket_id":"compose-queue-ticket","playlist":"casual","client_build":"build-1","protocol_version":1}'
|
||||
queue_json="$(curl -fsS -X POST "$api_url/v1/queue" \
|
||||
-H "Authorization: Bearer $access_token" \
|
||||
-H 'Idempotency-Key: compose-queue-key-123456' \
|
||||
-H 'Content-Type: application/json' -d "$queue_body")"
|
||||
queue_revision="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["revision"])' <<<"$queue_json")"
|
||||
[[ "$queue_revision" == 0 ]]
|
||||
|
||||
# Reusing a queue idempotency key with different command material must not
|
||||
# silently turn into a second ticket or a successful replay.
|
||||
conflict_status="$(curl -sS -o /dev/null -w '%{http_code}' -X POST "$api_url/v1/queue" \
|
||||
-H "Authorization: Bearer $access_token" \
|
||||
-H 'Idempotency-Key: compose-queue-key-123456' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"ticket_id":"compose-other-ticket","playlist":"casual","client_build":"build-1","protocol_version":1}')"
|
||||
[[ "$conflict_status" == 409 ]]
|
||||
|
||||
heartbeat_json="$(curl -fsS -X POST "$api_url/v1/queue/compose-queue-ticket/heartbeat" \
|
||||
-H "Authorization: Bearer $access_token" \
|
||||
-H 'Idempotency-Key: compose-heartbeat-key-123456' \
|
||||
-H 'If-Match-Revision: 0')"
|
||||
heartbeat_revision="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["revision"])' <<<"$heartbeat_json")"
|
||||
[[ "$heartbeat_revision" == 1 ]]
|
||||
curl -fsS -o /dev/null -X POST "$api_url/v1/queue/compose-queue-ticket/cancel" \
|
||||
-H "Authorization: Bearer $access_token" \
|
||||
-H 'Idempotency-Key: compose-cancel-key-123456' \
|
||||
-H "If-Match-Revision: $heartbeat_revision"
|
||||
|
||||
# Model the durable state produced by the allocator, then use the real HTTP
|
||||
# workload authentication and mutation boundaries for every action below.
|
||||
"${compose[@]}" exec -T database psql -v ON_ERROR_STOP=1 -U cosmic_clash_test -d cosmic_clash_test <<'SQL'
|
||||
|
||||
Reference in New Issue
Block a user