check: add ./check stress stage; fix unreachable bench/mount dispatch
- ./check stress spins a fresh cube-server+cubec built from this tree on a throwaway socket/store and drives ~150s of real prog/run traffic while sampling the per-command latency + per-C telemetry. - tools/stress.sh: never touches the production daemon; STRESS_SECONDS override. - Fixed latent control-flow bug: the old '|| exit 0' guards made 'bench' and 'mount' subcommands unreachable after the gate (they exited early). Now uses explicit run_* flags and only exits at the true end.
This commit is contained in:
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
# Sustained stress stage for CUBELinux-2 (invoked by `./check stress`).
|
||||
#
|
||||
# Builds cube-server + cubec from THIS workspace tree, spins a fresh daemon on a
|
||||
# throwaway socket + store, then drives it hard for STRESS_SECONDS (default 150)
|
||||
# with real prog/run traffic while sampling the per-command latency + per-C
|
||||
# namespace telemetry. This exercises the new cubesys `stats` path under load.
|
||||
#
|
||||
# It deliberately does NOT touch the production daemon (real socket/store in
|
||||
# /home/luulu/.cubelinux) so it is safe to run any time. Numbers are
|
||||
# informational; the stage passes iff the gate passed and the daemon survives.
|
||||
set -uo pipefail
|
||||
REPO="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$REPO"
|
||||
export PATH="$HOME/.cargo/bin:/usr/local/bin:/usr/bin:/bin:$PATH"
|
||||
command -v cargo >/dev/null || { echo "cargo not found" >&2; exit 127; }
|
||||
|
||||
JOBS="${JOBS:-4}"
|
||||
SECS="${STRESS_SECONDS:-150}"
|
||||
|
||||
echo "building cube-server + cubec from tree ($REPO) ..."
|
||||
cargo build -p cubesys --release --bins --jobs "$JOBS" >/dev/null 2>&1 || {
|
||||
echo "BUILD FAILED (cubesys bins)"; exit 1
|
||||
}
|
||||
SRV="$REPO/target/release/cube-server"
|
||||
CLI="$REPO/target/release/cubec"
|
||||
[ -x "$SRV" ] && [ -x "$CLI" ] || { echo "binaries missing after build"; exit 1; }
|
||||
|
||||
TMPD="$(mktemp -d /tmp/cube-stress.XXXXXX)"
|
||||
SOCK="$TMPD/cube.sock"
|
||||
STORE="$TMPD/store.json"
|
||||
trap 'kill $DPID 2>/dev/null; wait $DPID 2>/dev/null; rm -rf "$TMPD"' EXIT
|
||||
|
||||
echo "starting stress daemon on $SOCK ..."
|
||||
"$SRV" --socket "$SOCK" --store "$STORE" >"$TMPD/daemon.log" 2>&1 &
|
||||
DPID=$!
|
||||
# wait for socket (max ~15s)
|
||||
for i in $(seq 1 15); do [ -S "$SOCK" ] && break; sleep 1; done
|
||||
[ -S "$SOCK" ] || { echo "daemon failed to start (see $TMPD/daemon.log)"; kill $DPID 2>/dev/null; exit 1; }
|
||||
|
||||
START=$(date +%s)
|
||||
END=$((START + SECS))
|
||||
PAIRS=0
|
||||
SAMPLE_EVERY=25 # sample stats every 25 pairs (~ once a second at load)
|
||||
while [ "$(date +%s)" -lt "$END" ]; do
|
||||
X=$((PAIRS % 256))
|
||||
"$CLI" --socket "$SOCK" "prog /c077/z001/y001/x$X const $((PAIRS % 97)) halt" >/dev/null 2>&1
|
||||
"$CLI" --socket "$SOCK" "run /c077/z001/y001/x$X" >/dev/null 2>&1
|
||||
PAIRS=$((PAIRS + 1))
|
||||
if [ "$((PAIRS % SAMPLE_EVERY))" -eq 0 ]; then
|
||||
echo "--- [$(date -u +%H:%M:%S)] stress sample $((PAIRS / SAMPLE_EVERY)) (pairs=$PAIRS) ---"
|
||||
"$CLI" --socket "$SOCK" "stats" || true
|
||||
fi
|
||||
done
|
||||
|
||||
# final health snapshot
|
||||
echo "--- final stats (pairs driven: $PAIRS over ~${SECS}s) ---"
|
||||
"$CLI" --socket "$SOCK" "stats" || true
|
||||
|
||||
ELAPSED=$(($(date +%s) - START))
|
||||
if [ "$ELAPSED" -lt 1 ]; then ELAPSED=1; fi
|
||||
echo "stress throughput: ~$((PAIRS / ELAPSED)) prog+run pairs/s (informational)"
|
||||
echo "STRESS STAGE OK (daemon alive, $PAIRS pairs driven)"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user