You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

89 lines
2.7 KiB

param(
[ValidateSet("loadtest", "find-max-users")]
[string]$Mode = "loadtest",
[string]$Target = "http://localhost:8080",
[int]$Users = 200,
[string]$Duration = "30s",
[string]$RampUp = "10s",
[string]$Timeout = "5s",
[string]$WebSocketTimeout = "15s",
[double]$WebSocketRatio = 0.05,
[int]$WebSocketMaxConnections = 20,
[string]$MonitorInterval = "1s",
[string]$WebSocketCommand = "Get-Location",
[int]$SearchStartUsers = 100,
[int]$SearchStepUsers = 100,
[int]$SearchMaxUsers = 2000,
[double]$MaxFailureRate = 1.0,
[string]$MaxP95 = "1s",
[switch]$Insecure
)
$ScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$ProjectRoot = Split-Path -Parent $ScriptRoot
$RuntimeRoot = Join-Path $ProjectRoot "runtime"
$BinRoot = Join-Path $RuntimeRoot "bin"
$CacheRoot = Join-Path $RuntimeRoot "cache"
$GoCache = Join-Path $CacheRoot "go-build"
$GoTmp = Join-Path $CacheRoot "go-tmp"
$LoadTestExe = Join-Path $BinRoot "teraclone-loadtest.exe"
function Find-GoExecutable {
$candidates = @(
(Join-Path $env:ProgramFiles "Go\bin\go.exe"),
(Join-Path ${env:ProgramFiles(x86)} "Go\bin\go.exe"),
(Join-Path $env:USERPROFILE "go\bin\go.exe")
) | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }
foreach ($candidate in $candidates) {
if (Test-Path $candidate) {
return $candidate
}
}
$fromPath = Get-Command go.exe -ErrorAction SilentlyContinue
if ($null -ne $fromPath) {
return $fromPath.Source
}
throw "go.exe를 찾을 수 없습니다. Go를 설치하거나 PATH에 추가해주세요."
}
New-Item -ItemType Directory -Force -Path $BinRoot | Out-Null
New-Item -ItemType Directory -Force -Path $GoCache | Out-Null
New-Item -ItemType Directory -Force -Path $GoTmp | Out-Null
$env:GOCACHE = $GoCache
$env:GOTMPDIR = $GoTmp
$GoExe = Find-GoExecutable
& $GoExe build -buildvcs=false -o $LoadTestExe ./cmd/loadtest
if ($LASTEXITCODE -ne 0 -or -not (Test-Path $LoadTestExe)) {
Write-Host "부하 테스트 도구 빌드에 실패했습니다."
exit 1
}
$arguments = @(
"-mode", $Mode,
"-target", $Target,
"-users", $Users,
"-duration", $Duration,
"-ramp-up", $RampUp,
"-timeout", $Timeout,
"-ws-timeout", $WebSocketTimeout,
"-ws-ratio", $WebSocketRatio,
"-ws-max-conns", $WebSocketMaxConnections,
"-monitor-interval", $MonitorInterval,
"-ws-command", $WebSocketCommand,
"-search-start-users", $SearchStartUsers,
"-search-step-users", $SearchStepUsers,
"-search-max-users", $SearchMaxUsers,
"-max-failure-rate", $MaxFailureRate,
"-max-p95", $MaxP95
)
if ($Insecure) {
$arguments += "-insecure"
}
& $LoadTestExe @arguments