k6 step-load rig: staircase scenarios, per-step/per-endpoint tagging, live Prometheus remote-write, Grafana dashboard
This commit is contained in:
61
scripts/stepload.sh
Executable file
61
scripts/stepload.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
# Run a step-load (staircase) test across a collection of endpoints.
|
||||
# Usage:
|
||||
# ./scripts/stepload.sh <base-url> <endpoints-json> [start-rps] [step-rps] [step-duration] [steps]
|
||||
# Example:
|
||||
# ./scripts/stepload.sh https://api.example.com \
|
||||
# '[{"name":"login","method":"POST","path":"/login"},{"name":"list","path":"/items","weight":3}]' \
|
||||
# 25 25 2m 6
|
||||
# -> starts at 25 rps, +25 rps every 2 minutes, 6 steps (ending at 150 rps)
|
||||
set -euo pipefail
|
||||
|
||||
BASE=${1:?usage: stepload.sh <base-url> <endpoints-json> [start-rps] [step-rps] [step-duration] [steps]}
|
||||
EPS=${2:?endpoints-json required - see script header for format}
|
||||
START=${3:-50}
|
||||
STEP=${4:-50}
|
||||
DUR=${5:-2m}
|
||||
STEPS=${6:-5}
|
||||
NAME="stepload-$(date +%s)"
|
||||
PROM_RW="http://prometheus.monitoring.svc:9090/api/v1/write"
|
||||
|
||||
kubectl -n loadtest apply -f - <<EOF
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: $NAME
|
||||
spec:
|
||||
parallelism: 1
|
||||
ttlSecondsAfterFinished: 1800
|
||||
template:
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
containers:
|
||||
- name: k6
|
||||
image: grafana/k6:1.4.0
|
||||
command: ["k6", "run", "/scripts/step.js", "-o", "experimental-prometheus-rw"]
|
||||
env:
|
||||
- {name: BASE_URL, value: "$BASE"}
|
||||
- {name: ENDPOINTS_JSON, value: '$EPS'}
|
||||
- {name: START_RPS, value: "$START"}
|
||||
- {name: STEP_RPS, value: "$STEP"}
|
||||
- {name: STEP_DURATION, value: "$DUR"}
|
||||
- {name: STEPS, value: "$STEPS"}
|
||||
- {name: K6_PROMETHEUS_RW_SERVER_URL, value: "$PROM_RW"}
|
||||
- {name: K6_PROMETHEUS_RW_TREND_STATS, value: "avg,p(50),p(95),p(99),min,max"}
|
||||
resources:
|
||||
requests: {cpu: 200m, memory: 256Mi}
|
||||
limits: {memory: 512Mi}
|
||||
volumeMounts:
|
||||
- {name: scripts, mountPath: /scripts}
|
||||
volumes:
|
||||
- name: scripts
|
||||
configMap: {name: k6-step-script}
|
||||
EOF
|
||||
|
||||
MAX=$(( START + (STEPS - 1) * STEP ))
|
||||
echo "Staircase '$NAME': $STEPS steps, $START -> $MAX rps (+$STEP each), $DUR holds"
|
||||
echo "Total duration: $STEPS x $DUR (plus 5s ramps per step)"
|
||||
echo ""
|
||||
echo "Watch live: Grafana -> the 'k6 Step Load' dashboard (or kubectl -n loadtest logs -f job/$NAME)"
|
||||
echo "Logs: kubectl -n loadtest logs -f job/$NAME"
|
||||
echo "Stop early: kubectl -n loadtest delete job $NAME"
|
||||
Reference in New Issue
Block a user