This commit is contained in:
2026-11-26 23:34:55 +03:00
parent 20afc2c790
commit a25f357314
167 changed files with 33202 additions and 89 deletions
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
# Dedicated caller IP on the private network; exercise both replicas through one ingress.
headers=$(mktemp)
trap 'rm -f "$headers"' EXIT
instances=""
for i in 1 2 3 4 5 6; do
code=$(scripts/dc.sh run --rm -T --no-deps --entrypoint curl api \
-sS --cacert /pki/ca.crt --connect-to localhost:8443:lb:443 \
-X POST -H 'Authorization: Basic bm9uZXhpc3RlbnQ6d3Jvbmc=' \
-D - -o - https://localhost:8443/api/v1/auth/sessions)
printf '%s\n' "$code" > "$headers"
instances+="$(tr -d '\r' < "$headers" | sed -n 's/^X-Instance-Id: //Ip') "
if [[ "$i" -le 5 ]]; then
[[ "$code" == *'401 Unauthorized'* ]] || { echo "FAIL: request $i expected 401"; exit 1; }
else
[[ "$code" == *'429 Too Many Requests'* ]]
tr -d '\r' < "$headers" | grep -qi '^Retry-After: 60$'
python3 - "$headers" <<'PYCODE'
import json,sys
raw=open(sys.argv[1]).read().split('\n\n',1)[1]
j=json.loads(raw)['error']
assert j['code']=='rate_limited' and j['request_id'] and j['message']
PYCODE
fi
done
[[ $(printf '%s\n' "$instances" | tr ' ' '\n' | sed '/^$/d' | sort -u | wc -l) -eq 2 ]] || { echo 'FAIL: both replicas must participate'; exit 1; }
echo 'PASS: first 5 invalid logins return 401; sixth returns 429 with Retry-After: 60'