Files
rdp-proxy/scripts/fabric/c18z36-service-channel-rebuild-alert-resurface-smoke.ps1
2026-05-12 21:02:29 +03:00

88 lines
3.8 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]$ExitNodeName = "test-2",
[string]$EntryBaseUrl = "http://192.168.200.61:19131",
[string]$DockerSSH = "test-docker",
[string]$ExpectedBackendImage = "rap-backend:fabric-service-channel-0.2.217",
[string]$ExpectedNodeAgentImage = "rap-node-agent:0.2.208",
[string]$ResultPath = "artifacts\c18z36-service-channel-rebuild-alert-resurface-smoke-result.json"
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$repoRoot = (Resolve-Path (Join-Path $scriptDir "..\..")).ProviderPath
$baseResultPath = "artifacts\c18z36-base-rebuild-alert-silence-smoke-result.json"
& (Join-Path $scriptDir "c18z35-service-channel-rebuild-alert-silence-smoke.ps1") `
-ApiBaseUrl $ApiBaseUrl `
-ClusterID $ClusterID `
-ActorUserID $ActorUserID `
-EntryNodeName $EntryNodeName `
-ExitNodeName $ExitNodeName `
-EntryBaseUrl $EntryBaseUrl `
-DockerSSH $DockerSSH `
-ExpectedBackendImage $ExpectedBackendImage `
-ExpectedNodeAgentImage $ExpectedNodeAgentImage `
-ResultPath $baseResultPath | Out-Null
$after = (Invoke-RestMethod -Method Get -Uri "$ApiBaseUrl/clusters/$ClusterID/fabric/service-channels/rebuild-health?actor_user_id=$ActorUserID&limit=5" -TimeoutSec 30).rebuild_health
function Get-Prop {
param([object]$Object, [string]$Name)
if ($null -eq $Object) { return $null }
$prop = $Object.PSObject.Properties[$Name]
if ($null -eq $prop) { return $null }
return $prop.Value
}
$rawResurfacedAttempts = Get-Prop $after "resurfaced_attempts"
$resurfacedAttempts = if ($null -eq $rawResurfacedAttempts) { @() } else { @($rawResurfacedAttempts) }
$resurfaced = @($resurfacedAttempts | Where-Object {
(Get-Prop $_ "alert_resurfaced") -eq $true -and
(Get-Prop $_ "alert_resurfaced_previous_generation")
})
$backendLine = (& ssh $DockerSSH "docker ps --format '{{.Names}} {{.Image}} {{.Status}}' | grep '^rap_test_backend '") | Out-String
$nodeLines = (& ssh $DockerSSH "docker ps --format '{{.Names}} {{.Image}} {{.Status}}' | grep '^rap_test_node_test_'") | Out-String
$result = [ordered]@{
schema_version = "c18z36.service_channel_rebuild_alert_resurface_smoke.v1"
cluster_id = $ClusterID
passed = [bool](
$backendLine.Contains($ExpectedBackendImage) -and
$nodeLines.Contains($ExpectedNodeAgentImage) -and
[int](Get-Prop $after "resurfaced_count") -gt 0 -and
$resurfaced.Count -gt 0
)
checks = [ordered]@{
backend_expected_image_deployed = $backendLine.Contains($ExpectedBackendImage)
node_agent_expected_image_deployed = $nodeLines.Contains($ExpectedNodeAgentImage)
resurfaced_count_positive = ([int](Get-Prop $after "resurfaced_count") -gt 0)
new_generation_resurfaced = ($resurfaced.Count -gt 0)
}
summary = [ordered]@{
backend_container = $backendLine.Trim()
node_containers = $nodeLines.Trim()
resurfaced = $resurfaced
health = $after
base_smoke_result = (Join-Path $repoRoot $baseResultPath)
}
}
$resultFullPath = Join-Path $repoRoot $ResultPath
$resultDir = Split-Path -Parent $resultFullPath
if (-not (Test-Path $resultDir)) {
New-Item -ItemType Directory -Path $resultDir | Out-Null
}
$result | ConvertTo-Json -Depth 100 | Set-Content -Path $resultFullPath -Encoding UTF8
if (-not $result.passed) {
throw "C18Z36 service-channel rebuild alert resurface smoke failed. Result: $resultFullPath"
}
Write-Host "C18Z36 service-channel rebuild alert resurface smoke passed. Result: $resultFullPath"
$result