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
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
# summarize-k6.sh — Extract per-endpoint p95 and failure rates from a k6 JSON
|
||||
# summary export. Mirrors scripts/loadtest/summarize-k6.ps1.
|
||||
# Usage: ./scripts/loadtest/summarize-k6.sh <k6-summary.json>
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -lt 1 ]]; then
|
||||
echo "Usage: $0 <k6-summary.json>" >&2
|
||||
exit 2
|
||||
fi
|
||||
summary_file="$1"
|
||||
[[ -f "$summary_file" ]] || { echo "Summary file not found: $summary_file" >&2; exit 1; }
|
||||
|
||||
SUMMARY_FILE="$summary_file" node <<'EOF'
|
||||
const fs = require('fs');
|
||||
const summary = JSON.parse(fs.readFileSync(process.env.SUMMARY_FILE, 'utf8'));
|
||||
const metrics = summary.metrics;
|
||||
if (!metrics) throw new Error('Invalid k6 summary file: missing metrics object.');
|
||||
|
||||
const val = (m, key) => (m && m.values && m.values[key] !== undefined) ? Number(m.values[key]) : undefined;
|
||||
const globalDuration = val(metrics.http_req_duration, 'p(95)');
|
||||
const globalFailRate = val(metrics.http_req_failed, 'rate');
|
||||
|
||||
console.log(`k6 Summary: ${process.env.SUMMARY_FILE}`);
|
||||
if (globalDuration !== undefined) console.log(`Global p95 duration (ms): ${globalDuration.toFixed(2)}`);
|
||||
if (globalFailRate !== undefined) console.log(`Global failure rate: ${(globalFailRate * 100).toFixed(2)}%`);
|
||||
console.log('');
|
||||
|
||||
const endpoints = ['overview', 'analytics', 'chat_log', 'users'];
|
||||
const rows = endpoints.map((ep) => {
|
||||
const dP95 = val(metrics[`http_req_duration{endpoint:${ep}}`], 'p(95)');
|
||||
const fRate = val(metrics[`http_req_failed{endpoint:${ep}}`], 'rate');
|
||||
return {
|
||||
Endpoint: ep,
|
||||
P95Ms: dP95 !== undefined ? dP95.toFixed(2) : 'n/a',
|
||||
FailurePct: fRate !== undefined ? (fRate * 100).toFixed(4) : 'n/a',
|
||||
};
|
||||
});
|
||||
|
||||
const pad = (s, n) => String(s).padEnd(n);
|
||||
console.log(pad('ENDPOINT', 12) + pad('P95_MS', 10) + 'FAILURE_PCT');
|
||||
for (const r of rows) console.log(pad(r.Endpoint, 12) + pad(r.P95Ms, 10) + r.FailurePct);
|
||||
EOF
|
||||
Reference in new issue
Block a user