181 lines
8.7 KiB
PowerShell
181 lines
8.7 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\c19z60-remote-workspace-real-adapter-disabled-action-map-compatibility-smoke-result.json"
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath
|
|
$sourceResultPath = "artifacts\c19z60-remote-workspace-real-adapter-disabled-action-map-source-result.json"
|
|
$requiredActionMapFields = @(
|
|
"schema_version",
|
|
"readiness_summary_schema",
|
|
"readiness_state",
|
|
"operator_action",
|
|
"activation_decision",
|
|
"process_start_allowed",
|
|
"health_probe_enabled",
|
|
"payload_traffic",
|
|
"action_count",
|
|
"actions"
|
|
)
|
|
$requiredActionFields = @(
|
|
"action_key",
|
|
"status",
|
|
"severity",
|
|
"reason",
|
|
"derived_from",
|
|
"blocks_activation",
|
|
"allows_process_start",
|
|
"allows_payload_traffic"
|
|
)
|
|
$expectedActions = @(
|
|
[ordered]@{ action_key = "keep_real_adapter_disabled"; severity = "info"; derived_from = @("handoff_v4_complete", "mode_matrix_v3_compatible", "activation_blocked") },
|
|
[ordered]@{ action_key = "review_real_runtime_stage_gates"; severity = "warn"; derived_from = @("activation_blocked", "missing_gates_visible") },
|
|
[ordered]@{ action_key = "validate_real_adapter_config_projection"; severity = "info"; derived_from = @("requested_and_default_config_shapes_visible") },
|
|
[ordered]@{ action_key = "prepare_process_supervisor_preconditions"; severity = "warn"; derived_from = @("process_start_disabled") },
|
|
[ordered]@{ action_key = "prepare_process_health_probe_signals"; severity = "warn"; derived_from = @("health_probe_disabled", "missing_health_signals_visible") },
|
|
[ordered]@{ action_key = "keep_payload_forwarding_disabled"; severity = "info"; derived_from = @("payload_traffic_none") }
|
|
)
|
|
|
|
function Get-PropertyValue {
|
|
param([object]$Item, [string]$Name, [object]$Default = $null)
|
|
if ($null -eq $Item) { return $Default }
|
|
if ($Item -is [System.Collections.IDictionary]) {
|
|
if ($Item.Contains($Name)) { return $Item[$Name] }
|
|
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 ($Item -is [System.Collections.IDictionary]) {
|
|
if (-not $Item.Contains($field)) { return $false }
|
|
continue
|
|
}
|
|
if ($null -eq $Item.PSObject.Properties[$field]) { return $false }
|
|
}
|
|
return $true
|
|
}
|
|
|
|
function Test-ArrayItem {
|
|
param([object]$Items, [string]$Want)
|
|
foreach ($item in @($Items)) {
|
|
if ([string]$item -eq $Want) { return $true }
|
|
}
|
|
return $false
|
|
}
|
|
|
|
function Get-ActionByKey {
|
|
param([object[]]$Actions, [string]$Key)
|
|
return @($Actions | Where-Object { [string](Get-PropertyValue -Item $_ -Name "action_key" -Default "") -eq $Key } | Select-Object -First 1)
|
|
}
|
|
|
|
function Test-ActionDerivedFrom {
|
|
param([object]$Action, [object]$Expected)
|
|
$actual = @(Get-PropertyValue -Item $Action -Name "derived_from" -Default @())
|
|
$expectedItems = @(Get-PropertyValue -Item $Expected -Name "derived_from" -Default @())
|
|
if ($actual.Count -ne $expectedItems.Count) { return $false }
|
|
foreach ($item in $expectedItems) {
|
|
if (-not (Test-ArrayItem -Items $actual -Want ([string]$item))) { return $false }
|
|
}
|
|
return $true
|
|
}
|
|
|
|
function Test-ExpectedAction {
|
|
param([object]$Action, [object]$Expected)
|
|
if ($null -eq $Action) { return $false }
|
|
return (
|
|
(Test-ObjectHasFields -Item $Action -Fields $requiredActionFields) -and
|
|
[string](Get-PropertyValue -Item $Action -Name "action_key" -Default "") -eq [string](Get-PropertyValue -Item $Expected -Name "action_key" -Default "") -and
|
|
[string](Get-PropertyValue -Item $Action -Name "status" -Default "") -eq "blocked" -and
|
|
[string](Get-PropertyValue -Item $Action -Name "severity" -Default "") -eq [string](Get-PropertyValue -Item $Expected -Name "severity" -Default "") -and
|
|
[string](Get-PropertyValue -Item $Action -Name "reason" -Default "") -ne "" -and
|
|
(Test-ActionDerivedFrom -Action $Action -Expected $Expected) -and
|
|
[bool](Get-PropertyValue -Item $Action -Name "blocks_activation" -Default $false) -and
|
|
-not [bool](Get-PropertyValue -Item $Action -Name "allows_process_start" -Default $true) -and
|
|
-not [bool](Get-PropertyValue -Item $Action -Name "allows_payload_traffic" -Default $true)
|
|
)
|
|
}
|
|
|
|
& powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c19z59-remote-workspace-real-adapter-disabled-action-map-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
|
|
$actionMap = Get-PropertyValue -Item $sourceResult -Name "action_map" -Default $null
|
|
$actions = @((Get-PropertyValue -Item $actionMap -Name "actions" -Default @()))
|
|
$actionChecks = [ordered]@{}
|
|
foreach ($expected in $expectedActions) {
|
|
$key = [string](Get-PropertyValue -Item $expected -Name "action_key" -Default "")
|
|
$actionChecks[$key] = Test-ExpectedAction -Action (Get-ActionByKey -Actions $actions -Key $key) -Expected $expected
|
|
}
|
|
|
|
$actionMapFieldsCompatible = Test-ObjectHasFields -Item $actionMap -Fields $requiredActionMapFields
|
|
$actionMapValuesCompatible = (
|
|
[string](Get-PropertyValue -Item $actionMap -Name "schema_version" -Default "") -eq "rap.remote_workspace_real_adapter_disabled_runtime_operator_action_map.v1" -and
|
|
[string](Get-PropertyValue -Item $actionMap -Name "readiness_summary_schema" -Default "") -eq "rap.remote_workspace_real_adapter_disabled_runtime_readiness_summary.v1" -and
|
|
[string](Get-PropertyValue -Item $actionMap -Name "readiness_state" -Default "") -eq "blocked_until_real_runtime_stage" -and
|
|
[string](Get-PropertyValue -Item $actionMap -Name "operator_action" -Default "") -eq "keep_real_adapter_disabled" -and
|
|
[string](Get-PropertyValue -Item $actionMap -Name "activation_decision" -Default "") -eq "blocked" -and
|
|
-not [bool](Get-PropertyValue -Item $actionMap -Name "process_start_allowed" -Default $true) -and
|
|
-not [bool](Get-PropertyValue -Item $actionMap -Name "health_probe_enabled" -Default $true) -and
|
|
[string](Get-PropertyValue -Item $actionMap -Name "payload_traffic" -Default "") -eq "none" -and
|
|
[int](Get-PropertyValue -Item $actionMap -Name "action_count" -Default -1) -eq $expectedActions.Count
|
|
)
|
|
|
|
$checks = [ordered]@{
|
|
source_smoke_passed = ([bool]$sourceResult.passed)
|
|
source_schema_expected = ([string]$sourceResult.schema_version -eq "c19z59.remote_workspace_real_adapter_disabled_action_map_smoke.v1")
|
|
action_map_present = ($null -ne $actionMap)
|
|
action_map_fields_compatible = $actionMapFieldsCompatible
|
|
action_map_values_compatible = $actionMapValuesCompatible
|
|
action_count_expected = ($actions.Count -eq $expectedActions.Count)
|
|
required_action_fields_declared = ($requiredActionFields.Count -eq 8)
|
|
all_expected_actions_compatible = (@($actionChecks.GetEnumerator() | Where-Object { -not $_.Value }).Count -eq 0)
|
|
}
|
|
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
|
|
|
|
$result = [ordered]@{
|
|
schema_version = "c19z60.remote_workspace_real_adapter_disabled_action_map_compatibility_smoke.v1"
|
|
source_result_path = $sourceFile
|
|
cluster_id = $ClusterID
|
|
required_action_map_fields = $requiredActionMapFields
|
|
required_action_fields = $requiredActionFields
|
|
expected_actions = $expectedActions
|
|
action_checks = $actionChecks
|
|
action_map = $actionMap
|
|
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 "C19Z60 remote workspace real-adapter disabled action map compatibility smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')"
|
|
}
|
|
|
|
Write-Host "C19Z60 remote workspace real-adapter disabled action map compatibility smoke passed. Result: $fullResultPath"
|
|
$result
|