feat: initialize independent Sense product skeleton (#21)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$senseRoot = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
|
||||
$serverRoot = Join-Path $senseRoot 'server'
|
||||
$env:SENSE_DATABASE_MODE = 'memory'
|
||||
$env:SENSE_HTTP_ADDRESS = '127.0.0.1:18080'
|
||||
|
||||
$process = Start-Process -FilePath 'go' -ArgumentList @('run', '.') -WorkingDirectory $serverRoot -PassThru -WindowStyle Hidden
|
||||
try {
|
||||
$ready = $false
|
||||
for ($attempt = 0; $attempt -lt 30; $attempt++) {
|
||||
try {
|
||||
$health = Invoke-RestMethod -Uri 'http://127.0.0.1:18080/healthz' -TimeoutSec 1
|
||||
$readiness = Invoke-RestMethod -Uri 'http://127.0.0.1:18080/readyz' -TimeoutSec 1
|
||||
if ($health.status -eq 'ok' -and $readiness.status -eq 'ready') {
|
||||
$ready = $true
|
||||
break
|
||||
}
|
||||
} catch {
|
||||
Start-Sleep -Milliseconds 250
|
||||
}
|
||||
}
|
||||
if (-not $ready) {
|
||||
throw 'Sense smoke server did not become ready.'
|
||||
}
|
||||
|
||||
try {
|
||||
Invoke-WebRequest -Uri 'http://127.0.0.1:18080/api/v1/demo' -TimeoutSec 2 | Out-Null
|
||||
throw 'Disabled demo route unexpectedly returned success.'
|
||||
} catch {
|
||||
if ($_.Exception.Response.StatusCode.value__ -ne 404) { throw }
|
||||
}
|
||||
Write-Output 'Sense independent smoke test passed.'
|
||||
} finally {
|
||||
if (-not $process.HasExited) { Stop-Process -Id $process.Id }
|
||||
$process.WaitForExit()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user