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]$ExpectedBackendImage = "rap-backend:fabric-service-channel-0.2.281-c18z109", [string]$DockerSSH = "test-docker", [string]$ResultPath = "artifacts\c18z102-rebuild-health-feedback-drilldown-audit-smoke-result.json" ) Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path $repoRoot = (Resolve-Path (Join-Path $scriptDir "..\..")).ProviderPath $runId = "c18z102-" + (Get-Date -Format "yyyyMMdd-HHmmss") function Invoke-Api { param([string]$Method, [string]$Path, [object]$Body = $null) $params = @{ Method = $Method; Uri = "$ApiBaseUrl$Path"; TimeoutSec = 30 } if ($null -ne $Body) { $params.ContentType = "application/json" $params.Body = ($Body | ConvertTo-Json -Depth 50) } return Invoke-RestMethod @params } function Get-PropertyValue { param([object]$Item, [string]$Name, [object]$Default = $null) if ($null -eq $Item) { return $Default } $property = $Item.PSObject.Properties[$Name] if ($null -eq $property) { return $Default } return $property.Value } $checks = [ordered]@{} $backendImage = (& ssh $DockerSSH "docker inspect rap_test_backend --format '{{.Config.Image}}'").Trim() $checks.backend_expected_image_deployed = ($backendImage -eq $ExpectedBackendImage) $feedbackChannelID = "$runId-channel" $feedbackViolationStatus = "fabric_route_send_failed_backend_fallback_blocked" $reason = "synthetic c18z102 rebuild-health feedback drilldown audit" Invoke-Api -Method POST -Path "/clusters/$ClusterID/fabric/service-channels/rebuild-incidents/investigations" -Body @{ actor_user_id = $ActorUserID feedback_source = "fabric_service_channel_access_report" feedback_channel_id = $feedbackChannelID feedback_violation_status = $feedbackViolationStatus drilldown_source = "rebuild_health_feedback_breakdown" reason = $reason } | Out-Null $auditEvents = (Invoke-Api -Method GET -Path "/clusters/$ClusterID/audit?actor_user_id=$ActorUserID&limit=25").audit_events $event = @($auditEvents | Where-Object { $_.event_type -eq "fabric.service_channel_rebuild_feedback_breakdown.investigation_opened" -and (Get-PropertyValue -Item $_.payload -Name "feedback_channel_id" -Default "") -eq $feedbackChannelID }) | Select-Object -First 1 $checks.audit_event_recorded = ($null -ne $event) $checks.audit_event_target_is_breakdown = ($null -ne $event -and $event.target_type -eq "fabric_service_channel_rebuild_feedback_breakdown" -and $event.target_id -eq $feedbackChannelID) $checks.audit_event_payload_has_feedback_filters = ( $null -ne $event -and (Get-PropertyValue -Item $event.payload -Name "feedback_source" -Default "") -eq "fabric_service_channel_access_report" -and (Get-PropertyValue -Item $event.payload -Name "feedback_violation_status" -Default "") -eq $feedbackViolationStatus -and (Get-PropertyValue -Item $event.payload -Name "drilldown_source" -Default "") -eq "rebuild_health_feedback_breakdown" -and (Get-PropertyValue -Item $event.payload -Name "reason" -Default "") -eq $reason ) $failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key }) $result = [ordered]@{ schema_version = "c18z102.rebuild_health_feedback_drilldown_audit_smoke.v1" run_id = $runId cluster_id = $ClusterID feedback_channel_id = $feedbackChannelID passed = ($failed.Count -eq 0) checks = $checks failed_checks = $failed summary = [ordered]@{ backend_image = $backendImage audit_event_id = if ($null -ne $event) { $event.id } else { $null } } } $target = Join-Path $repoRoot $ResultPath $result | ConvertTo-Json -Depth 50 | Set-Content -Path $target -Encoding UTF8 if ($failed.Count -gt 0) { throw "C18Z102 rebuild-health feedback drilldown audit smoke failed: $($failed -join ', ')" } Write-Host "C18Z102 rebuild-health feedback drilldown audit smoke passed. Result: $target" $result