122 lines
5.3 KiB
PowerShell
122 lines
5.3 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]$EntryNodeName = "test-1",
|
|
[string]$ResultPath = "artifacts\c19z36-remote-workspace-real-adapter-supervision-compatibility-smoke-result.json"
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath
|
|
$sourceResultPath = "artifacts\c19z36-remote-workspace-real-adapter-supervision-compatibility-source-result.json"
|
|
$requiredEnv = @(
|
|
"RAP_REMOTE_WORKSPACE_REAL_ADAPTER_ENABLED",
|
|
"RAP_REMOTE_WORKSPACE_REAL_ADAPTER_COMMAND",
|
|
"RAP_REMOTE_WORKSPACE_REAL_ADAPTER_ARGS_JSON",
|
|
"RAP_REMOTE_WORKSPACE_REAL_ADAPTER_WORKDIR"
|
|
)
|
|
$requiredStatusContract = @(
|
|
"schema_version",
|
|
"enabled",
|
|
"activation_state",
|
|
"execution_mode",
|
|
"payload_traffic",
|
|
"process_model",
|
|
"config_env",
|
|
"status_contract"
|
|
)
|
|
$requiredGuardrails = @(
|
|
"contract_probe_remains_default",
|
|
"no_payload_forwarding_until_real_runtime_stage",
|
|
"backend_relay_not_steady_state",
|
|
"fabric_service_channel_required"
|
|
)
|
|
|
|
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-ArrayItem {
|
|
param([object]$Items, [string]$Want)
|
|
foreach ($item in @($Items)) {
|
|
if ([string]$item -eq $Want) { return $true }
|
|
}
|
|
return $false
|
|
}
|
|
|
|
function Test-RequiredItems {
|
|
param([object]$Items, [string[]]$Required)
|
|
foreach ($item in $Required) {
|
|
if (-not (Test-ArrayItem -Items $Items -Want $item)) { return $false }
|
|
}
|
|
return $true
|
|
}
|
|
|
|
function Test-RealAdapterCompatibility {
|
|
param([object]$Contract)
|
|
if ($null -eq $Contract) { return $false }
|
|
return (
|
|
[string](Get-PropertyValue -Item $Contract -Name "schema_version" -Default "") -eq "rap.remote_workspace_real_adapter_supervision.v1" -and
|
|
-not [bool](Get-PropertyValue -Item $Contract -Name "enabled" -Default $true) -and
|
|
[string](Get-PropertyValue -Item $Contract -Name "activation_state" -Default "") -eq "disabled_until_real_runtime_stage" -and
|
|
[string](Get-PropertyValue -Item $Contract -Name "execution_mode" -Default "") -eq "real_adapter_supervision_disabled" -and
|
|
[string](Get-PropertyValue -Item $Contract -Name "payload_traffic" -Default "") -eq "none" -and
|
|
[string](Get-PropertyValue -Item $Contract -Name "process_model" -Default "") -eq "external_rdp_worker_process" -and
|
|
(Test-RequiredItems -Items (Get-PropertyValue -Item $Contract -Name "config_env" -Default @()) -Required $requiredEnv) -and
|
|
(Test-RequiredItems -Items (Get-PropertyValue -Item $Contract -Name "status_contract" -Default @()) -Required $requiredStatusContract) -and
|
|
(Test-RequiredItems -Items (Get-PropertyValue -Item $Contract -Name "guardrails" -Default @()) -Required $requiredGuardrails)
|
|
)
|
|
}
|
|
|
|
$source = & powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c19z35-remote-workspace-real-adapter-supervision-scaffold-smoke.ps1") `
|
|
-ApiBaseUrl $ApiBaseUrl `
|
|
-ClusterID $ClusterID `
|
|
-ActorUserID $ActorUserID `
|
|
-EntryNodeName $EntryNodeName `
|
|
-ResultPath $sourceResultPath
|
|
|
|
$sourceFile = Join-Path $repoRoot $sourceResultPath
|
|
$sourceResult = Get-Content -Raw -Path $sourceFile | ConvertFrom-Json
|
|
$status = Get-PropertyValue -Item $sourceResult -Name "workload_status" -Default $null
|
|
$payload = Get-PropertyValue -Item $status -Name "status_payload" -Default $null
|
|
$contract = Get-PropertyValue -Item $payload -Name "real_adapter_supervision" -Default $null
|
|
|
|
$checks = [ordered]@{
|
|
source_smoke_passed = ([bool]$sourceResult.passed)
|
|
contract_probe_remains_active = ([string](Get-PropertyValue -Item $payload -Name "execution_mode" -Default "") -eq "contract_probe")
|
|
payload_traffic_none = ([string](Get-PropertyValue -Item $payload -Name "traffic" -Default "") -eq "none")
|
|
real_adapter_contract_compatible = (Test-RealAdapterCompatibility -Contract $contract)
|
|
}
|
|
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
|
|
|
|
$result = [ordered]@{
|
|
schema_version = "c19z36.remote_workspace_real_adapter_supervision_compatibility_smoke.v1"
|
|
source_result_path = $sourceFile
|
|
cluster_id = $ClusterID
|
|
required_env = $requiredEnv
|
|
required_status_contract = $requiredStatusContract
|
|
required_guardrails = $requiredGuardrails
|
|
real_adapter_supervision = $contract
|
|
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 "C19Z36 remote workspace real-adapter supervision compatibility smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')"
|
|
}
|
|
|
|
Write-Host "C19Z36 remote workspace real-adapter supervision compatibility smoke passed. Result: $fullResultPath"
|
|
$result
|