135 lines
6.1 KiB
PowerShell
135 lines
6.1 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]$ResultPath = "artifacts\c19z48-remote-workspace-real-adapter-process-preconditions-compatibility-smoke-result.json"
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath
|
|
$sourceResultPath = "artifacts\c19z48-remote-workspace-real-adapter-process-preconditions-source-result.json"
|
|
$requiredChecks = @(
|
|
"real_runtime_stage_enabled",
|
|
"command_config_validated",
|
|
"workdir_config_validated",
|
|
"process_identity_policy_bound",
|
|
"fabric_service_channel_runtime_ready",
|
|
"payload_forwarding_contract_enabled",
|
|
"health_probe_contract_enabled"
|
|
)
|
|
$requiredFields = @(
|
|
"schema_version",
|
|
"process_start_allowed",
|
|
"reason",
|
|
"command_config_present",
|
|
"workdir_config_present",
|
|
"args_config_present",
|
|
"required_checks",
|
|
"missing_checks"
|
|
)
|
|
|
|
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-RequiredFields {
|
|
param([object]$Item)
|
|
if ($null -eq $Item) { return $false }
|
|
foreach ($field in $requiredFields) {
|
|
if ($null -eq $Item.PSObject.Properties[$field]) { return $false }
|
|
}
|
|
return $true
|
|
}
|
|
|
|
function Test-PreconditionContract {
|
|
param([object]$Preconditions, [bool]$CommandPresent, [bool]$ArgsPresent, [bool]$WorkdirPresent)
|
|
if ($null -eq $Preconditions) { return $false }
|
|
return (
|
|
(Test-RequiredFields -Item $Preconditions) -and
|
|
[string](Get-PropertyValue -Item $Preconditions -Name "schema_version" -Default "") -eq "rap.remote_workspace_real_adapter_process_supervisor_preconditions.v1" -and
|
|
-not [bool](Get-PropertyValue -Item $Preconditions -Name "process_start_allowed" -Default $true) -and
|
|
[string](Get-PropertyValue -Item $Preconditions -Name "reason" -Default "") -eq "disabled_until_real_runtime_stage" -and
|
|
[bool](Get-PropertyValue -Item $Preconditions -Name "command_config_present" -Default (-not $CommandPresent)) -eq $CommandPresent -and
|
|
[bool](Get-PropertyValue -Item $Preconditions -Name "args_config_present" -Default (-not $ArgsPresent)) -eq $ArgsPresent -and
|
|
[bool](Get-PropertyValue -Item $Preconditions -Name "workdir_config_present" -Default (-not $WorkdirPresent)) -eq $WorkdirPresent -and
|
|
(Test-RequiredItems -Items (Get-PropertyValue -Item $Preconditions -Name "required_checks" -Default @()) -Required $requiredChecks) -and
|
|
(Test-RequiredItems -Items (Get-PropertyValue -Item $Preconditions -Name "missing_checks" -Default @()) -Required $requiredChecks)
|
|
)
|
|
}
|
|
|
|
& powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c19z47-remote-workspace-real-adapter-process-preconditions-smoke.ps1") `
|
|
-ApiBaseUrl $ApiBaseUrl `
|
|
-ClusterID $ClusterID `
|
|
-ActorUserID $ActorUserID `
|
|
-RequestedNodeName $RequestedNodeName `
|
|
-DefaultNodeName $DefaultNodeName `
|
|
-ResultPath $sourceResultPath | Out-Null
|
|
|
|
$sourceFile = Join-Path $repoRoot $sourceResultPath
|
|
$sourceResult = Get-Content -Raw -Path $sourceFile | ConvertFrom-Json
|
|
$requestedPreconditions = Get-PropertyValue -Item $sourceResult -Name "requested_preconditions" -Default $null
|
|
$defaultPreconditions = Get-PropertyValue -Item $sourceResult -Name "default_preconditions" -Default $null
|
|
|
|
$checks = [ordered]@{
|
|
source_smoke_passed = ([bool]$sourceResult.passed)
|
|
source_schema_expected = ([string]$sourceResult.schema_version -eq "c19z47.remote_workspace_real_adapter_process_preconditions_smoke.v1")
|
|
requested_contract_compatible = (Test-PreconditionContract -Preconditions $requestedPreconditions -CommandPresent $true -ArgsPresent $true -WorkdirPresent $true)
|
|
default_contract_compatible = (Test-PreconditionContract -Preconditions $defaultPreconditions -CommandPresent $false -ArgsPresent $false -WorkdirPresent $false)
|
|
process_start_blocked_in_both = (
|
|
-not [bool](Get-PropertyValue -Item $requestedPreconditions -Name "process_start_allowed" -Default $true) -and
|
|
-not [bool](Get-PropertyValue -Item $defaultPreconditions -Name "process_start_allowed" -Default $true)
|
|
)
|
|
required_fields_declared = ($requiredFields.Count -eq 8)
|
|
required_checks_declared = ($requiredChecks.Count -eq 7)
|
|
}
|
|
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
|
|
|
|
$result = [ordered]@{
|
|
schema_version = "c19z48.remote_workspace_real_adapter_process_preconditions_compatibility_smoke.v1"
|
|
source_result_path = $sourceFile
|
|
cluster_id = $ClusterID
|
|
required_fields = $requiredFields
|
|
required_checks = $requiredChecks
|
|
requested_preconditions = $requestedPreconditions
|
|
default_preconditions = $defaultPreconditions
|
|
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 "C19Z48 remote workspace real-adapter process preconditions compatibility smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')"
|
|
}
|
|
|
|
Write-Host "C19Z48 remote workspace real-adapter process preconditions compatibility smoke passed. Result: $fullResultPath"
|
|
$result
|