-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_full_flow.ps1
More file actions
65 lines (51 loc) · 1.98 KB
/
Copy pathrun_full_flow.ps1
File metadata and controls
65 lines (51 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
param(
[string]$BaseUrl = "http://localhost:8010"
)
$ErrorActionPreference = "Stop"
Write-Host "=== QoD Full Flow Smoke Test ==="
function Invoke-JsonPost {
param(
[string]$Url,
[object]$Body
)
$json = $Body | ConvertTo-Json -Compress -Depth 10
return Invoke-RestMethod -Method Post -Uri $Url -ContentType "application/json" -Body $json
}
# 1) Readiness check
$ready = Invoke-RestMethod -Method Get -Uri "$BaseUrl/ready"
if ($ready.status -ne "ok") { throw "Ready check failed: $($ready | ConvertTo-Json -Compress)" }
Write-Host "Ready OK"
# 2) Create intent
$intentBody = @{
text = "smoke test run"
target_p95_latency_ms = 120
target_jitter_ms = 10
duration_s = 60
flow_label = "smoke-flow"
}
$intentResp = Invoke-JsonPost -Url "$BaseUrl/intent" -Body $intentBody
$SID = $intentResp.session_id
if ([string]::IsNullOrWhiteSpace($SID)) { throw "No session_id returned from /intent. Response: $($intentResp | ConvertTo-Json -Compress)" }
Write-Host "Session created: $SID"
# 3) Post telemetry
$telemetryBody = @{
session_id = $SID
n = 100
p50_ms = 40
p95_ms = 120
jitter_ms = 8
notes = "smoke telemetry"
}
$telemetryResp = Invoke-JsonPost -Url "$BaseUrl/telemetry" -Body $telemetryBody
if ($telemetryResp.status -ne "stored") { throw "Telemetry not stored. Response: $($telemetryResp | ConvertTo-Json -Compress)" }
Write-Host "Telemetry stored"
# 4) Finalize proof
$finalResp = Invoke-RestMethod -Method Post -Uri "$BaseUrl/proof/$SID/finalize"
if ([string]::IsNullOrWhiteSpace($finalResp.this_hash)) { throw "Proof missing this_hash. Response: $($finalResp | ConvertTo-Json -Compress)" }
Write-Host "Proof finalized"
# 5) Confirm artifact exists on host
$artifactMatch = Get-ChildItem ".\artifacts" -Recurse -File | Where-Object { $_.Name -like "*$SID*" }
if (-not $artifactMatch) { throw "Artifact file not found under .\artifacts for SID=$SID" }
Write-Host "Artifact written:"
$artifactMatch | ForEach-Object { Write-Host $_.FullName }
Write-Host "=== SUCCESS ==="