100 lines
4.9 KiB
PowerShell
100 lines
4.9 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]$ExpectedBackendImage = "rap-backend:fabric-service-channel-0.2.281-c18z109",
|
|
[string]$ExpectedNodeAgentImage = "rap-node-agent:0.2.270-c18z95",
|
|
[string]$ResultPath = "artifacts\c18z95-node-agent-blocked-fallback-telemetry-smoke-result.json"
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$repoRoot = (Resolve-Path (Join-Path $scriptDir "..\..")).ProviderPath
|
|
$runId = "c18z95-" + (Get-Date -Format "yyyyMMdd-HHmmss")
|
|
$baseResultPath = "artifacts\$runId-c18z92-base-result.json"
|
|
|
|
function Invoke-Api {
|
|
param([string]$Method, [string]$Path, [object]$Body = $null)
|
|
$params = @{ Method = $Method; Uri = "$ApiBaseUrl$Path"; TimeoutSec = 30 }
|
|
if ($null -ne $Body) {
|
|
$params.ContentType = "application/json"
|
|
$params.Body = ($Body | ConvertTo-Json -Depth 80)
|
|
}
|
|
return Invoke-RestMethod @params
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
& (Join-Path $scriptDir "c18z92-node-agent-disabled-compat-fallback-smoke.ps1") `
|
|
-ApiBaseUrl $ApiBaseUrl `
|
|
-ClusterID $ClusterID `
|
|
-ActorUserID $ActorUserID `
|
|
-ExpectedBackendImage $ExpectedBackendImage `
|
|
-ExpectedNodeAgentImage $ExpectedNodeAgentImage `
|
|
-ResultPath $baseResultPath | Out-Null
|
|
|
|
$baseResult = Get-Content (Join-Path $repoRoot $baseResultPath) -Raw | ConvertFrom-Json
|
|
$channelID = [string]$baseResult.channel_id
|
|
|
|
$accessTelemetry = $null
|
|
$activeChannel = $null
|
|
for ($i = 0; $i -lt 8; $i++) {
|
|
Start-Sleep -Seconds 5
|
|
$response = Invoke-Api -Method GET -Path "/clusters/$ClusterID/fabric/service-channels/access-telemetry?actor_user_id=$ActorUserID&limit=50"
|
|
$accessTelemetry = $response.fabric_service_channel_access_telemetry
|
|
$activeChannel = @($accessTelemetry.active_channels | Where-Object { [string](Get-PropertyValue -Item $_ -Name "channel_id" -Default "") -eq $channelID }) | Select-Object -First 1
|
|
if ($null -ne $activeChannel -and [int](Get-PropertyValue -Item $activeChannel -Name "entry_node_degraded_route_blocked_count" -Default 0) -ge 1) {
|
|
break
|
|
}
|
|
}
|
|
|
|
$incidents = (Invoke-Api -Method GET -Path "/clusters/$ClusterID/fabric/service-channels/rebuild-incidents?actor_user_id=$ActorUserID&limit=20").rebuild_incidents
|
|
$incident = @($incidents | Where-Object {
|
|
[string](Get-PropertyValue -Item $_ -Name "incident_source" -Default "") -eq "data_plane_contract" -and
|
|
[string](Get-PropertyValue -Item $_ -Name "channel_id" -Default "") -eq $channelID
|
|
}) | Select-Object -First 1
|
|
|
|
$checks = [ordered]@{
|
|
base_disabled_fallback_smoke_passed = [bool]$baseResult.passed
|
|
access_telemetry_reports_blocked_fallback = ($null -ne $accessTelemetry -and [int](Get-PropertyValue -Item $accessTelemetry -Name "degraded_route_blocked_count" -Default 0) -ge 1)
|
|
active_channel_reports_blocked_fallback = ($null -ne $activeChannel -and [int](Get-PropertyValue -Item $activeChannel -Name "entry_node_degraded_route_blocked_count" -Default 0) -ge 1)
|
|
active_channel_reports_violation_status = ($null -ne $activeChannel -and [string](Get-PropertyValue -Item $activeChannel -Name "entry_node_last_data_plane_violation_status" -Default "") -eq "degraded_route_blocked_by_policy")
|
|
incident_reports_blocked_fallback = ($null -ne $incident -and [string](Get-PropertyValue -Item $incident -Name "guard_status" -Default "") -eq "degraded_route_blocked_by_policy")
|
|
incident_action_reports_restore_route_or_policy = ($null -ne $incident -and [string](Get-PropertyValue -Item $incident -Name "recommended_operator_action" -Default "") -eq "restore_fabric_route_or_change_signed_backend_relay_policy_before_retry")
|
|
}
|
|
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
|
|
|
|
$result = [ordered]@{
|
|
schema_version = "c18z95.node_agent_blocked_fallback_telemetry_smoke.v1"
|
|
run_id = $runId
|
|
cluster_id = $ClusterID
|
|
channel_id = $channelID
|
|
passed = ($failed.Count -eq 0)
|
|
checks = $checks
|
|
failed_checks = $failed
|
|
summary = [ordered]@{
|
|
base_result_path = $baseResultPath
|
|
active_channel = $activeChannel
|
|
incident = $incident
|
|
}
|
|
}
|
|
|
|
$target = Join-Path $repoRoot $ResultPath
|
|
$result | ConvertTo-Json -Depth 80 | Set-Content -Path $target -Encoding UTF8
|
|
|
|
if (-not $result.passed) {
|
|
throw "C18Z95 node-agent blocked fallback telemetry smoke failed: $($failed -join ', ')"
|
|
}
|
|
|
|
Write-Host "C18Z95 node-agent blocked fallback telemetry smoke passed. Result: $target"
|
|
$result
|
|
|