From 403fd6e55432dfd298280f8ed61b1eb79a7d7f37 Mon Sep 17 00:00:00 2001 From: QiuSW <105186638@qq.com> Date: Sat, 8 Aug 2026 09:52:28 +0800 Subject: [PATCH] fix(lab): bound T-014 process cleanup [T-014] --- Sense/scripts/t014-capacity.ps1 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Sense/scripts/t014-capacity.ps1 b/Sense/scripts/t014-capacity.ps1 index 2556949..7ecdd33 100644 --- a/Sense/scripts/t014-capacity.ps1 +++ b/Sense/scripts/t014-capacity.ps1 @@ -125,6 +125,20 @@ function Stop-ManagedProcess($Managed) { } } +function Stop-AllManagedProcesses($Items) { + $processes = @($Items | Where-Object { $null -ne $_ -and $null -ne $_.Process }) + foreach ($item in $processes) { + if (-not $item.Process.HasExited) { + $item.Process.Kill() + } + } + foreach ($item in $processes) { + if (-not $item.Process.HasExited) { + $item.Process.WaitForExit(10000) | Out-Null + } + } +} + function Assert-Alive($Managed) { if ($null -eq $Managed -or $Managed.Process.HasExited) { $code = if ($null -eq $Managed) { 'not-started' } else { $Managed.Process.ExitCode } @@ -879,9 +893,7 @@ catch { $failure = "T-014 stage '$stage' failed: $($_.Exception.Message)" } finally { - foreach ($item in @($managed)) { - Stop-ManagedProcess $item - } + Stop-AllManagedProcesses @($managed) if ($postgresStarted) { & $script:pgCtl '-D' $pgData '-m' 'fast' '-w' 'stop' | Out-Null $postgresStopped = $LASTEXITCODE -eq 0