Files
rdp-proxy/scripts/fabric/c18z16-live-service-channel-quality-fairness-smoke.ps1
T
2026-05-12 21:02:29 +03:00

98 lines
4.4 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]$RelayNodeName = "test-3",
[string]$ExitNodeName = "test-2",
[string]$EntryBaseUrl = "http://192.168.200.61:19131",
[string]$DockerSSH = "test-docker",
[int]$InitialBatchCount = 12,
[int]$LearningBatchCount = 24,
[int]$PostChurnBatchCount = 24,
[int]$PacketsPerBatch = 8,
[int]$BatchDelayMilliseconds = 25,
[string]$ResultPath = "artifacts\c18z16-live-service-channel-quality-fairness-smoke-result.json"
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$repoRoot = (Resolve-Path (Join-Path $scriptDir "..\..")).ProviderPath
$innerResultPath = "artifacts\c18z16-live-service-channel-quality-fairness-inner-result.json"
$innerResultFullPath = Join-Path $repoRoot $innerResultPath
& (Join-Path $scriptDir "c18z15-live-service-channel-effective-quality-smoke.ps1") `
-ApiBaseUrl $ApiBaseUrl `
-ClusterID $ClusterID `
-ActorUserID $ActorUserID `
-EntryNodeName $EntryNodeName `
-RelayNodeName $RelayNodeName `
-ExitNodeName $ExitNodeName `
-EntryBaseUrl $EntryBaseUrl `
-DockerSSH $DockerSSH `
-InitialBatchCount $InitialBatchCount `
-LearningBatchCount $LearningBatchCount `
-PostChurnBatchCount $PostChurnBatchCount `
-PacketsPerBatch $PacketsPerBatch `
-BatchDelayMilliseconds $BatchDelayMilliseconds `
-ResultPath $innerResultPath
$result = Get-Content -Path $innerResultFullPath -Raw | ConvertFrom-Json
$qualityIngress = $result.telemetry.final_entry_ingress
$channelStats = $qualityIngress.flow_scheduler.channel_stats
$statItems = @()
if ($null -ne $channelStats) {
$statItems = @($channelStats.PSObject.Properties | ForEach-Object {
$qualityRouteID = ""
$qualityScore = 0
if ($_.Value.PSObject.Properties["quality_preference_route_id"]) { $qualityRouteID = [string]$_.Value.quality_preference_route_id }
if ($_.Value.PSObject.Properties["quality_preference_score"]) { $qualityScore = [int]$_.Value.quality_preference_score }
[pscustomobject]@{
channel = $_.Name
served = [int64]($_.Value.served)
dropped = [int64]($_.Value.dropped)
last_route_id = [string]($_.Value.last_route_id)
quality_preference_route_id = $qualityRouteID
quality_preference_score = $qualityScore
}
})
}
$qualityChannels = @($statItems | Where-Object {
$_.served -gt 0 -and
$_.dropped -eq 0 -and
$_.quality_preference_route_id -eq [string]$result.active_websocket.final_route_id -and
$_.quality_preference_score -gt 0
})
$servedChannels = @($statItems | Where-Object { $_.served -gt 0 })
$result.schema_version = "c18z16.live_service_channel_quality_fairness_smoke.v1"
$result | Add-Member -NotePropertyName c18z16_checks -NotePropertyValue ([ordered]@{
multi_channel_traffic_observed = ($servedChannels.Count -ge 2)
quality_preference_applied_per_channel = ($qualityChannels.Count -ge 2)
no_channel_drops_under_quality_preference = (@($statItems | Where-Object { $_.dropped -gt 0 }).Count -eq 0)
active_session_stayed_on_quality_route = ([string]$result.active_websocket.final_route_id -eq [string]$result.live_feedback.route_id)
}) -Force
$result | Add-Member -NotePropertyName c18z16_summary -NotePropertyValue ([ordered]@{
served_channel_count = $servedChannels.Count
quality_preference_channel_count = $qualityChannels.Count
final_quality_route_id = [string]$result.active_websocket.final_route_id
}) -Force
$result.passed = [bool]($result.passed -and
$result.c18z16_checks.multi_channel_traffic_observed -and
$result.c18z16_checks.quality_preference_applied_per_channel -and
$result.c18z16_checks.no_channel_drops_under_quality_preference -and
$result.c18z16_checks.active_session_stayed_on_quality_route)
$resolvedResultPath = Join-Path $repoRoot $ResultPath
$result | ConvertTo-Json -Depth 100 | Set-Content -Path $resolvedResultPath -Encoding UTF8
Remove-Item -Path $innerResultFullPath -Force -ErrorAction SilentlyContinue
if (-not $result.passed) {
throw "C18Z16 route-quality fairness smoke failed. Result: $resolvedResultPath"
}
Write-Host "C18Z16 live service-channel quality fairness smoke passed. Result: $resolvedResultPath"
$result