95 lines
4.1 KiB
PowerShell
95 lines
4.1 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]$ResultPath = "artifacts\c18z74-service-channel-remediation-execution-smoke-result.json"
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$repoRoot = (Resolve-Path (Join-Path $scriptDir "..\..")).ProviderPath
|
|
$c18z67 = Join-Path $scriptDir "c18z67-service-channel-concurrent-qos-live-smoke.ps1"
|
|
|
|
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 30)
|
|
}
|
|
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
|
|
}
|
|
|
|
& powershell -NoProfile -ExecutionPolicy Bypass -File $c18z67 | Out-Host
|
|
|
|
$c18z67ResultPath = Join-Path $repoRoot "artifacts\c18z67-service-channel-concurrent-qos-live-smoke-result.json"
|
|
$c18z67Result = Get-Content -Path $c18z67ResultPath -Raw | ConvertFrom-Json
|
|
$channelID = [string]$c18z67Result.channel_id
|
|
$replacementRouteID = [string]$c18z67Result.expected_replacement_route_id
|
|
|
|
$accessTelemetry = $null
|
|
$channel = $null
|
|
for ($i = 0; $i -lt 12; $i++) {
|
|
Start-Sleep -Seconds 5
|
|
$accessTelemetry = (Invoke-Api -Method GET -Path "/clusters/$ClusterID/fabric/service-channels/access-telemetry?actor_user_id=$ActorUserID&limit=50").fabric_service_channel_access_telemetry
|
|
$channel = @($accessTelemetry.active_channels | Where-Object { $_.channel_id -eq $channelID }) | Select-Object -First 1
|
|
if ($null -ne $channel -and [string](Get-PropertyValue -Item $channel -Name "remediation_execution_status" -Default "") -eq "applied") {
|
|
break
|
|
}
|
|
}
|
|
|
|
$command = Get-PropertyValue -Item $channel -Name "remediation_command" -Default $null
|
|
$checks = [ordered]@{
|
|
c18z67_regression_passed = [bool]$c18z67Result.passed
|
|
active_channel_found = ($null -ne $channel)
|
|
remediation_prefers_alternate = ($null -ne $channel -and [string](Get-PropertyValue -Item $channel -Name "remediation_action" -Default "") -eq "prefer_alternate_route")
|
|
remediation_execution_applied = ($null -ne $channel -and [string](Get-PropertyValue -Item $channel -Name "remediation_execution_status" -Default "") -eq "applied")
|
|
remediation_execution_generation_visible = ($null -ne $channel -and ([string](Get-PropertyValue -Item $channel -Name "remediation_execution_generation" -Default "")).Length -gt 0)
|
|
command_execution_applied = ($null -ne $command -and [string](Get-PropertyValue -Item $command -Name "execution_status" -Default "") -eq "applied")
|
|
command_replacement_matches = ($null -ne $command -and [string](Get-PropertyValue -Item $command -Name "replacement_route_id" -Default "") -eq $replacementRouteID)
|
|
}
|
|
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
|
|
|
|
$result = [ordered]@{
|
|
schema_version = "c18z74.service_channel_remediation_execution_smoke.v1"
|
|
run_id = "c18z74-" + (Get-Date -Format "yyyyMMdd-HHmmss")
|
|
cluster_id = $ClusterID
|
|
channel_id = $channelID
|
|
passed = ($failed.Count -eq 0)
|
|
checks = $checks
|
|
failed_checks = $failed
|
|
summary = [ordered]@{
|
|
c18z67_run_id = $c18z67Result.run_id
|
|
access_status = Get-PropertyValue -Item $accessTelemetry -Name "status" -Default ""
|
|
active_channel = $channel
|
|
}
|
|
}
|
|
|
|
$target = Join-Path $repoRoot $ResultPath
|
|
$result | ConvertTo-Json -Depth 60 | Set-Content -Path $target -Encoding UTF8
|
|
|
|
if (-not $result.passed) {
|
|
throw "C18Z74 remediation execution smoke failed: $($failed -join ', ')"
|
|
}
|
|
|
|
Write-Host "C18Z74 service-channel remediation execution smoke passed. Result: $target"
|
|
$result
|