141 lines
6.9 KiB
PowerShell
141 lines
6.9 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\c19z65-remote-workspace-real-adapter-admin-handoff-digest-rollup-smoke-result.json"
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath
|
|
$sourceResultPath = "artifacts\c19z65-remote-workspace-real-adapter-admin-handoff-digest-rollup-source-result.json"
|
|
|
|
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 New-CountMap {
|
|
param([object[]]$Rows, [string]$Field)
|
|
$map = [ordered]@{}
|
|
foreach ($row in $Rows) {
|
|
$key = [string](Get-PropertyValue -Item $row -Name $Field -Default "")
|
|
if ($key -eq "") { $key = "unknown" }
|
|
if ($map.Contains($key)) { $map[$key] = [int]$map[$key] + 1 } else { $map[$key] = 1 }
|
|
}
|
|
return $map
|
|
}
|
|
|
|
function Get-MapInt {
|
|
param([object]$Map, [string]$Name)
|
|
if ($null -eq $Map) { return 0 }
|
|
$value = Get-PropertyValue -Item $Map -Name $Name -Default 0
|
|
return [int]$value
|
|
}
|
|
|
|
& powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c19z64-remote-workspace-real-adapter-admin-handoff-digest-compatibility-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
|
|
$digest = Get-PropertyValue -Item $sourceResult -Name "admin_handoff_digest" -Default $null
|
|
$rows = @((Get-PropertyValue -Item $digest -Name "display_rows" -Default @()))
|
|
$guardrails = Get-PropertyValue -Item $digest -Name "guardrails" -Default $null
|
|
$severityCounts = New-CountMap -Rows $rows -Field "severity"
|
|
$stateCounts = New-CountMap -Rows $rows -Field "state"
|
|
|
|
$rollup = [ordered]@{
|
|
schema_version = "rap.remote_workspace_real_adapter_admin_handoff_digest_rollup.v1"
|
|
source_digest_schema = Get-PropertyValue -Item $digest -Name "schema_version" -Default $null
|
|
rollup_status = "complete"
|
|
admin_status = Get-PropertyValue -Item $digest -Name "admin_status" -Default $null
|
|
primary_action = Get-PropertyValue -Item $digest -Name "admin_action" -Default $null
|
|
row_count = $rows.Count
|
|
counts_by_severity = $severityCounts
|
|
counts_by_state = $stateCounts
|
|
guardrail_summary = [ordered]@{
|
|
activation_blocked = Get-PropertyValue -Item $guardrails -Name "activation_blocked" -Default $null
|
|
process_start_allowed = Get-PropertyValue -Item $guardrails -Name "process_start_allowed" -Default $null
|
|
health_probe_enabled = Get-PropertyValue -Item $guardrails -Name "health_probe_enabled" -Default $null
|
|
payload_traffic = Get-PropertyValue -Item $guardrails -Name "payload_traffic" -Default $null
|
|
allows_process_start = Get-PropertyValue -Item $guardrails -Name "allows_process_start" -Default $null
|
|
allows_payload_traffic = Get-PropertyValue -Item $guardrails -Name "allows_payload_traffic" -Default $null
|
|
}
|
|
}
|
|
|
|
$severityCompatible = (
|
|
(Get-MapInt -Map $severityCounts -Name "warn") -eq 2 -and
|
|
(Get-MapInt -Map $severityCounts -Name "info") -eq 6
|
|
)
|
|
$stateCompatible = (
|
|
(Get-MapInt -Map $stateCounts -Name "blocked") -eq 3 -and
|
|
(Get-MapInt -Map $stateCounts -Name "disabled") -eq 3 -and
|
|
(Get-MapInt -Map $stateCounts -Name "required") -eq 1 -and
|
|
(Get-MapInt -Map $stateCounts -Name "complete") -eq 1
|
|
)
|
|
$guardrailsCompatible = (
|
|
[bool](Get-PropertyValue -Item $rollup.guardrail_summary -Name "activation_blocked" -Default $false) -and
|
|
-not [bool](Get-PropertyValue -Item $rollup.guardrail_summary -Name "process_start_allowed" -Default $true) -and
|
|
-not [bool](Get-PropertyValue -Item $rollup.guardrail_summary -Name "health_probe_enabled" -Default $true) -and
|
|
[string](Get-PropertyValue -Item $rollup.guardrail_summary -Name "payload_traffic" -Default "") -eq "none" -and
|
|
-not [bool](Get-PropertyValue -Item $rollup.guardrail_summary -Name "allows_process_start" -Default $true) -and
|
|
-not [bool](Get-PropertyValue -Item $rollup.guardrail_summary -Name "allows_payload_traffic" -Default $true)
|
|
)
|
|
$rollupValuesCompatible = (
|
|
[string](Get-PropertyValue -Item $rollup -Name "schema_version" -Default "") -eq "rap.remote_workspace_real_adapter_admin_handoff_digest_rollup.v1" -and
|
|
[string](Get-PropertyValue -Item $rollup -Name "source_digest_schema" -Default "") -eq "rap.remote_workspace_real_adapter_admin_handoff_digest.v1" -and
|
|
[string](Get-PropertyValue -Item $rollup -Name "rollup_status" -Default "") -eq "complete" -and
|
|
[string](Get-PropertyValue -Item $rollup -Name "admin_status" -Default "") -eq "not_ready" -and
|
|
[string](Get-PropertyValue -Item $rollup -Name "primary_action" -Default "") -eq "keep_real_adapter_disabled" -and
|
|
[int](Get-PropertyValue -Item $rollup -Name "row_count" -Default -1) -eq 8
|
|
)
|
|
|
|
$checks = [ordered]@{
|
|
source_smoke_passed = ([bool]$sourceResult.passed)
|
|
source_schema_expected = ([string]$sourceResult.schema_version -eq "c19z64.remote_workspace_real_adapter_admin_handoff_digest_compatibility_smoke.v1")
|
|
rollup_values_compatible = $rollupValuesCompatible
|
|
severity_counts_compatible = $severityCompatible
|
|
state_counts_compatible = $stateCompatible
|
|
guardrails_compatible = $guardrailsCompatible
|
|
}
|
|
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
|
|
|
|
$result = [ordered]@{
|
|
schema_version = "c19z65.remote_workspace_real_adapter_admin_handoff_digest_rollup_smoke.v1"
|
|
source_result_path = $sourceFile
|
|
cluster_id = $ClusterID
|
|
admin_handoff_digest_rollup = $rollup
|
|
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 "C19Z65 remote workspace real-adapter admin handoff digest rollup smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')"
|
|
}
|
|
|
|
Write-Host "C19Z65 remote workspace real-adapter admin handoff digest rollup smoke passed. Result: $fullResultPath"
|
|
$result
|