tests: Retry-After-Sperre für die nächste Anfrage prüfen

Der neue Test lässt einen Stub dauerhaft 429 mit Retry-After 30 liefern und
prüft, dass die zweite Anfrage den Endpunkt als "cooling" überspringt und
dass die Sperre die 30 s des Anbieters nennt, nicht die eigene 1 s.

Die Ports PORT+230/231 sind dafür neu; sie stehen jetzt auch in der
Sperrliste, damit ein liegengebliebener Stub den Lauf nicht verfälscht.
This commit is contained in:
Hermes committed 2026-11-17 19:08:00 +00:00
1 parent 29aa281ca9
commit 90c4896f4e
2 files changed
+35 -1

No files matched your search

+34
View File
@@ -135,3 +135,37 @@ if grep -q "retry_after_s=0" "$TMP/ra.log" 2>/dev/null; then
else
ok "nothing invented when the provider says nothing"
fi
# Der Anbieter nennt eine Reset-Zeit, alle Versuche sind vorbei: der Endpunkt muss
# auch für die *nächste* Anfrage gesperrt bleiben. Sonst rennt jede Anfrage wieder
# in dasselbe erschöpfte Kontingent (in Produktion: 429 mit Retry-After 926119).
RBP=$((PORT+230))
RBS=$((PORT+231))
STUB_STATE="$TMP/rab.state" tests/stub $RBS "RAB" --fail-n 100 --retry-after 30 \
> "$TMP/rab_stub.log" 2>&1 &
PIDS+=($!)
sleep 0.3
cat > "$TMP/rab.conf" <<CFG
listen 127.0.0.1:$RBP
log_prefix rab
retry_num 0
retry_backoff 0.2
endpoint a {
base http://127.0.0.1:$RBS/v1
timeout 20
cooldown 1
}
req for "*" check none pass a
CFG
./junction --config "$TMP/rab.conf" > "$TMP/rab.log" 2>&1 &
PIDS+=($!)
wait_port "$RBP" 10 || bad "cooldown instance did not come up"
curl -s -o /dev/null -m 20 -X POST -H 'Content-Type: application/json' -d "$RABODY" \
"http://127.0.0.1:$RBP/v1/chat/completions"
R=$(curl -s -m 20 -X POST -H 'Content-Type: application/json' -d "$RABODY" \
"http://127.0.0.1:$RBP/v1/chat/completions")
contains "$R" "cooling" "the next request skips an endpoint benched by Retry-After"
contains "$(grep -o 'reason=retry_after reset_s=[0-9]*' "$TMP/rab.log" | head -1)" \
"reset_s=30" "the bench uses the provider's reset time, not the 1 s cooldown"
+1 -1
View File
@@ -68,7 +68,7 @@ log_has() {
# answer requests with somebody else's config), so fail loudly and early.
# 8157 gehört auf dieser Maschine dem Hermes-Gateway — der Port wird von keinem
# Test benutzt, also darf er die Suite nicht aufhalten.
for port in 8361 8362 8363 8364 8357 8358 8359 8360 8355 8356 8347 8348 8349 8350 8351 8352 8353 8354 8345 8346 8335 8336 8337 8338 8339 8340 8341 8342 8375 8376 8377 8378 8385 8386 8387 8388 8389 8395 8396 8397 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8150 8151 8152 8153 8154 8155 8156 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8170 8171 8172 8173 8175 8180 8181 8194 8176 8177 8185 8186 8187 8188 8189 8190 9443 9990 9991 9992 9993 9994 9995 9996; do
for port in 8361 8362 8363 8364 8357 8358 8359 8360 8355 8356 8347 8348 8349 8350 8351 8352 8353 8354 8345 8346 8335 8336 8337 8338 8339 8340 8341 8342 8375 8376 8377 8378 8385 8386 8387 8388 8389 8395 8396 8397 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8150 8151 8152 8153 8154 8155 8156 8158 8159 8160 8161 8162 8163 8164 8165 8166 8365 8366 8167 8168 8170 8171 8172 8173 8175 8180 8181 8194 8176 8177 8185 8186 8187 8188 8189 8190 9443 9990 9991 9992 9993 9994 9995 9996; do
if ss -tln 2>/dev/null | grep -q ":$port "; then
echo "port $port is busy — a leftover junction/stub is still running:"
ss -tlnp 2>/dev/null | grep ":$port " | sed 's/^/ /'