# ============================================================================== # Start-StressInteractive.ps1 - Interactive Menu for Stability Harness # ============================================================================== # Ensure running as Administrator $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (-not $isAdmin) { Write-Host "[提示] 稳定性测试涉及杀系统服务与配置防火墙,正在自动请求管理员提权..." -ForegroundColor Yellow Start-Process powershell.exe -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs exit 0 } [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 try { $Host.UI.RawUI.WindowTitle = "ClassNotify 自动化无人值守极限稳定性压测套件" } catch {} Write-Host "==============================================================================" -ForegroundColor Cyan Write-Host " ClassNotify 自动化无人值守极限稳定性压测套件 (Commercial Pilot) " -ForegroundColor Cyan Write-Host "==============================================================================" -ForegroundColor Cyan Write-Host "" Write-Host " [1] QUICK 快速模式 (约 1.5~2 小时 / 快速回归与排查)" -ForegroundColor Yellow Write-Host " * 200 次通知 / 10 次强杀 WPF / 5 次杀服务 / 5 次断网 / 升降级各 1 次" Write-Host "" Write-Host " [2] STANDARD 标准极限验收模式 (两段式: Part A 加速混沌 + Part B 稳态浸润 / 跑满 6 小时)" -ForegroundColor Green Write-Host " * Part A: 1050 次通知轰炸 / 40 次杀 WPF / 20 次杀系统服务 / 25 次断网 / 升降级各 3 次" Write-Host " * Part B: 稳态低频教学浸润持续至满 360 分钟 / 稳态数据数学线性回归判定零内存泄漏" Write-Host "" Write-Host " [3] OVERNIGHT 隔夜静默浸润模式 (8~10 小时)" -ForegroundColor White Write-Host " * 睡觉挂机 / 监测待机内存、SignalR 心跳保活与日志文件增长" Write-Host "" Write-Host " [Q] 退出" -ForegroundColor Gray Write-Host "" Write-Host "==============================================================================" -ForegroundColor Cyan $choice = Read-Host "请选择要执行的压测模式 [1/2/3/Q]" $scenario = switch ($choice.Trim().ToUpper()) { "1" { "quick-2h" } "2" { "standard-6h" } "3" { "overnight" } "Q" { exit 0 } Default { Write-Host "输入无效,默认执行 [1] QUICK 快速排查模式..." -ForegroundColor Yellow "quick-2h" } } # Auto-detect target server URL from installed appsettings.json if available $detectedServerUrl = "https://classnotify.paradise.eu.org" $appSettingsPaths = @( "C:\Program Files\ClassNotify\appsettings.json", "C:\Program Files\ClassNotify\Service\appsettings.json", "C:\ProgramData\ClassNotify\appsettings.json", (Join-Path $PSScriptRoot "..\..\src\Windows\ClassNotify.Service\appsettings.json") ) foreach ($p in $appSettingsPaths) { if (Test-Path $p) { try { $json = Get-Content $p -Raw -ErrorAction SilentlyContinue | ConvertFrom-Json if ($json.ClassNotify.ServerUrl) { $uri = [System.Uri]$json.ClassNotify.ServerUrl $detectedServerUrl = "$($uri.Scheme)://$($uri.Host)" if ($uri.Port -and $uri.Port -ne 80 -and $uri.Port -ne 443) { $detectedServerUrl += ":$($uri.Port)" } break } } catch {} } } Write-Host "" Write-Host "------------------------------------------------------------------------------" -ForegroundColor DarkGray Write-Host " [测试目标服务器环境选择]:" -ForegroundColor Yellow Write-Host " [1] 默认云端服务 ($detectedServerUrl) [回车默认]" -ForegroundColor Green Write-Host " [2] 本地电脑开发端 (http://127.0.0.1:5000)" -ForegroundColor Yellow Write-Host " [3] 自定义输入服务器地址 (IP或内网域名)" -ForegroundColor White $serverChoice = Read-Host "请选择目标服务器 [1/2/3, 直接回车默认为 1]" $targetServerUrl = switch ($serverChoice.Trim()) { "2" { "http://127.0.0.1:5000" } "3" { $custom = Read-Host "请输入目标服务器基地址 (例如 http://192.168.1.100:5000)" if ($custom) { $custom.Trim().TrimEnd('/') } else { $detectedServerUrl } } Default { $detectedServerUrl } } Write-Host "" Write-Host "[启动] 正在执行模式: $scenario ..." -ForegroundColor Cyan Write-Host "[目标] 服务端基地址: $targetServerUrl" -ForegroundColor Cyan $orchestratorPath = Join-Path $PSScriptRoot "Run-Orchestrator.ps1" & $orchestratorPath -Scenario $scenario -ServerBaseUrl $targetServerUrl Write-Host "" Write-Host "==============================================================================" -ForegroundColor Green Write-Host "测试已完成!HTML 报表已在默认浏览器中打开。" -ForegroundColor Green Write-Host "==============================================================================" -ForegroundColor Green Write-Host "按任意键退出..." $null = [Console]::ReadKey($true)