From ed3bbb4f9e58c5d0573ef06bb7d533d803b1deb9 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sun, 8 Nov 2026 17:41:15 -0400 Subject: [PATCH] tests: serve_e2e and anchor_rerun take the port serve reports; the census moves with them Batch 3 of #1485, and this time the census moves in the same commit - that is what #1537's CI failure taught. - `serve_e2e.sh`: `--port 0` and `serve_port_wait`, with a generous budget (12000 tenths) because this one loads a real model before it is ready; its own health window is 600 s. - `anchor_rerun.sh`: same, budget 18000 to match the script's own 30-minute health window, and a serve that never reports a port now names the alias and tails the log instead of continuing to poll a port nobody is listening on. - `_onebit_route_tests` drops `serve_e2e_cpu`/`serve_e2e_hrx`: they no longer pre-pick, so the lock has nothing to serialise. `hrx_cpu_weight_parity` stays and the comment says why - it starts `llama-server` itself, whose port is not ours to choose, which is also why it is not in this migration at all. Checked before touching it: `hrx_cpu_weight_parity` is **not** a `1bit serve` script (it runs `$server`, i.e. `llama-server`), so the ready-line parse would be wrong there. It stays as it is. Rehearsed the census against a stand-in `ctest` built from the new lists: 3/3 cases pass. `bash -n` clean on both scripts; shellcheck warning counts unchanged against main (serve_e2e 2, anchor_rerun 0). --- CMakeLists.txt | 6 ++++-- tests/anchor_rerun.sh | 11 +++++++++-- tests/serve_e2e.sh | 8 ++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba3f31302..370c39172 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1437,8 +1437,10 @@ set(_onebit_route_tests laya_gguf_route mem_admit_route hrx_cwsr_route hrx_runtime_route hybrid_route hybrid_kvshare_route) # Tests that only exist for some configurations (a model was passed, a device is built in). -list(APPEND _onebit_route_tests hybrid_e2e laya_route_e2e laya_models_e2e pm_laya_route serve_e2e_cpu serve_e2e_hrx - hrx_cpu_weight_parity) +# serve_e2e_ left this list with engine #1485: it runs `serve --port 0` now, so it picks nothing and there is no +# window for the lock to close. hrx_cpu_weight_parity stays - it starts `llama-server` itself, whose port is not ours to +# choose (that is also why it is not in the `1bit serve` migration). +list(APPEND _onebit_route_tests hybrid_e2e laya_route_e2e laya_models_e2e pm_laya_route hrx_cpu_weight_parity) foreach(_onebit_route_test IN LISTS _onebit_route_tests) if(TEST ${_onebit_route_test}) set_tests_properties(${_onebit_route_test} PROPERTIES RESOURCE_LOCK route_ports) diff --git a/tests/anchor_rerun.sh b/tests/anchor_rerun.sh index e0de0a720..53b67131e 100755 --- a/tests/anchor_rerun.sh +++ b/tests/anchor_rerun.sh @@ -19,6 +19,8 @@ set -uo pipefail bin=${1:?usage: anchor_rerun.sh <1bit> : ...} +# shellcheck source=tests/serve_port.sh +. "$(dirname "$0")/serve_port.sh" # serve_port_wait: read back the port serve bound (engine #1485) outdir=${2:?} device=${3:?} shift 3 @@ -31,11 +33,16 @@ for spec in "$@"; do echo "SKIP $alias: gguf missing: $gguf" continue fi - port=$(python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1", 0)); print(s.getsockname()[1])') log=$(mktemp /tmp/serve-rerun-${alias}.XXXX.log) t0=$(date +%s) - "$bin" serve -m "$gguf" --device "$device" --port "$port" --alias "$alias" >"$log" 2>&1 & + # --port 0: the kernel picks and serve reports the port it bound (engine #1485), so nothing is picked and released + # here. The budget matches this script's own 30-minute health window: these are real models. + "$bin" serve -m "$gguf" --device "$device" --port 0 --alias "$alias" >"$log" 2>&1 & pid=$! + port=$(serve_port_wait "$log" "$pid" 18000) || { + echo "FAIL $alias: serve never reported a port; log=$log"; tail -25 "$log" + kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; continue + } code=000 for _ in $(seq 1 3600); do code=$(curl -s -o /dev/null -w '%{http_code}' "http://127.0.0.1:$port/health" 2>/dev/null) diff --git a/tests/serve_e2e.sh b/tests/serve_e2e.sh index 0179f424b..316743e58 100755 --- a/tests/serve_e2e.sh +++ b/tests/serve_e2e.sh @@ -25,6 +25,8 @@ set -uo pipefail bin=${1:?usage: serve_e2e.sh path/to/1bit [args]} +# shellcheck source=tests/serve_port.sh +. "$(dirname "$0")/serve_port.sh" # serve_port_wait: read back the port serve bound (engine #1485) model=${2:?} device=${3:?} shift 3 @@ -35,10 +37,12 @@ if [ "$device" = hrx ]; then for t in $want; do case " $have" in *" $t "*) found=1 ;; esac; done [ $found = 1 ] || { echo "skip: no $want GPU for HRX on this machine (GPUs: ${have:-none})"; exit 77; } fi -port=$(python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1", 0)); print(s.getsockname()[1])') log=$(mktemp) -"$bin" serve -m "$model" --device "$device" --port "$port" --alias e2e-model "$@" >"$log" 2>&1 & +# --port 0: the kernel picks and serve reports the port it bound, so nothing here picks a port and releases it before +# serve binds (engine #1444/#1485). The budget is generous because this test loads a real model before it is ready. +"$bin" serve -m "$model" --device "$device" --port 0 --alias e2e-model "$@" >"$log" 2>&1 & pid=$! +port=$(serve_port_wait "$log" "$pid" 12000) || { echo "FAIL serve never reported a port"; cat "$log"; exit 1; } cleanup() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; rm -f "$log"; } trap cleanup EXIT fail=0