103 lines
4.9 KiB
PowerShell
103 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]$EntryNodeName = "test-1",
|
|
[string]$RelayNodeName = "test-3",
|
|
[string]$ExitNodeName = "test-2",
|
|
[string]$EntryBaseUrl = "http://192.168.200.61:19131",
|
|
[string]$DockerSSH = "test-docker",
|
|
[int]$InitialBatchCount = 12,
|
|
[int]$LearningBatchCount = 24,
|
|
[int]$PostChurnBatchCount = 24,
|
|
[int]$PacketsPerBatch = 8,
|
|
[int]$BatchDelayMilliseconds = 25,
|
|
[string]$ResultPath = "artifacts\c18z22-service-channel-rolling-feedback-smoke-result.json"
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$repoRoot = (Resolve-Path (Join-Path $scriptDir "..\..")).ProviderPath
|
|
$innerResultPath = "artifacts\c18z22-service-channel-rolling-feedback-inner-result.json"
|
|
$innerResultFullPath = Join-Path $repoRoot $innerResultPath
|
|
|
|
$backendRoot = Join-Path $repoRoot "backend"
|
|
Push-Location $backendRoot
|
|
try {
|
|
$unitTestOutput = & go test ./internal/modules/cluster -run "TestRecordHeartbeatUsesRollingQualityWindowForRouteFeedback|TestRecordHeartbeatPersistsServiceChannelRouteFeedbackForLaterLease" 2>&1
|
|
if ($LASTEXITCODE -ne 0) {
|
|
$unitText = ($unitTestOutput | Out-String)
|
|
throw "C18Z22 rolling feedback backend unit tests failed:`n$unitText"
|
|
}
|
|
} finally {
|
|
Pop-Location
|
|
}
|
|
|
|
& (Join-Path $scriptDir "c18z21-service-channel-rolling-quality-window-smoke.ps1") `
|
|
-ApiBaseUrl $ApiBaseUrl `
|
|
-ClusterID $ClusterID `
|
|
-ActorUserID $ActorUserID `
|
|
-EntryNodeName $EntryNodeName `
|
|
-RelayNodeName $RelayNodeName `
|
|
-ExitNodeName $ExitNodeName `
|
|
-EntryBaseUrl $EntryBaseUrl `
|
|
-DockerSSH $DockerSSH `
|
|
-InitialBatchCount $InitialBatchCount `
|
|
-LearningBatchCount $LearningBatchCount `
|
|
-PostChurnBatchCount $PostChurnBatchCount `
|
|
-PacketsPerBatch $PacketsPerBatch `
|
|
-BatchDelayMilliseconds $BatchDelayMilliseconds `
|
|
-ResultPath $innerResultPath
|
|
|
|
$result = Get-Content -Path $innerResultFullPath -Raw | ConvertFrom-Json
|
|
$entryNodeID = $result.entry_node.id
|
|
$liveRouteID = [string]$result.live_feedback.route_id
|
|
$routeFeedbackUrl = "$ApiBaseUrl/clusters/$ClusterID/fabric/service-channels/route-feedback?actor_user_id=$ActorUserID&reporter_node_id=$entryNodeID&route_id=$liveRouteID&service_class=vpn_packets&include_expired=true"
|
|
$feedbackResponse = Invoke-RestMethod -Method Get -Uri $routeFeedbackUrl -TimeoutSec 30
|
|
$feedbackItems = @($feedbackResponse.route_feedback)
|
|
$rollingFeedbackItems = @($feedbackItems | Where-Object {
|
|
$_.reasons -and @($_.reasons) -contains "service_channel_rolling_quality_window"
|
|
})
|
|
$healthyRollingItems = @($rollingFeedbackItems | Where-Object { $_.feedback_status -eq "healthy" })
|
|
$rollingPayloadItems = @($rollingFeedbackItems | Where-Object {
|
|
$_.payload -and $_.payload.PSObject.Properties["quality_window_sample_count"] -and [int]$_.payload.quality_window_sample_count -gt 0
|
|
})
|
|
|
|
$result.schema_version = "c18z22.service_channel_rolling_feedback_smoke.v1"
|
|
$result | Add-Member -NotePropertyName c18z22_checks -NotePropertyValue ([ordered]@{
|
|
unit_backend_rolling_feedback_contract_passed = ($unitTestOutput -join "`n").Contains("ok")
|
|
live_c18z21_still_passed = [bool]$result.passed
|
|
live_route_feedback_visible = ($feedbackItems.Count -gt 0)
|
|
live_rolling_feedback_reason_visible = ($rollingFeedbackItems.Count -gt 0)
|
|
live_healthy_rolling_feedback_visible = ($healthyRollingItems.Count -gt 0)
|
|
live_rolling_feedback_payload_visible = ($rollingPayloadItems.Count -gt 0)
|
|
}) -Force
|
|
$result | Add-Member -NotePropertyName c18z22_summary -NotePropertyValue ([ordered]@{
|
|
unit_test_output = ($unitTestOutput | Out-String).Trim()
|
|
route_feedback_count = $feedbackItems.Count
|
|
rolling_feedback_count = $rollingFeedbackItems.Count
|
|
healthy_rolling_feedback_count = $healthyRollingItems.Count
|
|
rolling_payload_count = $rollingPayloadItems.Count
|
|
backend_image = "rap-backend:fabric-service-channel-0.2.197"
|
|
node_agent_version = "0.2.196"
|
|
}) -Force
|
|
$result.passed = [bool]($result.passed -and
|
|
$result.c18z22_checks.unit_backend_rolling_feedback_contract_passed -and
|
|
$result.c18z22_checks.live_route_feedback_visible -and
|
|
$result.c18z22_checks.live_rolling_feedback_reason_visible -and
|
|
$result.c18z22_checks.live_healthy_rolling_feedback_visible -and
|
|
$result.c18z22_checks.live_rolling_feedback_payload_visible)
|
|
|
|
$resolvedResultPath = Join-Path $repoRoot $ResultPath
|
|
$result | ConvertTo-Json -Depth 100 | Set-Content -Path $resolvedResultPath -Encoding UTF8
|
|
Remove-Item -Path $innerResultFullPath -Force -ErrorAction SilentlyContinue
|
|
|
|
if (-not $result.passed) {
|
|
throw "C18Z22 rolling feedback smoke failed. Result: $resolvedResultPath"
|
|
}
|
|
|
|
Write-Host "C18Z22 service-channel rolling feedback smoke passed. Result: $resolvedResultPath"
|
|
$result
|