param([string]$PythonCommand = 'py') $ErrorActionPreference = 'Stop' Push-Location (Split-Path $PSScriptRoot -Parent) $containerId = $null try { # An extra temporary API shares PostgreSQL but issues only two-second sessions. # The main API and its existing sessions are not reconfigured. $containerId = docker compose run -d --rm --no-deps -p 127.0.0.1:18083:8080 -e SESSION_TTL_SECONDS=2 api if ($LASTEXITCODE -ne 0) { throw 'Temporary API failed to start' } $ready = $false for ($i=0; $i -lt 30; $i++) { try { $null = Invoke-RestMethod http://127.0.0.1:18083/health/ready -TimeoutSec 2 $ready = $true break } catch { Start-Sleep -Milliseconds 500 } } if (-not $ready) { throw 'Temporary API not ready' } & $PythonCommand -X utf8 student-tests/check.py --base-url http://127.0.0.1:18083 --expiry if ($LASTEXITCODE -ne 0) { throw 'Expiry test failed' } } finally { if ($containerId) { docker stop $containerId | Out-Null } Pop-Location }