Record project continuation changes
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
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]$DockerSSH = "test-docker",
|
||||
[string]$ExpectedBackendImage = "rap-backend:fabric-service-channel-0.2.202",
|
||||
[string]$ResultPath = "artifacts\c18z27-service-channel-recovery-policy-smoke-result.json"
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$repoRoot = (Resolve-Path (Join-Path $scriptDir "..\..")).ProviderPath
|
||||
$backendRoot = Join-Path $repoRoot "backend"
|
||||
|
||||
Push-Location $backendRoot
|
||||
try {
|
||||
$unitTestOutput = & go test ./internal/modules/cluster -run "TestFabricServiceChannelRecoveryPolicyControlsPromotionAndPenalty|TestUpdateFabricServiceChannelRecoveryPolicyPersistsClusterMetadata|TestFabricServiceChannelRecoveryDemotionMarksRouteReason" 2>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$unitText = ($unitTestOutput | Out-String)
|
||||
throw "C18Z27 recovery policy backend unit tests failed:`n$unitText"
|
||||
}
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
$policyUrl = "$ApiBaseUrl/clusters/$ClusterID/fabric/service-channels/recovery-policy"
|
||||
$getUrl = "$policyUrl`?actor_user_id=$ActorUserID"
|
||||
$before = Invoke-RestMethod -Method Get -Uri $getUrl
|
||||
$beforePolicy = $before.fabric_service_channel_recovery_policy
|
||||
|
||||
$desired = @{
|
||||
actor_user_id = $ActorUserID
|
||||
hysteresis_penalty = 151
|
||||
promotion_min_samples = 65
|
||||
demotion_failure_threshold = 2
|
||||
demotion_drop_threshold = 2
|
||||
demotion_slow_threshold = 3
|
||||
demotion_rebuild_enabled = $true
|
||||
demotion_fenced_enabled = $true
|
||||
}
|
||||
$updated = Invoke-RestMethod -Method Put -Uri $policyUrl -ContentType "application/json" -Body ($desired | ConvertTo-Json -Depth 20)
|
||||
$updatedPolicy = $updated.fabric_service_channel_recovery_policy
|
||||
|
||||
$restore = @{
|
||||
actor_user_id = $ActorUserID
|
||||
hysteresis_penalty = 150
|
||||
promotion_min_samples = 64
|
||||
demotion_failure_threshold = 1
|
||||
demotion_drop_threshold = 1
|
||||
demotion_slow_threshold = 1
|
||||
demotion_rebuild_enabled = $true
|
||||
demotion_fenced_enabled = $true
|
||||
}
|
||||
$restored = Invoke-RestMethod -Method Put -Uri $policyUrl -ContentType "application/json" -Body ($restore | ConvertTo-Json -Depth 20)
|
||||
$restoredPolicy = $restored.fabric_service_channel_recovery_policy
|
||||
|
||||
$backendLine = (& ssh $DockerSSH "docker ps --format '{{.Names}} {{.Image}} {{.Status}}' | grep '^rap_test_backend '") | Out-String
|
||||
$backendImageOK = $backendLine.Contains($ExpectedBackendImage)
|
||||
$policyUpdatedOK = [int]$updatedPolicy.hysteresis_penalty -eq 151 -and
|
||||
[int]$updatedPolicy.promotion_min_samples -eq 65 -and
|
||||
[int]$updatedPolicy.demotion_failure_threshold -eq 2 -and
|
||||
[int]$updatedPolicy.demotion_slow_threshold -eq 3
|
||||
$policyRestoredOK = [int]$restoredPolicy.hysteresis_penalty -eq 150 -and
|
||||
[int]$restoredPolicy.promotion_min_samples -eq 64 -and
|
||||
[int]$restoredPolicy.demotion_failure_threshold -eq 1
|
||||
|
||||
$result = [ordered]@{
|
||||
schema_version = "c18z27.service_channel_recovery_policy_smoke.v1"
|
||||
passed = [bool]($backendImageOK -and $policyUpdatedOK -and $policyRestoredOK)
|
||||
checks = [ordered]@{
|
||||
unit_recovery_policy_contract_passed = ($unitTestOutput -join "`n").Contains("ok")
|
||||
backend_expected_image_deployed = $backendImageOK
|
||||
recovery_policy_update_api_applied = $policyUpdatedOK
|
||||
recovery_policy_restored_defaults = $policyRestoredOK
|
||||
}
|
||||
summary = [ordered]@{
|
||||
unit_test_output = ($unitTestOutput | Out-String).Trim()
|
||||
backend_container = $backendLine.Trim()
|
||||
expected_backend_image = $ExpectedBackendImage
|
||||
before_policy = $beforePolicy
|
||||
updated_policy = $updatedPolicy
|
||||
restored_policy = $restoredPolicy
|
||||
}
|
||||
}
|
||||
|
||||
$resolvedResultPath = Join-Path $repoRoot $ResultPath
|
||||
$result | ConvertTo-Json -Depth 100 | Set-Content -Path $resolvedResultPath -Encoding UTF8
|
||||
|
||||
if (-not $result.passed) {
|
||||
throw "C18Z27 recovery policy smoke failed. Result: $resolvedResultPath"
|
||||
}
|
||||
|
||||
Write-Host "C18Z27 service-channel recovery policy smoke passed. Result: $resolvedResultPath"
|
||||
$result
|
||||
Reference in New Issue
Block a user