Record project continuation changes

This commit is contained in:
2026-05-12 21:02:29 +03:00
parent 3059d1d7a3
commit 8f69d53193
339 changed files with 101111 additions and 1769 deletions
@@ -0,0 +1,112 @@
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\c18z107-audit-correlation-summary-smoke-result.json"
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$repoRoot = (Resolve-Path (Join-Path $scriptDir "..\..")).ProviderPath
$runId = "c18z107-" + (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 60)
}
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)
$health = (Invoke-Api -Method GET -Path "/clusters/$ClusterID/fabric/service-channels/rebuild-health?actor_user_id=$ActorUserID&limit=50").rebuild_health
$breakdown = @($health.feedback_breakdowns | Where-Object {
(Get-PropertyValue -Item $_ -Name "feedback_source" -Default "") -ne "" -and
(Get-PropertyValue -Item $_ -Name "feedback_channel_id" -Default "") -ne "" -and
(Get-PropertyValue -Item $_ -Name "feedback_violation_status" -Default "") -ne ""
}) | Select-Object -First 1
$checks.rebuild_health_has_feedback_breakdown = ($null -ne $breakdown)
if ($null -eq $breakdown) {
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
throw "C18Z107 audit correlation summary smoke failed before audit: $($failed -join ', ')"
}
$feedbackSource = $breakdown.feedback_source
$feedbackChannelID = $breakdown.feedback_channel_id
$feedbackViolationStatus = $breakdown.feedback_violation_status
$reason = "synthetic c18z107 audit correlation summary"
Invoke-Api -Method POST -Path "/clusters/$ClusterID/fabric/service-channels/rebuild-incidents/investigations" -Body @{
actor_user_id = $ActorUserID
feedback_source = $feedbackSource
feedback_channel_id = $feedbackChannelID
feedback_violation_status = $feedbackViolationStatus
drilldown_source = "rebuild_health_feedback_breakdown"
reason = $reason
} | Out-Null
$eventType = "fabric.service_channel_rebuild_feedback_breakdown.investigation_opened"
$payload = Invoke-Api -Method GET -Path "/clusters/$ClusterID/audit?actor_user_id=$ActorUserID&limit=20&event_type=$([uri]::EscapeDataString($eventType))&correlation=fabric_diagnostics"
$events = $payload.audit_events
$summary = $payload.audit_summary
$event = @($events | Where-Object {
(Get-PropertyValue -Item $_.payload -Name "reason" -Default "") -eq $reason -and
(Get-PropertyValue -Item $_.payload -Name "feedback_channel_id" -Default "") -eq $feedbackChannelID
}) | Select-Object -First 1
$hint = Get-PropertyValue -Item $event -Name "correlation_hints" -Default $null
$statusCounts = Get-PropertyValue -Item $summary -Name "counts_by_current_diagnostic_status" -Default $null
$sourceCounts = Get-PropertyValue -Item $summary -Name "counts_by_feedback_source" -Default $null
$violationCounts = Get-PropertyValue -Item $summary -Name "counts_by_feedback_violation_status" -Default $null
$checks.audit_summary_returned = ($null -ne $summary)
$checks.summary_total_matches_events = ((Get-PropertyValue -Item $summary -Name "total_count" -Default -1) -eq @($events).Count)
$checks.summary_counts_breakdown_active = ((Get-PropertyValue -Item $statusCounts -Name "breakdown_active" -Default 0) -ge 1)
$checks.summary_counts_feedback_source = ((Get-PropertyValue -Item $sourceCounts -Name $feedbackSource -Default 0) -ge 1)
$checks.summary_counts_feedback_violation = ((Get-PropertyValue -Item $violationCounts -Name $feedbackViolationStatus -Default 0) -ge 1)
$checks.event_keeps_correlation_hint = ((Get-PropertyValue -Item $hint -Name "current_diagnostic_status" -Default "") -eq "breakdown_active")
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
$result = [ordered]@{
schema_version = "c18z107.audit_correlation_summary_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 }
total_count = Get-PropertyValue -Item $summary -Name "total_count" -Default 0
correlated_count = Get-PropertyValue -Item $summary -Name "correlated_count" -Default 0
}
}
$target = Join-Path $repoRoot $ResultPath
$result | ConvertTo-Json -Depth 60 | Set-Content -Path $target -Encoding UTF8
if ($failed.Count -gt 0) {
throw "C18Z107 audit correlation summary smoke failed: $($failed -join ', ')"
}
Write-Host "C18Z107 audit correlation summary smoke passed. Result: $target"
$result