97 lines
4.4 KiB
PowerShell
97 lines
4.4 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\c19z30-remote-workspace-no-session-summary-compatibility-smoke-result.json"
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath
|
|
$sourceResultPath = "artifacts\c19z30-remote-workspace-no-session-summary-compatibility-source-result.json"
|
|
$requiredFeatures = @("status", "diagnostic_state", "active_session_count", "terminal_session_count")
|
|
|
|
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-ContractItem {
|
|
param([object]$Items, [string]$Want)
|
|
foreach ($item in @($Items)) {
|
|
if ([string]$item -eq $Want) { return $true }
|
|
}
|
|
return $false
|
|
}
|
|
|
|
function Test-FeatureFlag {
|
|
param([object]$Features, [string]$Name)
|
|
return ([bool](Get-PropertyValue -Item $Features -Name $Name -Default $false))
|
|
}
|
|
|
|
function Test-NoSessionSummaryCompatibility {
|
|
param([object]$Sink)
|
|
if ($null -eq $Sink) { return $false }
|
|
$readiness = Get-PropertyValue -Item $Sink -Name "adapter_runtime_readiness" -Default $null
|
|
$summary = Get-PropertyValue -Item $readiness -Name "no_session_summary" -Default $null
|
|
if ($null -eq $summary) { return $false }
|
|
if ([string](Get-PropertyValue -Item $summary -Name "schema_version" -Default "") -ne "rap.remote_workspace_adapter_no_session_summary.v1") { return $false }
|
|
if ([string](Get-PropertyValue -Item $summary -Name "status" -Default "") -ne "idle") { return $false }
|
|
if ([string](Get-PropertyValue -Item $summary -Name "diagnostic_state" -Default "") -ne "waiting_for_session") { return $false }
|
|
if ([int](Get-PropertyValue -Item $summary -Name "active_session_count" -Default -1) -ne 0) { return $false }
|
|
if ([int](Get-PropertyValue -Item $summary -Name "terminal_session_count" -Default -1) -ne 0) { return $false }
|
|
$contract = Get-PropertyValue -Item $summary -Name "summary_contract" -Default @()
|
|
$features = Get-PropertyValue -Item $summary -Name "summary_features" -Default $null
|
|
foreach ($feature in $requiredFeatures) {
|
|
if (-not (Test-ContractItem -Items $contract -Want $feature)) { return $false }
|
|
if (-not (Test-FeatureFlag -Features $features -Name $feature)) { return $false }
|
|
}
|
|
return $true
|
|
}
|
|
|
|
$source = & powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c19z29-remote-workspace-no-session-summary-features-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
|
|
$observed = Get-PropertyValue -Item $sourceResult -Name "observed" -Default $null
|
|
|
|
$checks = [ordered]@{
|
|
source_smoke_passed = ([bool]$sourceResult.passed)
|
|
workload_no_session_summary_compatibility = (Test-NoSessionSummaryCompatibility -Sink $observed.workload_sink)
|
|
telemetry_no_session_summary_compatibility = (Test-NoSessionSummaryCompatibility -Sink $observed.telemetry_sink)
|
|
}
|
|
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
|
|
|
|
$result = [ordered]@{
|
|
schema_version = "c19z30.remote_workspace_no_session_summary_compatibility_smoke.v1"
|
|
source_result_path = $sourceFile
|
|
cluster_id = $ClusterID
|
|
required_features = $requiredFeatures
|
|
source = $sourceResult
|
|
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 "C19Z30 remote workspace no-session summary compatibility smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')"
|
|
}
|
|
|
|
Write-Host "C19Z30 remote workspace no-session summary compatibility smoke passed. Result: $fullResultPath"
|
|
$result
|