Refactor load testing scripts to support Bash and PowerShell
- Updated README.md to reflect changes in load testing commands and added usage examples for Bash scripts. - Converted PowerShell load testing scripts to Bash equivalents for better cross-platform compatibility. - Added new Bash scripts: run-loadtests.sh, summarize-artillery.sh, and summarize-k6.sh to mirror existing PowerShell functionality. - Updated admin-api.js and ws-chat.yml for consistency and improved performance metrics reporting. - Enhanced error handling and output formatting in summary scripts for better readability.
This commit is contained in:
1 parent
9f60087a4c
commit
33b6296c5e
82 files changed
+19682
-21133
No files matched your search
@@ -1,115 +1,115 @@
|
||||
#!/usr/bin/env pwsh
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$ReportFile
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
if (-not (Test-Path $ReportFile)) {
|
||||
throw "Report file not found: $ReportFile"
|
||||
}
|
||||
|
||||
$report = Get-Content -Raw -Path $ReportFile | ConvertFrom-Json -Depth 100
|
||||
$aggregate = $report.aggregate
|
||||
|
||||
if (-not $aggregate) {
|
||||
throw 'Artillery report is missing aggregate data.'
|
||||
}
|
||||
|
||||
function Get-PropertyValue {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[object]$Object,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Name
|
||||
)
|
||||
|
||||
if (-not $Object) {
|
||||
return $null
|
||||
}
|
||||
|
||||
$property = $Object.PSObject.Properties[$Name]
|
||||
if ($property) {
|
||||
return $property.Value
|
||||
}
|
||||
|
||||
return $null
|
||||
}
|
||||
|
||||
function Format-StatLine {
|
||||
param(
|
||||
[string]$Prefix,
|
||||
[object]$Stats
|
||||
)
|
||||
|
||||
if (-not $Stats) {
|
||||
return $null
|
||||
}
|
||||
|
||||
$parts = @()
|
||||
foreach ($name in @('count', 'min', 'max', 'mean', 'median', 'p95', 'p99')) {
|
||||
$value = Get-PropertyValue -Object $Stats -Name $name
|
||||
if ($null -ne $value) {
|
||||
$parts += "$name=$value"
|
||||
}
|
||||
}
|
||||
|
||||
if ($parts.Count -eq 0) {
|
||||
return $null
|
||||
}
|
||||
|
||||
return "$Prefix: $($parts -join ', ')"
|
||||
}
|
||||
|
||||
$counters = Get-PropertyValue -Object $aggregate -Name 'counters'
|
||||
$rates = Get-PropertyValue -Object $aggregate -Name 'rates'
|
||||
$summaries = Get-PropertyValue -Object $aggregate -Name 'summaries'
|
||||
|
||||
$created = [double](Get-PropertyValue -Object $counters -Name 'vusers.created' ?? 0)
|
||||
$failed = [double](Get-PropertyValue -Object $counters -Name 'vusers.failed' ?? 0)
|
||||
$completed = [double](Get-PropertyValue -Object $counters -Name 'vusers.completed' ?? 0)
|
||||
$errorRate = if ($created -gt 0) { [math]::Round(($failed / $created) * 100, 2) } else { 0 }
|
||||
|
||||
Write-Output '=== Artillery WebSocket Summary ==='
|
||||
Write-Output "source: $ReportFile"
|
||||
|
||||
$timestamp = Get-PropertyValue -Object $report -Name 'timestamp'
|
||||
if ($timestamp) {
|
||||
Write-Output "timestamp: $timestamp"
|
||||
}
|
||||
|
||||
if ($null -ne $created) {
|
||||
Write-Output "vusers.created: $created"
|
||||
}
|
||||
if ($null -ne $completed) {
|
||||
Write-Output "vusers.completed: $completed"
|
||||
}
|
||||
if ($null -ne $failed) {
|
||||
Write-Output "vusers.failed: $failed"
|
||||
}
|
||||
Write-Output "vusers.failure_rate_percent: $errorRate"
|
||||
|
||||
if ($counters) {
|
||||
foreach ($metric in @('ws.messages_sent', 'ws.messages_received', 'ws.ping', 'plugins.metrics-by-endpoint.response_time')) {
|
||||
$value = Get-PropertyValue -Object $counters -Name $metric
|
||||
if ($null -ne $value) {
|
||||
Write-Output "$metric: $value"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($rates) {
|
||||
foreach ($property in $rates.PSObject.Properties) {
|
||||
Write-Output "rate.$($property.Name): $($property.Value)"
|
||||
}
|
||||
}
|
||||
|
||||
if ($summaries) {
|
||||
foreach ($property in $summaries.PSObject.Properties) {
|
||||
$line = Format-StatLine -Prefix "summary.$($property.Name)" -Stats $property.Value
|
||||
if ($line) {
|
||||
Write-Output $line
|
||||
}
|
||||
}
|
||||
}
|
||||
#!/usr/bin/env pwsh
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$ReportFile
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
if (-not (Test-Path $ReportFile)) {
|
||||
throw "Report file not found: $ReportFile"
|
||||
}
|
||||
|
||||
$report = Get-Content -Raw -Path $ReportFile | ConvertFrom-Json -Depth 100
|
||||
$aggregate = $report.aggregate
|
||||
|
||||
if (-not $aggregate) {
|
||||
throw 'Artillery report is missing aggregate data.'
|
||||
}
|
||||
|
||||
function Get-PropertyValue {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[object]$Object,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Name
|
||||
)
|
||||
|
||||
if (-not $Object) {
|
||||
return $null
|
||||
}
|
||||
|
||||
$property = $Object.PSObject.Properties[$Name]
|
||||
if ($property) {
|
||||
return $property.Value
|
||||
}
|
||||
|
||||
return $null
|
||||
}
|
||||
|
||||
function Format-StatLine {
|
||||
param(
|
||||
[string]$Prefix,
|
||||
[object]$Stats
|
||||
)
|
||||
|
||||
if (-not $Stats) {
|
||||
return $null
|
||||
}
|
||||
|
||||
$parts = @()
|
||||
foreach ($name in @('count', 'min', 'max', 'mean', 'median', 'p95', 'p99')) {
|
||||
$value = Get-PropertyValue -Object $Stats -Name $name
|
||||
if ($null -ne $value) {
|
||||
$parts += "$name=$value"
|
||||
}
|
||||
}
|
||||
|
||||
if ($parts.Count -eq 0) {
|
||||
return $null
|
||||
}
|
||||
|
||||
return "$Prefix: $($parts -join ', ')"
|
||||
}
|
||||
|
||||
$counters = Get-PropertyValue -Object $aggregate -Name 'counters'
|
||||
$rates = Get-PropertyValue -Object $aggregate -Name 'rates'
|
||||
$summaries = Get-PropertyValue -Object $aggregate -Name 'summaries'
|
||||
|
||||
$created = [double](Get-PropertyValue -Object $counters -Name 'vusers.created' ?? 0)
|
||||
$failed = [double](Get-PropertyValue -Object $counters -Name 'vusers.failed' ?? 0)
|
||||
$completed = [double](Get-PropertyValue -Object $counters -Name 'vusers.completed' ?? 0)
|
||||
$errorRate = if ($created -gt 0) { [math]::Round(($failed / $created) * 100, 2) } else { 0 }
|
||||
|
||||
Write-Output '=== Artillery WebSocket Summary ==='
|
||||
Write-Output "source: $ReportFile"
|
||||
|
||||
$timestamp = Get-PropertyValue -Object $report -Name 'timestamp'
|
||||
if ($timestamp) {
|
||||
Write-Output "timestamp: $timestamp"
|
||||
}
|
||||
|
||||
if ($null -ne $created) {
|
||||
Write-Output "vusers.created: $created"
|
||||
}
|
||||
if ($null -ne $completed) {
|
||||
Write-Output "vusers.completed: $completed"
|
||||
}
|
||||
if ($null -ne $failed) {
|
||||
Write-Output "vusers.failed: $failed"
|
||||
}
|
||||
Write-Output "vusers.failure_rate_percent: $errorRate"
|
||||
|
||||
if ($counters) {
|
||||
foreach ($metric in @('ws.messages_sent', 'ws.messages_received', 'ws.ping', 'plugins.metrics-by-endpoint.response_time')) {
|
||||
$value = Get-PropertyValue -Object $counters -Name $metric
|
||||
if ($null -ne $value) {
|
||||
Write-Output "$metric: $value"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($rates) {
|
||||
foreach ($property in $rates.PSObject.Properties) {
|
||||
Write-Output "rate.$($property.Name): $($property.Value)"
|
||||
}
|
||||
}
|
||||
|
||||
if ($summaries) {
|
||||
foreach ($property in $summaries.PSObject.Properties) {
|
||||
$line = Format-StatLine -Prefix "summary.$($property.Name)" -Stats $property.Value
|
||||
if ($line) {
|
||||
Write-Output $line
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user