94 lines
4.2 KiB
PowerShell
94 lines
4.2 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]$ExitNodeName = "test-2",
|
|
[string]$EntryBaseUrl = "http://192.168.200.61:19131",
|
|
[string]$ResultPath = "artifacts\c19z17-remote-workspace-mailbox-preflight-contract-smoke-result.json"
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath
|
|
$sourceResultPath = "artifacts\c19z17-remote-workspace-mailbox-preflight-contract-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 Test-ContractItem {
|
|
param([object]$Items, [string]$Want)
|
|
foreach ($item in @($Items)) {
|
|
if ([string]$item -eq $Want) { return $true }
|
|
}
|
|
return $false
|
|
}
|
|
|
|
function Test-PreflightContract {
|
|
param([object]$Sink, [string]$AdapterSessionID)
|
|
if ($null -eq $Sink) { return $false }
|
|
$readiness = Get-PropertyValue -Item $Sink -Name "adapter_runtime_readiness" -Default $null
|
|
$rollup = Get-PropertyValue -Item $readiness -Name "last_preflight" -Default $null
|
|
if ($null -eq $rollup) { return $false }
|
|
$contract = Get-PropertyValue -Item $rollup -Name "diagnostics_contract" -Default @()
|
|
return (
|
|
[string](Get-PropertyValue -Item $readiness -Name "adapter_session_id" -Default "") -eq $AdapterSessionID -and
|
|
[string](Get-PropertyValue -Item $rollup -Name "diagnostics_schema_version" -Default "") -eq "rap.remote_workspace_adapter_mailbox_preflight_diagnostics.v1" -and
|
|
(Test-ContractItem -Items $contract -Want "retained_window") -and
|
|
(Test-ContractItem -Items $contract -Want "remediation_checklist") -and
|
|
(Test-ContractItem -Items $contract -Want "attention") -and
|
|
(Test-ContractItem -Items $contract -Want "operator_counts")
|
|
)
|
|
}
|
|
|
|
$source = & powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c19z16-remote-workspace-mailbox-preflight-attention-reason-coverage-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 -Name "adapter_session_id" -Default "")
|
|
$observed = Get-PropertyValue -Item $sourceResult -Name "observed" -Default $null
|
|
|
|
$checks = [ordered]@{
|
|
source_smoke_passed = ([bool]$sourceResult.passed)
|
|
adapter_session_id_present = ($adapterSessionID -match "^rap-rw-adapter-session-[0-9a-f]{24}$")
|
|
workload_contract_visible = (Test-PreflightContract -Sink $observed.workload_sink -AdapterSessionID $adapterSessionID)
|
|
telemetry_contract_visible = (Test-PreflightContract -Sink $observed.telemetry_sink -AdapterSessionID $adapterSessionID)
|
|
}
|
|
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
|
|
|
|
$result = [ordered]@{
|
|
schema_version = "c19z17.remote_workspace_mailbox_preflight_contract_smoke.v1"
|
|
source_result_path = $sourceFile
|
|
cluster_id = $ClusterID
|
|
adapter_session_id = $adapterSessionID
|
|
observed = $observed
|
|
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 "C19Z17 remote workspace mailbox preflight contract smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')"
|
|
}
|
|
|
|
Write-Host "C19Z17 remote workspace mailbox preflight contract smoke passed. Result: $fullResultPath"
|
|
$result
|