ci: collect a killed benchmark server without killing it twice

A crash cycle kills the server itself to bracket the kill with time stamps, so it only waits for the container before restarting it. A test covers the idle window's two scrapes.

Signed-off-by: jeremyhi <fengjiachun@gmail.com>
This commit is contained in:
jeremyhi
2026-10-13 08:36:20 +08:00
parent 0251f12976
commit be4514ad7e
2 changed files with 22 additions and 4 deletions
+8 -2
View File
@@ -95,8 +95,14 @@ start_server() {
done
}
# kill sends SIGKILL, killed collects a server the caller already killed, and
# no argument stops it gracefully.
stop_server() {
if [[ "${1:-}" == kill ]]; then docker kill --signal KILL "$cid" >/dev/null; else docker stop -t 120 "$cid" >/dev/null; fi
case "${1:-}" in
kill) docker kill --signal KILL "$cid" >/dev/null ;;
killed) docker wait "$cid" >/dev/null ;;
*) docker stop -t 120 "$cid" >/dev/null ;;
esac
docker logs "$cid" > "$dir/server$phase.log" 2>&1
docker rm -fv "$cid" >/dev/null
cid=
@@ -159,7 +165,7 @@ crash_cycles() {
before=$(now_ns); docker kill --signal KILL "$cid" >/dev/null; after=$(now_ns)
wait "$wpid"
[[ -z "$spid" ]] || { kill "$spid" 2>/dev/null; wait "$spid" 2>/dev/null || true; spid=; }
stop_server kill
stop_server killed
phase=-restart-$cycle started=$(now)
start_server
restart_s=$(elapsed "$started")