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.216", [string]$ExpectedNodeAgentImage = "rap-node-agent:0.2.208", [string]$ResultPath = "artifacts\c18z35-service-channel-rebuild-alert-silence-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\c18z35-base-rebuild-health-smoke-result.json" & (Join-Path $scriptDir "c18z34-service-channel-rebuild-health-smoke.ps1") ` -ApiBaseUrl $ApiBaseUrl ` -ClusterID $ClusterID ` -ActorUserID $ActorUserID ` -EntryNodeName $EntryNodeName ` -ExitNodeName $ExitNodeName ` -EntryBaseUrl $EntryBaseUrl ` -DockerSSH $DockerSSH ` -ExpectedBackendImage $ExpectedBackendImage ` -ExpectedNodeAgentImage $ExpectedNodeAgentImage ` -ResultPath $baseResultPath | Out-Null $before = (Invoke-RestMethod -Method Get -Uri "$ApiBaseUrl/clusters/$ClusterID/fabric/service-channels/rebuild-health?actor_user_id=$ActorUserID&limit=5" -TimeoutSec 30).rebuild_health $target = @($before.most_recent_bad_attempts | Select-Object -First 1)[0] if ($null -eq $target) { throw "C18Z35 requires at least one active bad rebuild attempt to silence" } $payload = @{ actor_user_id = $ActorUserID reporter_node_id = [string]$target.reporter_node_id route_id = [string]$target.route_id guard_status = [string]$target.guard_status generation = [string]$target.generation reason = "c18z35 smoke acknowledged known rebuild alert" ttl_seconds = 21600 } $silence = (Invoke-RestMethod -Method Post -Uri "$ApiBaseUrl/clusters/$ClusterID/fabric/service-channels/rebuild-health/silences" -ContentType "application/json" -Body ($payload | ConvertTo-Json -Depth 20) -TimeoutSec 30).rebuild_alert_silence $after = (Invoke-RestMethod -Method Get -Uri "$ApiBaseUrl/clusters/$ClusterID/fabric/service-channels/rebuild-health?actor_user_id=$ActorUserID&limit=5" -TimeoutSec 30).rebuild_health $stillActiveSameGeneration = @($after.most_recent_bad_attempts | Where-Object { $_.reporter_node_id -eq $payload.reporter_node_id -and $_.route_id -eq $payload.route_id -and $_.guard_status -eq $payload.guard_status -and ([string]$_.generation) -eq $payload.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 = "c18z35.service_channel_rebuild_alert_silence_smoke.v1" cluster_id = $ClusterID passed = [bool]( $backendLine.Contains($ExpectedBackendImage) -and $nodeLines.Contains($ExpectedNodeAgentImage) -and [string]$silence.id -and [int]$after.silenced_count -gt [int]$before.silenced_count -and [int]$after.active_bad_count -lt [int]$before.active_bad_count -and $stillActiveSameGeneration.Count -eq 0 ) checks = [ordered]@{ backend_expected_image_deployed = $backendLine.Contains($ExpectedBackendImage) node_agent_expected_image_deployed = $nodeLines.Contains($ExpectedNodeAgentImage) silence_created = ([string]$silence.id).Length -gt 0 silenced_count_increased = ([int]$after.silenced_count -gt [int]$before.silenced_count) active_bad_count_decreased = ([int]$after.active_bad_count -lt [int]$before.active_bad_count) exact_generation_removed_from_active_bad = ($stillActiveSameGeneration.Count -eq 0) } summary = [ordered]@{ backend_container = $backendLine.Trim() node_containers = $nodeLines.Trim() target = $payload silence = $silence before = $before after = $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 "C18Z35 service-channel rebuild alert silence smoke failed. Result: $resultFullPath" } Write-Host "C18Z35 service-channel rebuild alert silence smoke passed. Result: $resultFullPath" $result