Record project continuation changes
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
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\c19p-remote-workspace-adapter-runtime-mailbox-smoke-result.json"
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath
|
||||
$sourceResultPath = "artifacts\c19p-remote-workspace-adapter-runtime-mailbox-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)
|
||||
}
|
||||
|
||||
$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 "")
|
||||
|
||||
$mailboxUrl = "$EntryBaseUrl/mesh/v1/remote-workspace/adapter-sessions/$adapterSessionID/mailbox?limit=10"
|
||||
$mailbox = Invoke-RestMethod -Method GET -Uri $mailboxUrl -TimeoutSec 30
|
||||
$drainedMailbox = Invoke-RestMethod -Method GET -Uri "$mailboxUrl&drain=true" -TimeoutSec 30
|
||||
$postDrainMailbox = Invoke-RestMethod -Method GET -Uri $mailboxUrl -TimeoutSec 30
|
||||
$postDrainEventCount = if ($null -eq $postDrainMailbox.events) { 0 } else { @($postDrainMailbox.events).Count }
|
||||
$snapshot = Invoke-RestMethod -Method GET -Uri "$EntryBaseUrl/mesh/v1/remote-workspace/adapter-sessions?include_terminal=true&limit=20" -TimeoutSec 30
|
||||
$snapshotSession = Get-SessionFromSnapshot -Snapshot $snapshot -AdapterSessionID $adapterSessionID
|
||||
|
||||
$events = @($mailbox.events)
|
||||
$drainedEvents = @($drainedMailbox.events)
|
||||
$checks = [ordered]@{
|
||||
source_smoke_passed = ([bool]$sourceResult.passed)
|
||||
adapter_session_id_present = ($adapterSessionID -match "^rap-rw-adapter-session-[0-9a-f]{24}$")
|
||||
mailbox_schema = ([string]$mailbox.schema_version -eq "rap.remote_workspace_adapter_mailbox_snapshot.v1")
|
||||
mailbox_has_delivery_event = (@($events | Where-Object { [string](Get-PropertyValue -Item $_ -Name "event" -Default "") -eq "frame_batch_probe_delivered" }).Count -ge 1)
|
||||
mailbox_has_backpressure_event = (@($events | Where-Object { [string](Get-PropertyValue -Item $_ -Name "event" -Default "") -eq "backpressure" }).Count -ge 1)
|
||||
mailbox_depth = ([int]$mailbox.mailbox_depth -ge 2 -and [int]$mailbox.depth_after -eq [int]$mailbox.mailbox_depth)
|
||||
drain_returned_events = ([bool]$drainedMailbox.drained -and @($drainedEvents).Count -ge 2)
|
||||
drain_depth_zero = ([int]$drainedMailbox.depth_after -eq 0)
|
||||
post_drain_empty = ([int]$postDrainMailbox.mailbox_depth -eq 0 -and $postDrainEventCount -eq 0)
|
||||
snapshot_mailbox_drained_visible = ($null -ne $snapshotSession -and [int]$snapshotSession.mailbox_depth -eq 0 -and [int64]$snapshotSession.mailbox_enqueued_total -ge 2 -and [int64]$snapshotSession.mailbox_drained_total -ge 2)
|
||||
}
|
||||
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
|
||||
|
||||
$result = [ordered]@{
|
||||
schema_version = "c19p.remote_workspace_adapter_runtime_mailbox_smoke.v1"
|
||||
source_result_path = $sourceFile
|
||||
cluster_id = $ClusterID
|
||||
adapter_session_id = $adapterSessionID
|
||||
mailbox = $mailbox
|
||||
drained_mailbox = $drainedMailbox
|
||||
post_drain_mailbox = $postDrainMailbox
|
||||
snapshot_session = $snapshotSession
|
||||
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 "C19P remote workspace adapter runtime mailbox smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')"
|
||||
}
|
||||
|
||||
Write-Host "C19P remote workspace adapter runtime mailbox smoke passed. Result: $fullResultPath"
|
||||
$result
|
||||
Reference in New Issue
Block a user