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.218", [string]$ExpectedNodeAgentImage = "rap-node-agent:0.2.208", [string]$ResultPath = "artifacts\c18z37-service-channel-readiness-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\c18z37-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 $readiness = (Invoke-RestMethod -Method Get -Uri "$ApiBaseUrl/clusters/$ClusterID/fabric/service-channels/readiness?actor_user_id=$ActorUserID&limit=5" -TimeoutSec 30).fabric_service_channel_readiness $health = (Invoke-RestMethod -Method Get -Uri "$ApiBaseUrl/clusters/$ClusterID/fabric/service-channels/rebuild-health?actor_user_id=$ActorUserID&limit=5" -TimeoutSec 30).rebuild_health $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 $expectedStatus = if ([int]$health.active_bad_count -gt 0 -or [int]$health.resurfaced_count -gt 0) { "blocked" } elseif ([int]$health.active_warn_count -gt 0 -or [int]$health.silenced_count -gt 0 -or [int]$health.pending_count -gt 0) { "degraded" } else { "clean" } $result = [ordered]@{ schema_version = "c18z37.service_channel_readiness_smoke.v1" cluster_id = $ClusterID passed = [bool]( $backendLine.Contains($ExpectedBackendImage) -and $nodeLines.Contains($ExpectedNodeAgentImage) -and [string]$readiness.status -eq $expectedStatus -and [int]$readiness.active_bad_count -eq [int]$health.active_bad_count -and [int]$readiness.active_warn_count -eq [int]$health.active_warn_count -and [int]$readiness.resurfaced_count -eq [int]$health.resurfaced_count -and [string]$readiness.reason ) checks = [ordered]@{ backend_expected_image_deployed = $backendLine.Contains($ExpectedBackendImage) node_agent_expected_image_deployed = $nodeLines.Contains($ExpectedNodeAgentImage) status_matches_health = ([string]$readiness.status -eq $expectedStatus) active_bad_matches = ([int]$readiness.active_bad_count -eq [int]$health.active_bad_count) active_warn_matches = ([int]$readiness.active_warn_count -eq [int]$health.active_warn_count) resurfaced_matches = ([int]$readiness.resurfaced_count -eq [int]$health.resurfaced_count) has_reason = ([string]$readiness.reason).Length -gt 0 } summary = [ordered]@{ backend_container = $backendLine.Trim() node_containers = $nodeLines.Trim() expected_status = $expectedStatus readiness = $readiness health = $health 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 "C18Z37 service-channel readiness smoke failed. Result: $resultFullPath" } Write-Host "C18Z37 service-channel readiness smoke passed. Result: $resultFullPath" $result