Files
rdp-proxy/scripts/fabric/c19z58-remote-workspace-real-adapter-readiness-handoff-summary-compatibility-smoke.ps1
2026-05-14 23:30:34 +03:00

173 lines
7.8 KiB
PowerShell

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]$RequestedNodeName = "test-1",
[string]$DefaultNodeName = "test-2",
[string]$MatrixNodeName = "test-1",
[string]$ResultPath = "artifacts\c19z58-remote-workspace-real-adapter-readiness-handoff-summary-compatibility-smoke-result.json"
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath
$sourceResultPath = "artifacts\c19z58-remote-workspace-real-adapter-readiness-handoff-summary-source-result.json"
$requiredSummaryFields = @(
"schema_version",
"readiness_state",
"operator_status",
"operator_action",
"runtime_stage",
"activation_decision",
"process_start_allowed",
"health_probe_enabled",
"payload_traffic",
"requested_config_visible",
"default_config_visible",
"mode_matrix_visible",
"checklist_passed_count",
"checklist_total_count",
"checklist_status"
)
$requiredChecklistItemFields = @("name", "passed", "evidence")
$requiredChecklistItems = @(
"handoff_v4_complete",
"mode_matrix_v3_compatible",
"requested_and_default_config_shapes_visible",
"desired_workload_modes_visible",
"activation_blocked",
"process_start_disabled",
"health_probe_disabled",
"payload_traffic_none",
"missing_gates_visible",
"missing_health_signals_visible"
)
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
}
function Test-ObjectHasFields {
param([object]$Item, [string[]]$Fields)
if ($null -eq $Item) { return $false }
foreach ($field in $Fields) {
if ($null -eq $Item.PSObject.Properties[$field]) { return $false }
}
return $true
}
function Get-ChecklistItem {
param([object[]]$Items, [string]$Name)
return @($Items | Where-Object { [string](Get-PropertyValue -Item $_ -Name "name" -Default "") -eq $Name } | Select-Object -First 1)
}
function Test-ChecklistItemsPresent {
param([object[]]$Items)
foreach ($name in $requiredChecklistItems) {
if ($null -eq (Get-ChecklistItem -Items $Items -Name $name)) { return $false }
}
return $true
}
function Test-ChecklistItemFields {
param([object[]]$Items)
if ($Items.Count -eq 0) { return $false }
foreach ($item in $Items) {
if (-not (Test-ObjectHasFields -Item $item -Fields $requiredChecklistItemFields)) { return $false }
}
return $true
}
function Test-ChecklistItemsPassed {
param([object[]]$Items)
if ($Items.Count -eq 0) { return $false }
return (@($Items | Where-Object { -not [bool](Get-PropertyValue -Item $_ -Name "passed" -Default $false) }).Count -eq 0)
}
& powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c19z57-remote-workspace-real-adapter-readiness-handoff-summary-smoke.ps1") `
-ApiBaseUrl $ApiBaseUrl `
-ClusterID $ClusterID `
-ActorUserID $ActorUserID `
-RequestedNodeName $RequestedNodeName `
-DefaultNodeName $DefaultNodeName `
-MatrixNodeName $MatrixNodeName `
-ResultPath $sourceResultPath | Out-Null
$sourceFile = Join-Path $repoRoot $sourceResultPath
$sourceResult = Get-Content -Raw -Path $sourceFile | ConvertFrom-Json
$summary = Get-PropertyValue -Item $sourceResult -Name "readiness_summary" -Default $null
$checklist = @((Get-PropertyValue -Item $sourceResult -Name "operator_checklist" -Default @()))
$summaryFieldsCompatible = Test-ObjectHasFields -Item $summary -Fields $requiredSummaryFields
$summaryValuesCompatible = (
[string](Get-PropertyValue -Item $summary -Name "schema_version" -Default "") -eq "rap.remote_workspace_real_adapter_disabled_runtime_readiness_summary.v1" -and
[string](Get-PropertyValue -Item $summary -Name "readiness_state" -Default "") -eq "blocked_until_real_runtime_stage" -and
[string](Get-PropertyValue -Item $summary -Name "operator_status" -Default "") -eq "not_ready" -and
[string](Get-PropertyValue -Item $summary -Name "operator_action" -Default "") -eq "keep_real_adapter_disabled" -and
[string](Get-PropertyValue -Item $summary -Name "runtime_stage" -Default "") -eq "disabled_until_real_runtime_stage" -and
[string](Get-PropertyValue -Item $summary -Name "activation_decision" -Default "") -eq "blocked" -and
-not [bool](Get-PropertyValue -Item $summary -Name "process_start_allowed" -Default $true) -and
-not [bool](Get-PropertyValue -Item $summary -Name "health_probe_enabled" -Default $true) -and
[string](Get-PropertyValue -Item $summary -Name "payload_traffic" -Default "") -eq "none" -and
[bool](Get-PropertyValue -Item $summary -Name "requested_config_visible" -Default $false) -and
[bool](Get-PropertyValue -Item $summary -Name "default_config_visible" -Default $false) -and
[bool](Get-PropertyValue -Item $summary -Name "mode_matrix_visible" -Default $false) -and
[string](Get-PropertyValue -Item $summary -Name "checklist_status" -Default "") -eq "complete"
)
$checklistCount = $checklist.Count
$checklistPassedCount = @($checklist | Where-Object { [bool](Get-PropertyValue -Item $_ -Name "passed" -Default $false) }).Count
$summaryCountsCompatible = (
[int](Get-PropertyValue -Item $summary -Name "checklist_total_count" -Default -1) -eq $requiredChecklistItems.Count -and
[int](Get-PropertyValue -Item $summary -Name "checklist_passed_count" -Default -1) -eq $requiredChecklistItems.Count -and
$checklistCount -eq $requiredChecklistItems.Count -and
$checklistPassedCount -eq $requiredChecklistItems.Count
)
$checklistFieldsCompatible = Test-ChecklistItemFields -Items $checklist
$checklistNamesCompatible = Test-ChecklistItemsPresent -Items $checklist
$checklistValuesCompatible = Test-ChecklistItemsPassed -Items $checklist
$checks = [ordered]@{
source_smoke_passed = ([bool]$sourceResult.passed)
source_schema_expected = ([string]$sourceResult.schema_version -eq "c19z57.remote_workspace_real_adapter_readiness_handoff_summary_smoke.v1")
summary_present = ($null -ne $summary)
summary_fields_compatible = $summaryFieldsCompatible
summary_values_compatible = $summaryValuesCompatible
summary_counts_compatible = $summaryCountsCompatible
checklist_count_expected = ($checklistCount -eq $requiredChecklistItems.Count)
checklist_fields_compatible = $checklistFieldsCompatible
checklist_names_compatible = $checklistNamesCompatible
checklist_values_compatible = $checklistValuesCompatible
}
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
$result = [ordered]@{
schema_version = "c19z58.remote_workspace_real_adapter_readiness_handoff_summary_compatibility_smoke.v1"
source_result_path = $sourceFile
cluster_id = $ClusterID
required_summary_fields = $requiredSummaryFields
required_checklist_item_fields = $requiredChecklistItemFields
required_checklist_items = $requiredChecklistItems
readiness_summary = $summary
operator_checklist = $checklist
checks = $checks
failed_checks = $failed
passed = ($failed.Count -eq 0)
}
$fullResultPath = Join-Path $repoRoot $ResultPath
$resultDir = Split-Path -Parent $fullResultPath
if ($resultDir) { New-Item -ItemType Directory -Force -Path $resultDir | Out-Null }
$result | ConvertTo-Json -Depth 100 | Set-Content -Encoding UTF8 -Path $fullResultPath
if (-not $result.passed) {
throw "C19Z58 remote workspace real-adapter readiness handoff summary compatibility smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')"
}
Write-Host "C19Z58 remote workspace real-adapter readiness handoff summary compatibility smoke passed. Result: $fullResultPath"
$result