diff --git a/tests/retry-after.sh b/tests/retry-after.sh index 9d214a1..d9a4fc5 100755 --- a/tests/retry-after.sh +++ b/tests/retry-after.sh @@ -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" < "$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" diff --git a/tests/run.sh b/tests/run.sh index 18ee0a3..0771a84 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -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/^/ /'