test: add multi-function stress suite and severe load testing
This commit is contained in:
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Суровый параллельный прогон по нескольким endpoint-ам.
|
||||
BASE_URL=${1:-https://fission.kube5s.ru}
|
||||
TOTAL_REQUESTS=${2:-600}
|
||||
CONCURRENCY=${3:-60}
|
||||
|
||||
USER_NAME=$(kubectl get secrets/router --template={{.data.username}} -n fission | base64 -d)
|
||||
USER_PASS=$(kubectl get secrets/router --template={{.data.password}} -n fission | base64 -d)
|
||||
TOKEN=$(fission token create --username "$USER_NAME" --password "$USER_PASS")
|
||||
LB_IP=$(kubectl -n ingress get svc shturval-ingress-controller-controller -o jsonpath="{.status.loadBalancer.ingress[0].ip}")
|
||||
|
||||
run_load() {
|
||||
local path="$1"
|
||||
local label="$2"
|
||||
|
||||
echo "[load] endpoint=$label path=$path requests=$TOTAL_REQUESTS concurrency=$CONCURRENCY"
|
||||
|
||||
result=$(seq 1 "$TOTAL_REQUESTS" | xargs -P "$CONCURRENCY" -I{} sh -c '
|
||||
final_code="000"
|
||||
for attempt in 1 2; do
|
||||
code=$(curl -sk --resolve fission.kube5s.ru:443:'"$LB_IP"' -H "Authorization: Bearer '"$TOKEN"'" -o /dev/null -w "%{http_code}" '"$BASE_URL$path"')
|
||||
final_code="$code"
|
||||
if [ "$code" = "200" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$final_code" = "200" ]; then
|
||||
echo ok:200
|
||||
else
|
||||
echo fail:"$final_code"
|
||||
fi
|
||||
')
|
||||
|
||||
success=$(printf "%s\n" "$result" | grep -c "^ok:200$" || true)
|
||||
fail=$(printf "%s\n" "$result" | grep -c "^fail:" || true)
|
||||
rate=$(awk -v s="$success" -v t="$TOTAL_REQUESTS" 'BEGIN { if (t==0) print 0; else printf "%.2f", (s*100.0)/t }')
|
||||
|
||||
codes=$(printf "%s\n" "$result" | grep "^fail:" | cut -d: -f2 | sort | uniq -c | tr '\n' ';' || true)
|
||||
|
||||
echo "[result] $label success=$success fail=$fail success_rate=${rate}% fail_codes=[${codes}]"
|
||||
|
||||
if [ "$fail" -gt 0 ]; then
|
||||
echo "[error] load test failed for $label"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
run_load "/stress/fast" "fast"
|
||||
run_load "/stress/cpu" "cpu"
|
||||
run_load "/stress/json" "json"
|
||||
|
||||
echo "[ok] all load tests passed"
|
||||
Reference in New Issue
Block a user