param( [string]$Image = "mtusi-messenger:lab1", [string]$Container = "mtusi-messenger-lab1", [string]$BaseUrl = "http://127.0.0.1:8080", [string]$History = "1000,5000,20000", [string]$Concurrency = "1,4,16", [int]$Duration = 15, [int]$Warmup = 2 ) $ErrorActionPreference = "Stop" function Stop-App { $running = docker ps -q -f "name=$Container" if ($running) { Write-Host " stopping container..." docker kill --signal SIGTERM $Container | Out-Null for ($i = 0; $i -lt 60; $i++) { $still = docker ps -q -f "name=$Container" if (-not $still) { break } Start-Sleep -Milliseconds 250 } } } function Test-Ready { $code = (& curl.exe -s -o NUL -m 2 -w "%{http_code}" "$BaseUrl/health/ready" 2>$null) return ("$code".Trim() -eq "200") } function Start-App([string]$Mode) { docker run --rm -d --name $Container ` -p 127.0.0.1:8080:8080 ` -e HOST=0.0.0.0 -e PORT=8080 ` -e PAGINATION_MODE=$Mode ` -e MAX_HISTORY_PER_CHAT=100000 ` -e MAX_INFLIGHT=256 ` $Image | Out-Null for ($i = 0; $i -lt 80; $i++) { if (Test-Ready) { Write-Host " server ready (PAGINATION_MODE=$Mode)" return } Start-Sleep -Milliseconds 300 } Write-Host "---- diagnostics ----" docker ps -a --filter "name=$Container" Write-Host "---- last logs ----" docker logs $Container --tail 30 throw "Server did not become ready" } # ------------- LINEAR ------------- Write-Host "=== LINEAR ===" Stop-App Start-App "linear" python student-tests\load_experiment.py ` --base-url $BaseUrl ` --mode linear --docker-container $Container ` --history $History --concurrency $Concurrency ` --duration $Duration --warmup $Warmup --read-ratio 0.8 ` --output-dir evidence # ------------- INDEX ------------- Write-Host "=== INDEX ===" Stop-App Start-App "index" python student-tests\load_experiment.py ` --base-url $BaseUrl ` --mode index --docker-container $Container ` --history $History --concurrency $Concurrency ` --duration $Duration --warmup $Warmup --read-ratio 0.8 ` --output-dir evidence Stop-App Write-Host "" Write-Host "DONE. See evidence\linear_summary.json and evidence\index_summary.json"