# HISTORICAL — k6 runner kept for reference. The canonical load test is wrk
# (load-test/run-wrk.sh). See load-test/README.md.
#
# Reads load-test/.env and runs k6 with all variables injected.
# Usage: .\load-test\run.ps1

$envFile = Join-Path $PSScriptRoot ".env"
$script  = Join-Path $PSScriptRoot "loadtest.js"

if (-not (Test-Path $envFile)) {
    Write-Error "Missing $envFile — copy .env.example and fill in your values."
    exit 1
}

$k6Args = @("run")

Get-Content $envFile | ForEach-Object {
    $line = $_.Trim()
    if ($line -and -not $line.StartsWith('#')) {
        $k6Args += "-e"
        $k6Args += $line
    }
}

$k6Args += $script

& k6 @k6Args
