Files
git.stella-ops.org/scripts/graph/load-test.sh
StellaOps Bot e6119cbe91
Some checks failed
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
up
2025-11-24 09:07:40 +02:00

48 lines
1.1 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
# DEVOPS-GRAPH-24-001: load test graph index/adjacency APIs
TARGET=${TARGET:-"http://localhost:5000"}
OUT="out/graph-load"
mkdir -p "$OUT"
USERS=${USERS:-8}
DURATION=${DURATION:-60}
RATE=${RATE:-200}
cat > "${OUT}/k6-graph.js" <<'EOF'
import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
vus: __USERS__,
duration: '__DURATION__s',
thresholds: {
http_req_duration: ['p(95)<500'],
http_req_failed: ['rate<0.01'],
},
};
const targets = [
'/graph/api/index',
'/graph/api/adjacency?limit=100',
'/graph/api/search?q=log4j',
];
export default function () {
const host = __TARGET__;
targets.forEach(path => http.get(`${host}${path}`));
sleep(1);
}
EOF
sed -i "s/__USERS__/${USERS}/g" "${OUT}/k6-graph.js"
sed -i "s/__DURATION__/${DURATION}/g" "${OUT}/k6-graph.js"
sed -i "s@__TARGET__@\"${TARGET}\"@g" "${OUT}/k6-graph.js"
echo "[graph-load] running k6..."
k6 run "${OUT}/k6-graph.js" --summary-export "${OUT}/summary.json" --http-debug="off"
echo "[graph-load] summary written to ${OUT}/summary.json"