1
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
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]$ExitNodeName = "test-2",
|
||||
[string]$EntryBaseUrl = "http://192.168.200.61:19131",
|
||||
[string]$ResultPath = "artifacts\c19z26-remote-workspace-terminal-summary-compatibility-smoke-result.json"
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath
|
||||
$sourceResultPath = "artifacts\c19z26-remote-workspace-terminal-summary-compatibility-source-result.json"
|
||||
$requiredFeatures = @("adapter_session_id", "session_state", "reason", "controlled_at")
|
||||
|
||||
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-TerminalSummaryCompatibility {
|
||||
param([object]$Sink, [string]$AdapterSessionID, [string]$TerminalState)
|
||||
if ($null -eq $Sink) { return $false }
|
||||
$readiness = Get-PropertyValue -Item $Sink -Name "adapter_runtime_readiness" -Default $null
|
||||
$summary = Get-PropertyValue -Item $readiness -Name "terminal_session_summary" -Default $null
|
||||
if ($null -eq $summary) { return $false }
|
||||
$contract = Get-PropertyValue -Item $summary -Name "summary_contract" -Default @()
|
||||
$features = Get-PropertyValue -Item $summary -Name "summary_features" -Default $null
|
||||
if ([string](Get-PropertyValue -Item $summary -Name "schema_version" -Default "") -ne "rap.remote_workspace_adapter_terminal_session_summary.v1") { return $false }
|
||||
if ([string](Get-PropertyValue -Item $summary -Name "adapter_session_id" -Default "") -ne $AdapterSessionID) { return $false }
|
||||
if ([string](Get-PropertyValue -Item $summary -Name "session_state" -Default "") -ne $TerminalState) { return $false }
|
||||
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 "c19z25-remote-workspace-terminal-summary-features-smoke.ps1") `
|
||||
-ApiBaseUrl $ApiBaseUrl `
|
||||
-ClusterID $ClusterID `
|
||||
-ActorUserID $ActorUserID `
|
||||
-EntryNodeName $EntryNodeName `
|
||||
-ExitNodeName $ExitNodeName `
|
||||
-EntryBaseUrl $EntryBaseUrl `
|
||||
-ResultPath $sourceResultPath
|
||||
|
||||
$sourceFile = Join-Path $repoRoot $sourceResultPath
|
||||
$sourceResult = Get-Content -Raw -Path $sourceFile | ConvertFrom-Json
|
||||
$sourceC19Z24 = Get-PropertyValue -Item $sourceResult -Name "source" -Default $null
|
||||
$sourceC19Z23 = Get-PropertyValue -Item $sourceC19Z24 -Name "source" -Default $null
|
||||
$sourceC19Z22 = Get-PropertyValue -Item $sourceC19Z23 -Name "source" -Default $null
|
||||
$expireProbe = Get-PropertyValue -Item $sourceC19Z22 -Name "expire_probe" -Default $null
|
||||
$resetProbe = Get-PropertyValue -Item $sourceC19Z22 -Name "reset_probe" -Default $null
|
||||
$expireObserved = Get-PropertyValue -Item $expireProbe -Name "observed" -Default $null
|
||||
$resetObserved = Get-PropertyValue -Item $resetProbe -Name "observed" -Default $null
|
||||
$expireSessionID = [string](Get-PropertyValue -Item $sourceResult -Name "expire_adapter_session_id" -Default "")
|
||||
$resetSessionID = [string](Get-PropertyValue -Item $sourceResult -Name "reset_adapter_session_id" -Default "")
|
||||
|
||||
$checks = [ordered]@{
|
||||
source_smoke_passed = ([bool]$sourceResult.passed)
|
||||
expire_adapter_session_id_present = ($expireSessionID -match "^rap-rw-adapter-session-[0-9a-f]{24}$")
|
||||
reset_adapter_session_id_present = ($resetSessionID -match "^rap-rw-adapter-session-[0-9a-f]{24}$")
|
||||
workload_expire_summary_compatibility = (Test-TerminalSummaryCompatibility -Sink $expireObserved.workload_sink -AdapterSessionID $expireSessionID -TerminalState "expired")
|
||||
telemetry_expire_summary_compatibility = (Test-TerminalSummaryCompatibility -Sink $expireObserved.telemetry_sink -AdapterSessionID $expireSessionID -TerminalState "expired")
|
||||
workload_reset_summary_compatibility = (Test-TerminalSummaryCompatibility -Sink $resetObserved.workload_sink -AdapterSessionID $resetSessionID -TerminalState "reset")
|
||||
telemetry_reset_summary_compatibility = (Test-TerminalSummaryCompatibility -Sink $resetObserved.telemetry_sink -AdapterSessionID $resetSessionID -TerminalState "reset")
|
||||
}
|
||||
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
|
||||
|
||||
$result = [ordered]@{
|
||||
schema_version = "c19z26.remote_workspace_terminal_summary_compatibility_smoke.v1"
|
||||
source_result_path = $sourceFile
|
||||
cluster_id = $ClusterID
|
||||
expire_adapter_session_id = $expireSessionID
|
||||
reset_adapter_session_id = $resetSessionID
|
||||
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 "C19Z26 remote workspace terminal-summary compatibility smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')"
|
||||
}
|
||||
|
||||
Write-Host "C19Z26 remote workspace terminal-summary compatibility smoke passed. Result: $fullResultPath"
|
||||
$result
|
||||
Reference in New Issue
Block a user