tests: auf den Listener warten statt zu schlafen
Ein Lauf nach frischem `make clean` fiel mit vier Fehlern durch, die nichts mit dem Code zu tun hatten: "soft budget delays the request (8 ms)", "the refusal names the reason: text-only endpoint (missing 'text-only')" und "a one-line endpoint block is enough to serve a request (missing 'served by GATED')". Alle drei schicken eine einzige Anfrage kurz nach dem Start und nehmen an, dass "0,7 s" reicht — unter Last (kompiliert, gescrapt, Container-Churn) reicht es nicht immer, und dann misst die Prüfung eine Verbindung, die noch niemand annimmt. Jetzt wartet die Suite: wait_port pollt bis zu 10 s, bis der Listener annimmt, statt eine Zeit zu raten. Beim Soft-Budget-Test zusätzlich: statt 2,5 s zu schlafen wird gewartet, bis /status den Prozentwert wirklich zeigt (usage_poll 1 s) — das ist die Bedingung, die die Prüfung braucht. Zwei Läufe hintereinander: PASS, 146 Prüfungen, keine Restprozesse.
This commit is contained in:
1 parent
5d4befcf51
commit
12cdf5a955
4 files changed
+24
-5
No files matched your search
+1
-1
@@ -120,7 +120,7 @@ req for "*" pass textonly
|
||||
CFG
|
||||
./junction --config "$TMP/ctx3.conf" > "$TMP/ctx3.log" 2>&1 &
|
||||
PIDS+=($!)
|
||||
sleep 0.7
|
||||
wait_port $((PORT+17)) 10
|
||||
R=$(curl -s -m 20 -X POST -H 'Content-Type: application/json' \
|
||||
-d '{"model":"m","messages":[{"role":"user","content":[{"type":"image_url","image_url":{"url":"http://example.org/a.png"}}]}],"max_tokens":8}' \
|
||||
"http://127.0.0.1:$((PORT+17))/v1/chat/completions")
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ req for "*" pass kurz
|
||||
CFG
|
||||
./junction --config "$TMP/inline.conf" > "$TMP/inline.log" 2>&1 &
|
||||
PIDS+=($!)
|
||||
sleep 0.8
|
||||
wait_port $((PORT+31)) 10
|
||||
R=$(curl -s -m 10 -X POST -H 'Content-Type: application/json' \
|
||||
-d '{"model":"x","messages":[{"role":"user","content":"hi"}]}' \
|
||||
"http://127.0.0.1:$((PORT+31))/v1/chat/completions")
|
||||
|
||||
@@ -25,7 +25,7 @@ endpoint box {
|
||||
req for "*" check none pass box
|
||||
CFG
|
||||
./junction --config "$TMP/retry.conf" > "$TMP/retry.log" 2>&1 & PIDS+=($!)
|
||||
sleep 0.5
|
||||
wait_port $P_RETRYJ 10
|
||||
R=$(curl -s -m 20 -X POST -H 'Content-Type: application/json' \
|
||||
-d '{"model":"m","messages":[{"role":"user","content":"hi"}],"max_tokens":8}' \
|
||||
"http://127.0.0.1:$P_RETRYJ/v1/chat/completions")
|
||||
@@ -63,7 +63,7 @@ req for "*" check none pass box
|
||||
CFG
|
||||
P_KEY_FIRST=$P_KEY_FIRST P_KEY_SECOND=$P_KEY_SECOND \
|
||||
./junction --config "$TMP/pool.conf" > "$TMP/pool.log" 2>&1 & PIDS+=($!)
|
||||
sleep 0.5
|
||||
wait_port $P_POOLJ 10
|
||||
RH=$(curl -s -m 20 -D- -X POST -H 'Content-Type: application/json' \
|
||||
-d '{"model":"m","messages":[{"role":"user","content":"hi"}],"max_tokens":8}' \
|
||||
"http://127.0.0.1:$P_POOLJ/v1/chat/completions")
|
||||
|
||||
+20
-1
@@ -18,6 +18,18 @@ ok() { printf ' OK %s\n' "$1"; }
|
||||
bad() { printf ' FAIL %s\n' "$1"; FAILED=1; }
|
||||
contains() { case "$1" in *"$2"*) ok "$3";; *) bad "$3 (missing '$2')";; esac; }
|
||||
|
||||
# Auf den Listener warten statt zu schlafen. Unter Last (parallel kompiliert, ein
|
||||
# Scrape dazwischen) war "junction nach 0,7 s erreichbar" nicht immer wahr, und dann
|
||||
# scheiterten Prüfungen, die mit dem Code nichts zu tun hatten.
|
||||
wait_port() {
|
||||
local port=$1 limit=$(( ${2:-10} * 20 )) i=0
|
||||
while [ "$i" -lt "$limit" ]; do
|
||||
if (exec 3<>"/dev/tcp/127.0.0.1/$port") 2>/dev/null; then exec 3>&-; return 0; fi
|
||||
sleep 0.05; i=$((i+1))
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# serviert wird vor dem Log-Eintrag: die Antwort ist beim Client, "served_by" folgt
|
||||
# einen Wimpernschlag später. Ein direkter grep verliert dieses Rennen je nach
|
||||
# Lastlage — deshalb kurz nachsehen statt sofort urteilen.
|
||||
@@ -588,7 +600,14 @@ req for "*" check none pass rich
|
||||
CFG
|
||||
./junction --config "$TMP/soft.conf" > "$TMP/soft.log" 2>&1 &
|
||||
PIDS+=($!)
|
||||
sleep 2.5
|
||||
wait_port $((PORT+13)) 10
|
||||
# Nicht schlafen und hoffen: warten, bis der Abruf den Prozentwert wirklich hat.
|
||||
# usage_poll steht auf 1 s; unter Last war "nach 2,5 s ist es da" nicht immer wahr,
|
||||
# und die Prüfung maß dann 8 ms statt der Drosselung.
|
||||
for _i in $(seq 1 100); do
|
||||
curl -s -m 2 "http://127.0.0.1:$((PORT+13))/status" | grep -q '"usage_percent":85' && break
|
||||
sleep 0.1
|
||||
done
|
||||
T0=$(date +%s%N)
|
||||
curl -s -m 20 -X POST -H 'Content-Type: application/json' \
|
||||
-d '{"model":"ds4","messages":[{"role":"user","content":"slow down"}]}' \
|
||||
|
||||
Reference in new issue
Block a user