Record project continuation changes

This commit is contained in:
2026-05-12 21:02:29 +03:00
parent 3059d1d7a3
commit 8f69d53193
339 changed files with 101111 additions and 1769 deletions
@@ -0,0 +1,142 @@
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\c19z1-remote-workspace-mailbox-preflight-smoke-result.json"
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath
$sourceResultPath = "artifacts\c19z1-remote-workspace-mailbox-preflight-source-result.json"
$consumerID = "rdp-worker-probe"
$adapterSessionID = ""
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-Events {
param([object]$Item)
$events = Get-PropertyValue -Item $Item -Name "events" -Default $null
if ($null -eq $events) { return @() }
return @($events)
}
function Invoke-Preflight {
param([string]$SessionID, [string]$Query = "")
$url = "$EntryBaseUrl/mesh/v1/remote-workspace/adapter-sessions/$SessionID/mailbox/preflight$Query"
$response = Invoke-WebRequest -Method GET -Uri $url -TimeoutSec 35
$json = $null
if ($response.Content) { $json = $response.Content | ConvertFrom-Json }
return [ordered]@{ status_code = [int]$response.StatusCode; body = $response.Content; json = $json }
}
function Invoke-Consumers {
param([string]$SessionID)
$url = "$EntryBaseUrl/mesh/v1/remote-workspace/adapter-sessions/$SessionID/mailbox/consumers?limit=10"
$response = Invoke-WebRequest -Method GET -Uri $url -TimeoutSec 35
$json = $null
if ($response.Content) { $json = $response.Content | ConvertFrom-Json }
return [ordered]@{ status_code = [int]$response.StatusCode; body = $response.Content; json = $json }
}
function Invoke-Control {
param([string]$SessionID)
if ([string]::IsNullOrWhiteSpace($SessionID)) { return $null }
$url = "$EntryBaseUrl/mesh/v1/remote-workspace/adapter-sessions/$SessionID/control"
$body = @{ action = "close"; reason = "c19z1 mailbox preflight close" } | ConvertTo-Json -Compress
return Invoke-RestMethod -Method POST -Uri $url -ContentType "application/json" -Body $body -TimeoutSec 30
}
function Get-Consumer {
param([object]$Snapshot, [string]$ConsumerID)
$items = @(Get-PropertyValue -Item $Snapshot -Name "consumers" -Default @())
return @($items | Where-Object { [string](Get-PropertyValue -Item $_ -Name "consumer_id" -Default "") -eq $ConsumerID } | Select-Object -First 1)
}
try {
$source = & powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c19x-remote-workspace-mailbox-consumer-resume-smoke.ps1") `
-ApiBaseUrl $ApiBaseUrl `
-ClusterID $ClusterID `
-ActorUserID $ActorUserID `
-EntryNodeName $EntryNodeName `
-ExitNodeName $ExitNodeName `
-EntryBaseUrl $EntryBaseUrl `
-ResultPath $sourceResultPath `
-SkipClose
$sourceFile = Join-Path $repoRoot $sourceResultPath
$sourceResult = Get-Content -Raw -Path $sourceFile | ConvertFrom-Json
$adapterSessionID = [string](Get-PropertyValue -Item $sourceResult -Name "adapter_session_id" -Default "")
$baseline = Get-PropertyValue -Item $sourceResult -Name "baseline" -Default $null
$baselineEvents = @(Get-Events -Item (Get-PropertyValue -Item $baseline -Name "json" -Default $null))
$firstSequence = if ($baselineEvents.Count -ge 1) { [int64]$baselineEvents[0].sequence } else { 0 }
$secondSequence = if ($baselineEvents.Count -ge 2) { [int64]$baselineEvents[1].sequence } else { 0 }
$thirdSequence = if ($baselineEvents.Count -ge 3) { [int64]$baselineEvents[2].sequence } else { 0 }
$consumersBefore = Invoke-Consumers -SessionID $adapterSessionID
$consumerBefore = Get-Consumer -Snapshot $consumersBefore.json -ConsumerID $consumerID
$readBefore = [int64](Get-PropertyValue -Item $consumerBefore -Name "consumer_read_total" -Default -1)
$ackBefore = [int64](Get-PropertyValue -Item $consumerBefore -Name "consumer_ack_total" -Default -1)
$checkpointBefore = [int64](Get-PropertyValue -Item $consumerBefore -Name "consumer_checkpoint_sequence" -Default -1)
$ackSequenceBefore = [int64](Get-PropertyValue -Item $consumerBefore -Name "consumer_ack_sequence" -Default -1)
$preflightAck = Invoke-Preflight -SessionID $adapterSessionID -Query "?consumer_id=$consumerID&resume_from=ack&limit=1"
$preflightCheckpoint = Invoke-Preflight -SessionID $adapterSessionID -Query "?consumer_id=$consumerID&resume_from=checkpoint&limit=10"
$consumersAfter = Invoke-Consumers -SessionID $adapterSessionID
$consumerAfter = Get-Consumer -Snapshot $consumersAfter.json -ConsumerID $consumerID
$control = Invoke-Control -SessionID $adapterSessionID
$checks = [ordered]@{
source_smoke_passed = ([bool]$sourceResult.passed)
adapter_session_id_present = ($adapterSessionID -match "^rap-rw-adapter-session-[0-9a-f]{24}$")
baseline_sequences_visible = ($firstSequence -gt 0 -and $secondSequence -gt $firstSequence -and $thirdSequence -gt $secondSequence)
consumer_before_visible = ($readBefore -eq 4 -and $ackBefore -eq 1 -and $checkpointBefore -eq $thirdSequence -and $ackSequenceBefore -eq $firstSequence)
ack_preflight_window = ([int]$preflightAck.status_code -eq 200 -and [bool]$preflightAck.json.read_only -and [string]$preflightAck.json.resume_from -eq "ack" -and [int64]$preflightAck.json.resume_sequence -eq $firstSequence -and [int64]$preflightAck.json.after_sequence -eq $firstSequence -and [int]$preflightAck.json.expected_available_count -eq 2 -and [int]$preflightAck.json.expected_returned_count -eq 1 -and [int]$preflightAck.json.expected_skipped_count -eq 1 -and [int64]$preflightAck.json.first_expected_sequence -eq $secondSequence -and [int64]$preflightAck.json.last_expected_sequence -eq $secondSequence)
checkpoint_preflight_empty = ([int]$preflightCheckpoint.status_code -eq 200 -and [bool]$preflightCheckpoint.json.read_only -and [string]$preflightCheckpoint.json.resume_from -eq "checkpoint" -and [int64]$preflightCheckpoint.json.resume_sequence -eq $thirdSequence -and [int]$preflightCheckpoint.json.expected_available_count -eq 0 -and [int]$preflightCheckpoint.json.expected_returned_count -eq 0 -and [int]$preflightCheckpoint.json.expected_skipped_count -eq 3)
preflight_did_not_mutate_consumer = ([int64](Get-PropertyValue -Item $consumerAfter -Name "consumer_read_total" -Default -2) -eq $readBefore -and [int64](Get-PropertyValue -Item $consumerAfter -Name "consumer_ack_total" -Default -2) -eq $ackBefore -and [int64](Get-PropertyValue -Item $consumerAfter -Name "consumer_checkpoint_sequence" -Default -2) -eq $checkpointBefore -and [int64](Get-PropertyValue -Item $consumerAfter -Name "consumer_ack_sequence" -Default -2) -eq $ackSequenceBefore)
close_accepted = ([bool]$control.accepted -and [string]$control.session_state -eq "closed")
}
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
$result = [ordered]@{
schema_version = "c19z1.remote_workspace_mailbox_preflight_smoke.v1"
source_result_path = $sourceFile
cluster_id = $ClusterID
adapter_session_id = $adapterSessionID
source = $sourceResult
consumers_before = $consumersBefore
preflight_ack = $preflightAck
preflight_checkpoint = $preflightCheckpoint
consumers_after = $consumersAfter
control = $control
checks = $checks
failed_checks = $failed
passed = ($failed.Count -eq 0)
}
} finally {
if ($adapterSessionID) {
try { [void](Invoke-Control -SessionID $adapterSessionID) } catch {}
}
}
$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 "C19Z1 remote workspace mailbox preflight smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')"
}
Write-Host "C19Z1 remote workspace mailbox preflight smoke passed. Result: $fullResultPath"
$result