56 lines
1.6 KiB
PowerShell
56 lines
1.6 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
|
|
Write-Host '[AZA] Step 14 - Docker/Compose Smoke'
|
|
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
$composeFile = Join-Path $PSScriptRoot 'docker-compose.yml'
|
|
$baseUrl = 'http://127.0.0.1:8000'
|
|
|
|
if (-not (Test-Path $composeFile)) {
|
|
throw "Compose file not found: $composeFile"
|
|
}
|
|
|
|
# Ensure Docker engine is up
|
|
& (Join-Path $PSScriptRoot 'docker_ensure.ps1')
|
|
|
|
# Bring up containers (build optional; keep it deterministic)
|
|
Write-Host '[AZA] docker compose up -d --build'
|
|
$old = $ErrorActionPreference
|
|
$ErrorActionPreference = 'Continue'
|
|
$out = & docker compose -f $composeFile up -d --build 2>&1
|
|
$code = $LASTEXITCODE
|
|
$ErrorActionPreference = $old
|
|
$out | Out-Host
|
|
if ($code -ne 0) {
|
|
throw "[AZA] FAIL: docker compose up failed (exit=$code)"
|
|
}
|
|
|
|
# Wait for /health
|
|
Write-Host "[AZA] Waiting for health: $baseUrl/health"
|
|
$ok = $false
|
|
for ($i = 0; $i -lt 30; $i++) {
|
|
try {
|
|
$r = Invoke-WebRequest -UseBasicParsing -Uri ($baseUrl + '/health') -TimeoutSec 3
|
|
if ($r.StatusCode -eq 200) { $ok = $true; break }
|
|
} catch {
|
|
Start-Sleep -Seconds 2
|
|
}
|
|
}
|
|
if (-not $ok) {
|
|
throw '[AZA] FAIL: /health did not return 200 within timeout.'
|
|
}
|
|
Write-Host '[AZA] OK: /health 200'
|
|
|
|
# Run smoke suite (reuses deploy/.env for tokens)
|
|
Write-Host '[AZA] Running smoke_suite.ps1'
|
|
# IMPORTANT:
|
|
# smoke_suite.ps1 expects EnvFile as .\deploy\.env (relative to repo root).
|
|
# If we run it from the deploy folder, it will look for .\deploy\deploy\.env and miss tokens.
|
|
Push-Location $root
|
|
try {
|
|
& powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot 'smoke_suite.ps1') -BaseUrl $baseUrl
|
|
} finally {
|
|
Pop-Location
|
|
}
|
|
|