Files
PFVCluster/proxmox/perf/bench/lxc-bench-setup.sh
T
mrcharles 7586605b70 fix(perf): bench jq direction bug + libaio + json note guard [#709]
- write tests read .write.* explicitly (jq // kept read=0 for writes)
- libaio1 installed everywhere (real aio engine, no sync cap)
- fio stdout notes stripped before jq parse

Ticket: https://projects.knownelement.com/issues/709
2026-09-03 07:53:37 -05:00

62 lines
2.3 KiB
Bash

#!/bin/bash
# lxc-bench-setup.sh — run ON a Proxmox host: stand up the #709 bench LXC
# (Proxmox cannot run docker; this is the host-side packaging of the same
# toolset) and optionally bench a storage path through it.
#
# Usage (from workstation, via tests/remote.sh prox-file):
# lxc-bench-setup.sh [--ctid N] [--store /mnt/path] [--keep]
# --store PATH bind-mount host PATH into the LXC at /mnt/bench and bench it
# --keep leave the LXC running (default: destroyed after the run)
set -eu
CTID="${BENCH_CTID:-30099}"
STORE=""
KEEP=0
while [ $# -gt 0 ]; do
case "$1" in
--ctid) CTID="$2"; shift 2 ;;
--store) STORE="$2"; shift 2 ;;
--keep) KEEP=1; shift ;;
*) echo "unknown arg $1" >&2; exit 1 ;;
esac
done
cleanup() {
if [ "$KEEP" != 1 ] && pct status "$CTID" >/dev/null 2>&1; then
pct stop "$CTID" >/dev/null 2>&1 || true
pct destroy "$CTID" >/dev/null 2>&1 || true
fi
}
trap cleanup EXIT
# template: fetch the standard Debian 12 LXC template if missing
TPL=$(pveam list local 2>/dev/null | grep -oE 'local:vztmpl/[a-z0-9-]*debian-12-standard[^ ]*\.tar\.zst' | head -1 || true)
if [ -z "$TPL" ]; then
pveam update >/dev/null
DL=$(pveam available --section system 2>/dev/null | grep -oE 'debian-12-standard[^ ]*\.tar\.zst' | sort -V | tail -1)
[ -n "$DL" ] || { echo "[bench-lxc] ERROR: no debian-12 LXC template in pveam" >&2; exit 1; }
pveam download local "$DL" >/dev/null
TPL=$(pveam list local | grep -oE "local:vztmpl/$DL" | head -1)
fi
echo "[bench-lxc] template: $TPL"
MP=()
if [ -n "$STORE" ]; then
MP=(-mp0 "$STORE,mp=/mnt/bench")
fi
pct create "$CTID" "$TPL" --hostname perfbench --memory 1024 --cores 2 \
--rootfs local-lvm:8 --net0 name=eth0,bridge=vmbr0,ip=dhcp \
--unprivileged 1 --features nesting=0 "${MP[@]}" >/dev/null
pct start "$CTID"
sleep 5
# toolset in (same installer the guests use; piped in, nothing fetched from outside)
pct exec "$CTID" -- bash -c "export DEBIAN_FRONTEND=noninteractive; apt-get update -qq >/dev/null; apt-get install -y -qq fio iperf3 jq libaio1 >/dev/null"
BDIR="/mnt/bench"
[ -z "$STORE" ] && BDIR="/var/tmp"
echo "[bench-lxc] benching $BDIR on CT $CTID"
pct exec "$CTID" -- env BENCH_DIR="$BDIR" bash -s < "$(dirname "$0")/bench-run.sh"
echo "[bench-lxc] done"