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]$ExpectedNodeAgentImage = "rap-node-agent:0.2.270-c18z95", [string]$ResultPath = "artifacts\c18z94-data-plane-contract-incident-smoke-result.json" ) Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path $repoRoot = (Resolve-Path (Join-Path $scriptDir "..\..")).ProviderPath $runId = "c18z94-" + (Get-Date -Format "yyyyMMdd-HHmmss") $baseResultPath = "artifacts\$runId-c18z92-base-result.json" 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 80) } 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 } & (Join-Path $scriptDir "c18z92-node-agent-disabled-compat-fallback-smoke.ps1") ` -ApiBaseUrl $ApiBaseUrl ` -ClusterID $ClusterID ` -ActorUserID $ActorUserID ` -ExpectedBackendImage $ExpectedBackendImage ` -ExpectedNodeAgentImage $ExpectedNodeAgentImage ` -ResultPath $baseResultPath | Out-Null $baseResult = Get-Content (Join-Path $repoRoot $baseResultPath) -Raw | ConvertFrom-Json $channelID = [string]$baseResult.channel_id $incidents = (Invoke-Api -Method GET -Path "/clusters/$ClusterID/fabric/service-channels/rebuild-incidents?actor_user_id=$ActorUserID&limit=20").rebuild_incidents $incident = @($incidents | Where-Object { [string](Get-PropertyValue -Item $_ -Name "incident_source" -Default "") -eq "data_plane_contract" -and [string](Get-PropertyValue -Item $_ -Name "channel_id" -Default "") -eq $channelID }) | Select-Object -First 1 $checks = [ordered]@{ base_disabled_fallback_smoke_passed = [bool]$baseResult.passed data_plane_incident_emitted = ($null -ne $incident) incident_source_is_data_plane_contract = ($null -ne $incident -and [string]$incident.incident_source -eq "data_plane_contract") incident_status_reports_blocked_backend_relay = ($null -ne $incident -and [string]$incident.guard_status -eq "degraded_route_blocked_by_policy") incident_severity_is_bad = ($null -ne $incident -and [string]$incident.guard_severity -eq "bad") incident_action_is_operator_visible = ($null -ne $incident -and [string]$incident.recommended_operator_action -eq "restore_fabric_route_or_change_signed_backend_relay_policy_before_retry") } $failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key }) $result = [ordered]@{ schema_version = "c18z94.data_plane_contract_incident_smoke.v1" run_id = $runId cluster_id = $ClusterID channel_id = $channelID passed = ($failed.Count -eq 0) checks = $checks failed_checks = $failed summary = [ordered]@{ base_result_path = $baseResultPath base_checks = $baseResult.checks incident = $incident } } $target = Join-Path $repoRoot $ResultPath $result | ConvertTo-Json -Depth 80 | Set-Content -Path $target -Encoding UTF8 if (-not $result.passed) { throw "C18Z94 data-plane contract incident smoke failed: $($failed -join ', ')" } Write-Host "C18Z94 data-plane contract incident smoke passed. Result: $target" $result