Record project continuation changes
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
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]$NonPreferredEntryNodeName = "test-2",
|
||||
[string]$ExitNodeName = "test-3",
|
||||
[string]$NonPreferredExitNodeName = "test-2",
|
||||
[string]$ResultPath = "artifacts\c18z72-service-channel-pool-policy-smoke-result.json"
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$repoRoot = (Resolve-Path (Join-Path $scriptDir "..\..")).ProviderPath
|
||||
|
||||
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 Select-NodeByName {
|
||||
param([object[]]$Nodes, [string]$Name)
|
||||
$node = @($Nodes | Where-Object { $_.name -eq $Name }) | Select-Object -First 1
|
||||
if ($null -eq $node) {
|
||||
throw "node '$Name' not found"
|
||||
}
|
||||
return $node
|
||||
}
|
||||
|
||||
$nodes = (Invoke-Api -Method GET -Path "/clusters/$ClusterID/nodes?actor_user_id=$ActorUserID").nodes
|
||||
$entryNode = Select-NodeByName -Nodes $nodes -Name $EntryNodeName
|
||||
$otherEntryNode = Select-NodeByName -Nodes $nodes -Name $NonPreferredEntryNodeName
|
||||
$exitNode = Select-NodeByName -Nodes $nodes -Name $ExitNodeName
|
||||
$otherExitNode = Select-NodeByName -Nodes $nodes -Name $NonPreferredExitNodeName
|
||||
|
||||
$policy = (Invoke-Api -Method PUT -Path "/clusters/$ClusterID/fabric/service-channels/pool-policy" -Body @{
|
||||
actor_user_id = $ActorUserID
|
||||
entry_pool_node_ids = @($entryNode.id)
|
||||
exit_pool_node_ids = @($exitNode.id)
|
||||
preferred_entry_node_id = $entryNode.id
|
||||
preferred_exit_node_id = $exitNode.id
|
||||
selection_strategy = "preferred_first"
|
||||
route_rebuild = "automatic"
|
||||
entry_failover = "automatic"
|
||||
exit_failover = "automatic"
|
||||
backend_fallback_allowed = $true
|
||||
sticky_session = $true
|
||||
}).fabric_service_channel_pool_policy
|
||||
|
||||
$lease = (Invoke-Api -Method POST -Path "/clusters/$ClusterID/fabric/service-channels/leases" -Body @{
|
||||
actor_user_id = $ActorUserID
|
||||
organization_id = "c18z72-org"
|
||||
user_id = "c18z72-user"
|
||||
resource_id = "c18z72-pool-policy-smoke"
|
||||
service_class = "vpn_packets"
|
||||
entry_node_ids = @($otherEntryNode.id, $entryNode.id)
|
||||
exit_node_ids = @($otherExitNode.id, $exitNode.id)
|
||||
allowed_channels = @("vpn_packet", "fabric_control")
|
||||
ttl_seconds = 5
|
||||
}).fabric_service_channel_lease
|
||||
|
||||
$entryPoolIDs = @($lease.entry_pool | ForEach-Object { $_.node_id })
|
||||
$exitPoolIDs = @($lease.exit_pool | ForEach-Object { $_.node_id })
|
||||
$checks = [ordered]@{
|
||||
policy_fingerprint_persisted = ([string]$policy.fingerprint).Length -gt 0
|
||||
selected_entry_from_policy = ([string]$lease.selected_entry_node_id -eq [string]$entryNode.id)
|
||||
selected_exit_from_policy = ([string]$lease.selected_exit_node_id -eq [string]$exitNode.id)
|
||||
entry_pool_constrained = ($entryPoolIDs.Count -eq 1 -and $entryPoolIDs[0] -eq [string]$entryNode.id)
|
||||
exit_pool_constrained = ($exitPoolIDs.Count -eq 1 -and $exitPoolIDs[0] -eq [string]$exitNode.id)
|
||||
lease_has_pool_policy = ($null -ne $lease.pool_policy -and [string]$lease.pool_policy.fingerprint -eq [string]$policy.fingerprint)
|
||||
authority_payload_present = ([string]$lease.authority_payload).Length -gt 0
|
||||
}
|
||||
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
|
||||
|
||||
$result = [ordered]@{
|
||||
schema_version = "c18z72.service_channel_pool_policy_smoke.v1"
|
||||
run_id = "c18z72-" + (Get-Date -Format "yyyyMMdd-HHmmss")
|
||||
cluster_id = $ClusterID
|
||||
passed = ($failed.Count -eq 0)
|
||||
checks = $checks
|
||||
failed_checks = $failed
|
||||
summary = [ordered]@{
|
||||
policy = $policy
|
||||
lease = $lease
|
||||
entry_pool_ids = $entryPoolIDs
|
||||
exit_pool_ids = $exitPoolIDs
|
||||
}
|
||||
}
|
||||
|
||||
$target = Join-Path $repoRoot $ResultPath
|
||||
$result | ConvertTo-Json -Depth 60 | Set-Content -Path $target -Encoding UTF8
|
||||
|
||||
try {
|
||||
Start-Sleep -Seconds 6
|
||||
Invoke-Api -Method POST -Path "/clusters/$ClusterID/fabric/service-channels/leases/cleanup" -Body @{
|
||||
actor_user_id = $ActorUserID
|
||||
limit = 50
|
||||
} | Out-Null
|
||||
Invoke-Api -Method PUT -Path "/clusters/$ClusterID/fabric/service-channels/pool-policy" -Body @{
|
||||
actor_user_id = $ActorUserID
|
||||
entry_pool_node_ids = @()
|
||||
exit_pool_node_ids = @()
|
||||
preferred_entry_node_id = ""
|
||||
preferred_exit_node_id = ""
|
||||
selection_strategy = "fastest_healthy"
|
||||
route_rebuild = "automatic"
|
||||
entry_failover = "automatic"
|
||||
exit_failover = "automatic"
|
||||
backend_fallback_allowed = $true
|
||||
sticky_session = $true
|
||||
} | Out-Null
|
||||
} catch {
|
||||
Write-Warning "failed to restore default pool policy after smoke: $($_.Exception.Message)"
|
||||
}
|
||||
|
||||
if (-not $result.passed) {
|
||||
throw "C18Z72 pool policy smoke failed: $($failed -join ', ')"
|
||||
}
|
||||
|
||||
Write-Host "C18Z72 service-channel pool policy smoke passed. Result: $target"
|
||||
$result
|
||||
Reference in New Issue
Block a user