Record project continuation changes
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
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\c19o-remote-workspace-adapter-session-snapshot-smoke-result.json"
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath
|
||||
$sourceResultPath = "artifacts\c19o-remote-workspace-adapter-session-source-result.json"
|
||||
|
||||
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 Get-SessionFromSnapshot {
|
||||
param([object]$Snapshot, [string]$AdapterSessionID)
|
||||
return @($Snapshot.sessions | Where-Object { [string](Get-PropertyValue -Item $_ -Name "adapter_session_id" -Default "") -eq $AdapterSessionID } | Select-Object -First 1)
|
||||
}
|
||||
|
||||
function Get-TerminalSessionFromSnapshot {
|
||||
param([object]$Snapshot, [string]$AdapterSessionID)
|
||||
return @($Snapshot.terminal_sessions | Where-Object { [string](Get-PropertyValue -Item $_ -Name "adapter_session_id" -Default "") -eq $AdapterSessionID } | Select-Object -First 1)
|
||||
}
|
||||
|
||||
$source = & powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c19i-remote-workspace-adapter-queue-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
|
||||
$adapterSessionID = [string](Get-PropertyValue -Item $sourceResult.droppable_overflow.body -Name "adapter_session_id" -Default "")
|
||||
|
||||
$snapshotUrl = "$EntryBaseUrl/mesh/v1/remote-workspace/adapter-sessions?include_terminal=true&limit=20"
|
||||
$activeSnapshot = Invoke-RestMethod -Method GET -Uri $snapshotUrl -TimeoutSec 30
|
||||
$activeSession = Get-SessionFromSnapshot -Snapshot $activeSnapshot -AdapterSessionID $adapterSessionID
|
||||
|
||||
$controlUrl = "$EntryBaseUrl/mesh/v1/remote-workspace/adapter-sessions/$adapterSessionID/control"
|
||||
$control = Invoke-RestMethod -Method POST -Uri $controlUrl -ContentType "application/json" -Body (@{
|
||||
action = "close"
|
||||
reason = "c19o snapshot terminal transition"
|
||||
} | ConvertTo-Json -Compress) -TimeoutSec 30
|
||||
|
||||
$terminalSnapshot = Invoke-RestMethod -Method GET -Uri $snapshotUrl -TimeoutSec 30
|
||||
$terminalSession = Get-TerminalSessionFromSnapshot -Snapshot $terminalSnapshot -AdapterSessionID $adapterSessionID
|
||||
$activeSessionAfterClose = Get-SessionFromSnapshot -Snapshot $terminalSnapshot -AdapterSessionID $adapterSessionID
|
||||
|
||||
$badLimit = $null
|
||||
try {
|
||||
Invoke-WebRequest -Method GET -Uri "$EntryBaseUrl/mesh/v1/remote-workspace/adapter-sessions?limit=bad" -TimeoutSec 30 | Out-Null
|
||||
$badLimit = [ordered]@{ status_code = 200; body = "" }
|
||||
} catch {
|
||||
$statusCode = $null
|
||||
if ($_.Exception.Response) { $statusCode = [int]$_.Exception.Response.StatusCode }
|
||||
$details = $_.ErrorDetails.Message
|
||||
if (-not $details) { $details = $_.Exception.Message }
|
||||
$badLimit = [ordered]@{ status_code = $statusCode; body = $details }
|
||||
}
|
||||
|
||||
$checks = [ordered]@{
|
||||
source_smoke_passed = ([bool]$sourceResult.passed)
|
||||
adapter_session_id_present = ($adapterSessionID -match "^rap-rw-adapter-session-[0-9a-f]{24}$")
|
||||
active_snapshot_schema = ([string]$activeSnapshot.schema_version -eq "rap.remote_workspace_adapter_session_snapshot.v1")
|
||||
active_snapshot_has_session = ($null -ne $activeSession -and [string]$activeSession.adapter_session_id -eq $adapterSessionID)
|
||||
active_snapshot_state = ($null -ne $activeSession -and [string]$activeSession.session_state -eq "backpressure")
|
||||
active_snapshot_counters = ($null -ne $activeSession -and [int64]$activeSession.delivery_count -ge 1 -and [int64]$activeSession.backpressure_count -ge 1 -and [int64]$activeSession.dropped_frames -ge 3)
|
||||
control_closed = ([bool]$control.accepted -and [string]$control.session_state -eq "closed")
|
||||
terminal_snapshot_schema = ([string]$terminalSnapshot.schema_version -eq "rap.remote_workspace_adapter_session_snapshot.v1")
|
||||
terminal_snapshot_has_session = ($null -ne $terminalSession -and [string]$terminalSession.adapter_session_id -eq $adapterSessionID)
|
||||
terminal_snapshot_state = ($null -ne $terminalSession -and [string]$terminalSession.session_state -eq "closed")
|
||||
terminal_snapshot_active_removed = ($null -eq $activeSessionAfterClose)
|
||||
bad_limit_rejected = ([int]$badLimit.status_code -eq 400 -and [string]$badLimit.body -match "invalid remote workspace adapter session snapshot limit")
|
||||
}
|
||||
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
|
||||
|
||||
$result = [ordered]@{
|
||||
schema_version = "c19o.remote_workspace_adapter_session_snapshot_smoke.v1"
|
||||
source_result_path = $sourceFile
|
||||
cluster_id = $ClusterID
|
||||
adapter_session_id = $adapterSessionID
|
||||
active_snapshot = $activeSnapshot
|
||||
control = $control
|
||||
terminal_snapshot = $terminalSnapshot
|
||||
bad_limit = $badLimit
|
||||
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 "C19O remote workspace adapter session snapshot smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')"
|
||||
}
|
||||
|
||||
Write-Host "C19O remote workspace adapter session snapshot smoke passed. Result: $fullResultPath"
|
||||
$result
|
||||
Reference in New Issue
Block a user