43 lines
1.6 KiB
PowerShell
43 lines
1.6 KiB
PowerShell
$ErrorActionPreference = "Stop"
|
|
|
|
$repositoryRoot = Split-Path -Parent $PSScriptRoot
|
|
$composeFile = Join-Path $repositoryRoot "deploy/docker-compose.test.yml"
|
|
$composeProject = "proxy-pool-controller-test"
|
|
$previousPostgresURL = [Environment]::GetEnvironmentVariable("PROXY_POOL_TEST_POSTGRES_URL", "Process")
|
|
$previousRedisURL = [Environment]::GetEnvironmentVariable("PROXY_POOL_TEST_REDIS_URL", "Process")
|
|
|
|
try {
|
|
docker compose -p $composeProject -f $composeFile up -d --wait --wait-timeout 60 postgres redis
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "starting Controller test fixtures failed with exit code $LASTEXITCODE"
|
|
}
|
|
|
|
$env:PROXY_POOL_TEST_POSTGRES_URL = "postgres://proxy_pool_test:proxy-pool-test@127.0.0.1:15432/proxy_pool_test?sslmode=disable"
|
|
$env:PROXY_POOL_TEST_REDIS_URL = "redis://127.0.0.1:16379/15"
|
|
Push-Location $repositoryRoot
|
|
try {
|
|
go test -count=1 -tags=integration -timeout 60s ./internal/controller/bootstrap
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Controller integration tests failed with exit code $LASTEXITCODE"
|
|
}
|
|
}
|
|
finally {
|
|
Pop-Location
|
|
}
|
|
}
|
|
finally {
|
|
if ($null -eq $previousPostgresURL) {
|
|
Remove-Item Env:PROXY_POOL_TEST_POSTGRES_URL -ErrorAction SilentlyContinue
|
|
}
|
|
else {
|
|
$env:PROXY_POOL_TEST_POSTGRES_URL = $previousPostgresURL
|
|
}
|
|
if ($null -eq $previousRedisURL) {
|
|
Remove-Item Env:PROXY_POOL_TEST_REDIS_URL -ErrorAction SilentlyContinue
|
|
}
|
|
else {
|
|
$env:PROXY_POOL_TEST_REDIS_URL = $previousRedisURL
|
|
}
|
|
docker compose -p $composeProject -f $composeFile down --volumes --remove-orphans
|
|
}
|