Files
rdp-proxy/scripts/fabric/c18z69-service-channel-adaptive-backpressure-smoke.ps1
2026-05-12 21:02:29 +03:00

93 lines
4.0 KiB
PowerShell

param(
[string]$ApiBaseUrl = "http://192.168.200.61:18121/api/v1",
[string]$ClusterID = "cfc0743d-d960-49fb-9de8-96e063d5e4aa",
[string]$ActorUserID = "f67d943f-5397-4b3a-a229-695fe67ad700",
[string]$EntryNodeName = "test-1",
[string]$ExpectedBackendImage = "rap-backend:fabric-service-channel-0.2.281-c18z109",
[string]$ExpectedNodeAgentImage = "rap-node-agent:codex-fabric-stability-20260512b",
[string]$ResultPath = "artifacts\c18z69-service-channel-adaptive-backpressure-smoke-result.json"
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$repoRoot = (Resolve-Path (Join-Path $scriptDir "..\..")).ProviderPath
$c18z67 = Join-Path $scriptDir "c18z67-service-channel-concurrent-qos-live-smoke.ps1"
& powershell -NoProfile -ExecutionPolicy Bypass -File $c18z67 -ExpectedBackendImage $ExpectedBackendImage -ExpectedNodeAgentImage $ExpectedNodeAgentImage | Out-Host
function Invoke-Api {
param([string]$Path)
return Invoke-RestMethod -Method GET -Uri "$ApiBaseUrl$Path" -TimeoutSec 30
}
$nodes = (Invoke-Api -Path "/clusters/$ClusterID/nodes?actor_user_id=$ActorUserID").nodes
$entryNode = @($nodes | Where-Object { $_.name -eq $EntryNodeName }) | Select-Object -First 1
if ($null -eq $entryNode) {
throw "entry node '$EntryNodeName' not found"
}
$heartbeats = (Invoke-Api -Path "/clusters/$ClusterID/nodes/$($entryNode.id)/heartbeats?actor_user_id=$ActorUserID&limit=1").heartbeats
if ($null -eq $heartbeats -or @($heartbeats).Count -eq 0) {
throw "no heartbeat found for entry node '$EntryNodeName'"
}
$flowScheduler = $heartbeats[0].metadata.fabric_service_channel_runtime_report.ingress.flow_scheduler
if ($null -eq $flowScheduler) {
throw "latest heartbeat does not include fabric service-channel flow scheduler"
}
$windows = $flowScheduler.recommended_parallel_windows
$trafficClasses = $flowScheduler.traffic_class_counts
$bulkWindow = [int]$windows.bulk
$interactiveWindow = [int]$windows.interactive
$controlWindow = [int]$windows.control
$bulkCount = [int]$trafficClasses.bulk
$interactiveCount = [int]$trafficClasses.interactive
$adaptiveActive = [bool]$flowScheduler.adaptive_backpressure_active
$adaptiveReason = [string]$flowScheduler.adaptive_backpressure_reason
$dropped = [int]$flowScheduler.dropped
$checks = [ordered]@{
adaptive_backpressure_active = $adaptiveActive
adaptive_reason_protects_interactive = ($adaptiveReason -eq "bulk_window_reduced_to_protect_interactive")
bulk_window_reduced = ($bulkWindow -eq 1)
interactive_window_preserved = ($interactiveWindow -ge 4)
control_window_preserved = ($controlWindow -ge 4)
bulk_pressure_observed = ($bulkCount -ge 16)
interactive_qos_observed = ($interactiveCount -gt 0)
no_scheduler_drops = ($dropped -eq 0)
}
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
$result = [ordered]@{
schema_version = "c18z69.service_channel_adaptive_backpressure_smoke.v1"
run_id = "c18z69-" + (Get-Date -Format "yyyyMMdd-HHmmss")
cluster_id = $ClusterID
entry_node_id = $entryNode.id
entry_node_name = $entryNode.name
passed = ($failed.Count -eq 0)
checks = $checks
failed_checks = $failed
summary = [ordered]@{
adaptive_backpressure_active = $adaptiveActive
adaptive_backpressure_reason = $adaptiveReason
recommended_parallel_windows = $windows
traffic_class_counts = $trafficClasses
channel_count = [int]$flowScheduler.channel_count
high_watermark = [int]$flowScheduler.high_watermark
max_in_flight = [int]$flowScheduler.max_in_flight
dropped = $dropped
}
}
$target = Join-Path $repoRoot $ResultPath
$result | ConvertTo-Json -Depth 40 | Set-Content -Path $target -Encoding UTF8
if (-not $result.passed) {
throw "C18Z69 adaptive backpressure smoke failed: $($failed -join ', ')"
}
Write-Host "C18Z69 service-channel adaptive backpressure smoke passed. Result: $target"
$result