Ship live alerts, pool status, AI monitor, remote agent commands, build manager, and uninstall flow; wire Calibrate settings (WS ping, pool traffic log, retention limits) at runtime and exclude server/data from git.
110 lines
3.8 KiB
PowerShell
110 lines
3.8 KiB
PowerShell
# AetherForge API smoke tests — B-01 through B-10 matrix
|
|
param(
|
|
[string]$BaseUrl = "http://localhost:8989"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$passed = 0
|
|
$failed = 0
|
|
$results = @()
|
|
|
|
function Invoke-SmokeTest {
|
|
param(
|
|
[string]$TestId,
|
|
[string]$TestName,
|
|
[scriptblock]$Block
|
|
)
|
|
try {
|
|
& $Block
|
|
$script:passed++
|
|
$script:results += [pscustomobject]@{ ID = $TestId; Name = $TestName; Status = "PASS" }
|
|
Write-Host "[PASS] $TestId $TestName" -ForegroundColor Green
|
|
} catch {
|
|
$script:failed++
|
|
$msg = $_.Exception.Message
|
|
$script:results += [pscustomobject]@{ ID = $TestId; Name = $TestName; Status = "FAIL"; Detail = $msg }
|
|
Write-Host "[FAIL] $TestId $TestName - $msg" -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
Invoke-SmokeTest "B-01" "GET /health" {
|
|
$r = Invoke-RestMethod "$BaseUrl/api/v1/health"
|
|
if ($r.status -ne "ok") { throw "unexpected status" }
|
|
}
|
|
|
|
Invoke-SmokeTest "B-02" "GET /server/info" {
|
|
$r = Invoke-RestMethod "$BaseUrl/api/v1/server/info"
|
|
if (-not $r.local_ips) { throw "missing local_ips" }
|
|
}
|
|
|
|
Invoke-SmokeTest "B-03" "GET/PUT /config round-trip" {
|
|
$cfg = Invoke-RestMethod "$BaseUrl/api/v1/config"
|
|
$sub = "smoke-test-$(Get-Date -Format 'HHmmss')"
|
|
$cfg.server.dashboard_subtitle = $sub
|
|
$body = $cfg | ConvertTo-Json -Depth 10
|
|
Invoke-RestMethod "$BaseUrl/api/v1/config" -Method Put -Body $body -ContentType "application/json" | Out-Null
|
|
$cfg2 = Invoke-RestMethod "$BaseUrl/api/v1/config"
|
|
if ($cfg2.server.dashboard_subtitle -ne $sub) { throw "subtitle not persisted" }
|
|
}
|
|
|
|
Invoke-SmokeTest "B-04" "GET /builds list" {
|
|
$null = Invoke-RestMethod "$BaseUrl/api/v1/builds"
|
|
}
|
|
|
|
Invoke-SmokeTest "B-05" "GET /alerts" {
|
|
$null = Invoke-RestMethod "$BaseUrl/api/v1/alerts"
|
|
}
|
|
|
|
Invoke-SmokeTest "B-06" "Blueprint CRUD" {
|
|
$name = "smoke-blueprint-$(Get-Date -Format 'HHmmss')"
|
|
$payload = @{ name = $name; data = @{ worker_name = "smoke"; wallet = "4test" } } | ConvertTo-Json -Depth 5
|
|
Invoke-RestMethod "$BaseUrl/api/v1/blueprints" -Method Post -Body $payload -ContentType "application/json" | Out-Null
|
|
$list = Invoke-RestMethod "$BaseUrl/api/v1/blueprints"
|
|
if (-not ($list | Where-Object { $_.name -eq $name })) { throw "blueprint not listed" }
|
|
Invoke-RestMethod "$BaseUrl/api/v1/blueprints?name=$name" -Method Delete | Out-Null
|
|
}
|
|
|
|
Invoke-SmokeTest "B-07" "POST /agent/decide" {
|
|
$body = @{
|
|
agent_id = "smoke-agent"
|
|
worker_name = "smoke"
|
|
hostname = "smoke-pc"
|
|
uptime_seconds = 60
|
|
is_running = $true
|
|
cpu_cores = 4
|
|
cpu_usage_pct = 10
|
|
memory_gb = 8
|
|
memory_usage_pct = 20
|
|
hashrate_15m = 100
|
|
shares_total = 0
|
|
shares_good = 0
|
|
shares_bad = 0
|
|
} | ConvertTo-Json -Depth 5
|
|
try {
|
|
Invoke-RestMethod "$BaseUrl/api/v1/agent/decide" -Method Post -Body $body -ContentType "application/json" | Out-Null
|
|
} catch {
|
|
if ($_.Exception.Response.StatusCode.value__ -ge 500) { throw $_ }
|
|
}
|
|
}
|
|
|
|
Invoke-SmokeTest "B-08" "POST /agent/report array" {
|
|
$body = '[{"agent_id":"smoke-agent","tool":"sleep","success":true,"output":"ok"}]'
|
|
$r = Invoke-RestMethod "$BaseUrl/api/v1/agent/report" -Method Post -Body $body -ContentType "application/json"
|
|
if (-not $r.success) { throw "report not accepted" }
|
|
}
|
|
|
|
Invoke-SmokeTest "B-09" "GET /pools/status + /ai/activity" {
|
|
$null = Invoke-RestMethod "$BaseUrl/api/v1/pools/status"
|
|
$null = Invoke-RestMethod "$BaseUrl/api/v1/ai/activity"
|
|
}
|
|
|
|
Invoke-SmokeTest "B-10" "GET /agents + /dashboard/stats" {
|
|
$null = Invoke-RestMethod "$BaseUrl/api/v1/agents"
|
|
$null = Invoke-RestMethod "$BaseUrl/api/v1/dashboard/stats"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "Smoke summary: $passed passed, $failed failed" -ForegroundColor Cyan
|
|
$results | Format-Table -AutoSize
|
|
if ($failed -gt 0) { exit 1 }
|