Files
mtusi2026lab2/scripts/check-expiry.ps1
T
SashaKirupina 0c179a44a3
Skeleton contracts / contracts (pull_request) Canceled after 0s
ЛР 2 — БПИ2304 — Кирюпина — на 3
2026-11-05 13:46:46 +03:00

25 lines
1.0 KiB
PowerShell

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
}