Files
rustfs/scripts/test_hotpath_warp_abba.sh
T
Hauser Zhi 70525a9698 feat(ecstore): expose fsync worker policy experiments (#9357)
* feat(ecstore): expose fsync worker policy experiments

Add independent idle-spin controls and gated worker diagnostics for controlled performance comparisons.

Co-Authored-By: heihutu <heihutu@gmail.com>
Co-Authored-By: zhi22915 <qiuzgang@gmail.com>

* test(perf): forward Docker telemetry in ABBA runs

Validate node mappings and record per-leg container resources for isolated fsync policy experiments.

Co-Authored-By: heihutu <heihutu@gmail.com>
Co-Authored-By: zhi22915 <qiuzgang@gmail.com>

* fix(perf): reject baseline drift in either direction

Apply absolute delta budgets to A2 baseline checks while preserving directional candidate checks and their exemptions.

Co-Authored-By: heihutu <heihutu@gmail.com>
Co-Authored-By: zhi22915 <qiuzgang@gmail.com>

* fix(perf): stop ABBA after a load driver failure

Preserve the load driver exit status through command substitution and stop before later deployment legs while retaining cleanup traps.

Co-Authored-By: heihutu <heihutu@gmail.com>
Co-Authored-By: zhi22915 <qiuzgang@gmail.com>

---------

Co-authored-by: heihutu <heihutu@gmail.com>
Co-authored-by: zhi22915 <qiuzgang@gmail.com>
2026-11-12 18:28:01 -05:00

437 lines
16 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
RUNNER="${SCRIPT_DIR}/run_hotpath_warp_abba.sh"
TMP_DIR="$(mktemp -d)"
OUT_DIR="${TMP_DIR}/abba"
TRACE_FILE="${TMP_DIR}/abba-trace.log"
FAILURE_SERVER_PID=""
cleanup() {
if [[ -n "$FAILURE_SERVER_PID" ]]; then
kill "$FAILURE_SERVER_PID" 2>/dev/null || true
fi
rm -rf "$TMP_DIR"
}
trap cleanup EXIT
"$RUNNER" \
--baseline-bin /usr/bin/true \
--candidate-bin /usr/bin/true \
--baseline-revision baseline-test \
--candidate-revision candidate-test \
--warp-bin /usr/bin/true \
--rounds 3 \
--out-dir "$OUT_DIR" \
--dry-run >"$TRACE_FILE" 2>&1
awk -F',' '
NR == 1 {
if ($1 != "sync_label" || $6 != "leg" || $7 != "phase" || $10 != "bucket" || $11 != "dataset_setup") exit 1
next
}
{
key = $1 SUBSEP $3
seen[key]++
leg[key, seen[key]] = $6
phase[key, seen[key]] = $7
bucket[key, seen[key]] = $10
}
END {
for (key in seen) {
if (seen[key] != 4) exit 1
if (leg[key, 1] != "A1" || leg[key, 2] != "B1" || leg[key, 3] != "B2" || leg[key, 4] != "A2") exit 1
if (phase[key, 1] != "baseline" || phase[key, 2] != "candidate" || phase[key, 3] != "candidate" || phase[key, 4] != "baseline") exit 1
for (slot = 1; slot <= 4; slot++) {
if (length(bucket[key, slot]) > 63 || bucket[key, slot] !~ /^rustfs-abba-[a-z0-9-]+$/ || bucket[key, slot] in all_buckets) exit 1
all_buckets[bucket[key, slot]] = 1
}
cells++
}
exit cells == 12 ? 0 : 1
}
' "$OUT_DIR/abba_schedule.csv"
rg -qx 'schedule=ABBA' "$OUT_DIR/manifest.env"
rg -qx 'rounds=3' "$OUT_DIR/manifest.env"
rg -qx 'baseline_revision=baseline-test' "$OUT_DIR/manifest.env"
rg -qx 'candidate_revision=candidate-test' "$OUT_DIR/manifest.env"
rg -qx 'external_isolation=local-per-cell-disks' "$OUT_DIR/manifest.env"
rg -qx 'evidence_mode=dry-run' "$OUT_DIR/manifest.env"
rg -qx 'formal_evidence=false' "$OUT_DIR/manifest.env"
rg -qx 'performance_conclusion=not_measured_dry_run' "$OUT_DIR/manifest.env"
rg -qx 'bucket_isolation=per-leg' "$OUT_DIR/manifest.env"
rg -qx 'dataset_setup=get-and-mixed-via-bounded-warp-native' "$OUT_DIR/manifest.env"
rg -qx 'dataset_objects=64' "$OUT_DIR/manifest.env"
[[ "$(rg -c -- '--extra-args --objects\\ 64\\ --noclear' "$TRACE_FILE")" == "32" ]]
if rg -q -- 'dataset-setup' "$TRACE_FILE"; then
echo "unexpected redundant dataset setup command" >&2
exit 1
fi
if rg -q -- 'rustfs-bench' "$TRACE_FILE"; then
echo "unexpected rustfs-bench command" >&2
exit 1
fi
FOCUSED_OUT_DIR="${TMP_DIR}/focused"
"$RUNNER" \
--baseline-bin /usr/bin/true \
--candidate-bin /usr/bin/true \
--baseline-revision baseline-test \
--candidate-revision candidate-test \
--warp-bin /usr/bin/true \
--rounds 3 \
--workload 'put-128kib|put|128KiB' \
--workload 'put-512kib|put|512KiB' \
--drive-sync 'sync-on|true' \
--out-dir "$FOCUSED_OUT_DIR" \
--dry-run >/dev/null 2>&1
awk -F',' 'NR == 1 {next} {seen[$3]++; if ($1 != "sync-on" || $3 !~ /^put-(128|512)kib$/) exit 1} END {exit (seen["put-128kib"] == 4 && seen["put-512kib"] == 4) ? 0 : 1}' "$FOCUSED_OUT_DIR/abba_schedule.csv"
rg -Fxq 'workloads=put-128kib|put|128KiB;put-512kib|put|512KiB' "$FOCUSED_OUT_DIR/manifest.env"
rg -Fxq 'drive_sync_matrix=sync-on|true' "$FOCUSED_OUT_DIR/manifest.env"
DOCKER_OUT_DIR="${TMP_DIR}/docker-telemetry"
DOCKER_TRACE="${TMP_DIR}/docker-telemetry-trace.log"
"$RUNNER" \
--baseline-bin /usr/bin/true \
--candidate-bin /usr/bin/true \
--baseline-revision baseline-test \
--candidate-revision candidate-test \
--warp-bin /usr/bin/true \
--rounds 3 \
--workload 'put-100kib|put|100KiB' \
--drive-sync 'sync-on|true' \
--node-docker-container 'node-1=rustfs-one' \
--node-docker-container 'node-2=rustfs-two' \
--out-dir "$DOCKER_OUT_DIR" \
--dry-run >"$DOCKER_TRACE" 2>&1
rg -qx 'node_docker_container_count=2' "$DOCKER_OUT_DIR/manifest.env"
[[ "$(rg -c -F -- '--node-docker-container node-1=rustfs-one --node-docker-container node-2=rustfs-two' "$DOCKER_TRACE")" == "4" ]]
for invalid_target in 'missing-equals' '=container' 'node=' 'node,1=container' $'node=container\nother'; do
if "$RUNNER" \
--baseline-bin /usr/bin/true \
--candidate-bin /usr/bin/true \
--warp-bin /usr/bin/true \
--node-docker-container "$invalid_target" \
--out-dir "${TMP_DIR}/invalid-docker-target" \
--dry-run >"${TMP_DIR}/invalid-docker-target.log" 2>&1; then
echo "expected malformed Docker node mapping to fail" >&2
exit 1
fi
rg -qF -- '--node-docker-container must be node=container' "${TMP_DIR}/invalid-docker-target.log"
[[ ! -e "${TMP_DIR}/invalid-docker-target" ]]
done
if "$RUNNER" \
--baseline-bin /usr/bin/true \
--candidate-bin /usr/bin/true \
--warp-bin /usr/bin/true \
--node-docker-container 'node-1=rustfs-one' \
--node-docker-container 'node-1=rustfs-two' \
--out-dir "${TMP_DIR}/duplicate-docker-target" \
--dry-run >"${TMP_DIR}/duplicate-docker-target.log" 2>&1; then
echo "expected duplicate Docker node mapping to fail" >&2
exit 1
fi
rg -qF -- '--node-docker-container repeats node: node-1' "${TMP_DIR}/duplicate-docker-target.log"
[[ ! -e "${TMP_DIR}/duplicate-docker-target" ]]
if "$RUNNER" --baseline-bin /usr/bin/true --candidate-bin /usr/bin/true --baseline-revision baseline-test --candidate-revision candidate-test --warp-bin /usr/bin/true --rounds 3 --workload 'bad|delete|1KiB' --out-dir "${TMP_DIR}/bad-workload" --dry-run >/dev/null 2>&1; then
echo "expected invalid --workload mode to fail" >&2
exit 1
fi
if "$RUNNER" --baseline-bin /usr/bin/true --candidate-bin /usr/bin/true --baseline-revision baseline-test --candidate-revision candidate-test --warp-bin /usr/bin/true --rounds 3 --drive-sync 'sync-on|maybe' --out-dir "${TMP_DIR}/bad-drive-sync" --dry-run >/dev/null 2>&1; then
echo "expected invalid --drive-sync value to fail" >&2
exit 1
fi
rg -qF -- '--labeled-compare-csv sync-on/put-4kib/B1-vs-A1' "$TRACE_FILE"
rg -qF -- '--labeled-compare-csv sync-off/put-4kib/B1-vs-A1' "$TRACE_FILE"
rg -qF -- '--labeled-compare-csv sync-on/put-4kib/A2-vs-A1' "$TRACE_FILE"
rg -qF -- '--labeled-compare-csv sync-off/put-4kib/A2-vs-A1' "$TRACE_FILE"
[[ "$(rg -c -- '--baseline-drift' "$TRACE_FILE")" == "1" ]]
rg 'DRY-RUN:.*candidate_gate.md' "$TRACE_FILE" >"${TMP_DIR}/candidate-gate-command.log"
rg 'DRY-RUN:.*baseline_drift_gate.md' "$TRACE_FILE" >"${TMP_DIR}/drift-gate-command.log"
if rg -q -- '--baseline-drift' "${TMP_DIR}/candidate-gate-command.log"; then
echo "expected candidate gate to retain directional regression checks" >&2
exit 1
fi
rg -q -- '--baseline-drift.*--require-tail-error' "${TMP_DIR}/drift-gate-command.log"
"$RUNNER" \
--baseline-bin /usr/bin/true \
--candidate-bin /usr/bin/true \
--baseline-revision baseline-test \
--candidate-revision candidate-test \
--warp-bin /usr/bin/true \
--workload 'put-100kib|put|100KiB' \
--drive-sync 'sync-on|true' \
--allow-regression --exemption-reason 'candidate correctness tradeoff' \
--out-dir "${TMP_DIR}/candidate-exemption" \
--dry-run >"${TMP_DIR}/candidate-exemption-trace.log" 2>&1
rg 'DRY-RUN:.*candidate_gate.md' "${TMP_DIR}/candidate-exemption-trace.log" | rg -q -- '--allow-regression'
rg 'DRY-RUN:.*baseline_drift_gate.md' "${TMP_DIR}/candidate-exemption-trace.log" >"${TMP_DIR}/exempted-run-drift-command.log"
rg -q -- '--baseline-drift' "${TMP_DIR}/exempted-run-drift-command.log"
if rg -q -- '--allow-regression|--exemption-reason' "${TMP_DIR}/exempted-run-drift-command.log"; then
echo "expected candidate exemption to leave baseline stability checks strict" >&2
exit 1
fi
if "$RUNNER" \
--baseline-bin /usr/bin/true \
--candidate-bin /usr/bin/true \
--warp-bin /usr/bin/true \
--rounds 3 \
--out-dir "${TMP_DIR}/missing-revisions" >/dev/null 2>&1; then
echo "expected formal mode to reject unknown binary revisions" >&2
exit 1
fi
mkdir -p "${TMP_DIR}/data/reused/put-4kib-A1-sync-true"
printf '%s\n' sentinel >"${TMP_DIR}/data/reused/put-4kib-A1-sync-true/sentinel"
if "$RUNNER" \
--baseline-bin /usr/bin/true \
--candidate-bin /usr/bin/true \
--baseline-revision baseline-test \
--candidate-revision candidate-test \
--warp-bin /usr/bin/true \
--rounds 3 \
--data-root "${TMP_DIR}/data" \
--out-dir "${TMP_DIR}/reused" >/dev/null 2>&1; then
echo "expected local mode to reject a reused run namespace" >&2
exit 1
fi
"$RUNNER" \
--baseline-bin /usr/bin/true \
--candidate-bin /usr/bin/true \
--baseline-revision baseline-test \
--candidate-revision candidate-test \
--endpoint 127.0.0.1:9000 \
--allow-unmanaged-external \
--warp-bin /usr/bin/true \
--rounds 3 \
--out-dir "${TMP_DIR}/unmanaged-external-dry-run" \
--dry-run >"${TMP_DIR}/unmanaged-external-trace.log" 2>&1
rg -qx 'external=true' "${TMP_DIR}/unmanaged-external-dry-run/manifest.env"
rg -qx 'external_isolation=unmanaged' "${TMP_DIR}/unmanaged-external-dry-run/manifest.env"
rg -qx 'evidence_mode=dry-run' "${TMP_DIR}/unmanaged-external-dry-run/manifest.env"
rg -qx 'formal_evidence=false' "${TMP_DIR}/unmanaged-external-dry-run/manifest.env"
rg -qx 'performance_conclusion=not_measured_dry_run' "${TMP_DIR}/unmanaged-external-dry-run/manifest.env"
if "$RUNNER" \
--baseline-bin /usr/bin/true \
--candidate-bin /usr/bin/true \
--baseline-revision baseline-test \
--candidate-revision candidate-test \
--endpoint 127.0.0.1:9 \
--allow-unmanaged-external \
--warp-bin /usr/bin/true \
--rounds 3 \
--health-timeout 1 \
--out-dir "${TMP_DIR}/unmanaged-external-nonformal" >/dev/null 2>&1; then
echo "expected unmanaged external mode to fail readiness in this test" >&2
exit 1
fi
rg -qx 'external=true' "${TMP_DIR}/unmanaged-external-nonformal/manifest.env"
rg -qx 'external_isolation=unmanaged' "${TMP_DIR}/unmanaged-external-nonformal/manifest.env"
rg -qx 'evidence_mode=external-unmanaged-nonformal' "${TMP_DIR}/unmanaged-external-nonformal/manifest.env"
rg -qx 'formal_evidence=false' "${TMP_DIR}/unmanaged-external-nonformal/manifest.env"
rg -qx 'performance_conclusion=not_formal_unmanaged_external' "${TMP_DIR}/unmanaged-external-nonformal/manifest.env"
if "$RUNNER" \
--baseline-bin /usr/bin/true \
--candidate-bin /usr/bin/true \
--endpoint 127.0.0.1:9000 \
--warp-bin /usr/bin/true \
--rounds 3 \
--out-dir "${TMP_DIR}/external" \
--dry-run >/dev/null 2>&1; then
echo "expected formal external mode to require a deploy hook" >&2
exit 1
fi
if "$RUNNER" \
--baseline-bin /usr/bin/true \
--candidate-bin /usr/bin/true \
--baseline-revision baseline-test \
--candidate-revision candidate-test \
--endpoint 127.0.0.1:9000 \
--deploy-hook ':' \
--warp-bin /usr/bin/true \
--rounds 3 \
--out-dir "${TMP_DIR}/missing-deploy-evidence" >/dev/null 2>&1; then
echo "expected a formal external deploy hook to write evidence" >&2
exit 1
fi
rg -qx 'external=true' "${TMP_DIR}/missing-deploy-evidence/manifest.env"
rg -qx 'external_isolation=deploy-hook-attested' "${TMP_DIR}/missing-deploy-evidence/manifest.env"
rg -qx 'evidence_mode=external-deploy-hook-attested' "${TMP_DIR}/missing-deploy-evidence/manifest.env"
rg -qx 'formal_evidence=true' "${TMP_DIR}/missing-deploy-evidence/manifest.env"
rg -qx 'performance_conclusion=not_claimed_gate_and_artifacts_required' "${TMP_DIR}/missing-deploy-evidence/manifest.env"
BAD_EVIDENCE_HOOK="${TMP_DIR}/bad-evidence-hook.sh"
cat >"$BAD_EVIDENCE_HOOK" <<'HOOK'
#!/usr/bin/env bash
set -euo pipefail
leg="$HOTPATH_ABBA_LEG"
phase="$HOTPATH_ABBA_PHASE"
bucket="$HOTPATH_ABBA_BUCKET"
binary_sha256="$HOTPATH_ABBA_BINARY_SHA256"
dataset_reset=true
case "${BAD_EVIDENCE_FIELD:?missing BAD_EVIDENCE_FIELD}" in
leg) leg=wrong-leg ;;
phase) phase=wrong-phase ;;
bucket) bucket=wrong-bucket ;;
binary_sha256) binary_sha256=wrong-sha256 ;;
dataset_reset) dataset_reset=false ;;
*) echo "unknown BAD_EVIDENCE_FIELD=$BAD_EVIDENCE_FIELD" >&2; exit 2 ;;
esac
cat >"$HOTPATH_ABBA_DEPLOY_EVIDENCE_FILE" <<EOF
leg=$leg
phase=$phase
bucket=$bucket
binary_sha256=$binary_sha256
dataset_reset=$dataset_reset
EOF
HOOK
chmod +x "$BAD_EVIDENCE_HOOK"
for bad_field in leg phase bucket binary_sha256 dataset_reset; do
bad_out_dir="${TMP_DIR}/bad-deploy-evidence-${bad_field}"
if BAD_EVIDENCE_FIELD="$bad_field" "$RUNNER" \
--baseline-bin /usr/bin/true \
--candidate-bin /usr/bin/true \
--baseline-revision baseline-test \
--candidate-revision candidate-test \
--endpoint 127.0.0.1:9000 \
--deploy-hook "$BAD_EVIDENCE_HOOK" \
--warp-bin /usr/bin/true \
--rounds 3 \
--out-dir "$bad_out_dir" >/dev/null 2>&1; then
echo "expected a formal external deploy hook with wrong $bad_field evidence to fail" >&2
exit 1
fi
rg -qx 'external=true' "$bad_out_dir/manifest.env"
rg -qx 'external_isolation=deploy-hook-attested' "$bad_out_dir/manifest.env"
rg -qx 'evidence_mode=external-deploy-hook-attested' "$bad_out_dir/manifest.env"
rg -qx 'formal_evidence=true' "$bad_out_dir/manifest.env"
rg -qx 'performance_conclusion=not_claimed_gate_and_artifacts_required' "$bad_out_dir/manifest.env"
done
# Exercise the actual command-substitution path with a failing load driver.
FAILURE_REPO="$TMP_DIR/failed-driver-repo"
mkdir -p "$FAILURE_REPO/scripts" "$FAILURE_REPO/bin"
git init -q "$FAILURE_REPO"
cat >"$FAILURE_REPO/scripts/run_object_batch_bench_enhanced.sh" <<'DRIVER'
#!/usr/bin/env bash
set -euo pipefail
while [[ $# -gt 0 ]]; do
if [[ "$1" == --out-dir ]]; then
printf 'measure:%s\n' "${2##*/}" >>"$FAILURE_TRACE"
break
fi
shift
done
exit 42
DRIVER
cat >"$FAILURE_REPO/scripts/hotpath_warp_ab_gate.sh" <<'GATE'
#!/usr/bin/env bash
echo gate >>"$FAILURE_TRACE"
exit 0
GATE
cat >"$FAILURE_REPO/bin/curl" <<'CURL'
#!/usr/bin/env bash
set -euo pipefail
if [[ -z "${SERVER_PID_FILE:-}" ]]; then
exit 0
fi
for ((i = 0; i < 500; i++)); do
[[ -s "$SERVER_PID_FILE" ]] && exit 0
sleep 0.01
done
exit 1
CURL
cat >"$FAILURE_REPO/bin/rustfs" <<'SERVER'
#!/usr/bin/env bash
set -euo pipefail
if [[ "${1:-}" == --version ]]; then
echo 'test server'
exit 0
fi
echo "$$" >"$SERVER_PID_FILE"
exec sleep 60
SERVER
cat >"$FAILURE_REPO/deploy.sh" <<'DEPLOY'
#!/usr/bin/env bash
set -euo pipefail
echo "deploy:$HOTPATH_ABBA_LEG" >>"$FAILURE_TRACE"
cat >"$HOTPATH_ABBA_DEPLOY_EVIDENCE_FILE" <<EOF
leg=$HOTPATH_ABBA_LEG
phase=$HOTPATH_ABBA_PHASE
bucket=$HOTPATH_ABBA_BUCKET
binary_sha256=$HOTPATH_ABBA_BINARY_SHA256
dataset_reset=true
EOF
DEPLOY
chmod +x "$FAILURE_REPO/scripts/"*.sh "$FAILURE_REPO/bin/"* "$FAILURE_REPO/deploy.sh"
for failure_mode in external local; do
FAILURE_OUT_DIR="$TMP_DIR/failed-driver-$failure_mode"
failure_trace="$TMP_DIR/failed-driver-$failure_mode.trace"
failure_args=(--endpoint 127.0.0.1:9000 --deploy-hook "$FAILURE_REPO/deploy.sh")
server_pid_file=""
if [[ "$failure_mode" == local ]]; then
failure_args=(--data-root "$FAILURE_REPO/data")
server_pid_file="$FAILURE_REPO/server.pid"
fi
if (
cd "$FAILURE_REPO"
PATH="$FAILURE_REPO/bin:$PATH" FAILURE_TRACE="$failure_trace" SERVER_PID_FILE="$server_pid_file" \
"$RUNNER" \
--baseline-bin "$FAILURE_REPO/bin/rustfs" \
--candidate-bin "$FAILURE_REPO/bin/rustfs" \
--baseline-revision baseline-test \
--candidate-revision candidate-test \
--warp-bin /usr/bin/true \
--workload 'put-100kib|put|100KiB' \
--drive-sync 'sync-on|true' \
--health-timeout 1 \
--out-dir "$FAILURE_OUT_DIR" \
"${failure_args[@]}"
) >"$TMP_DIR/failed-driver-$failure_mode.log" 2>&1; then
echo "expected failing load driver to abort the $failure_mode run" >&2
exit 1
else
failure_status=$?
fi
if [[ "$failure_mode" == local && -s "$server_pid_file" ]]; then
FAILURE_SERVER_PID="$(cat "$server_pid_file")"
fi
[[ "$failure_status" == 42 ]]
if [[ "$failure_mode" == external ]]; then
[[ "$(cat "$failure_trace")" == $'deploy:A1\nmeasure:A1' ]]
else
[[ "$(cat "$failure_trace")" == 'measure:A1' ]]
[[ -n "$FAILURE_SERVER_PID" ]]
for ((i = 0; i < 500; i++)); do
kill -0 "$FAILURE_SERVER_PID" 2>/dev/null || break
sleep 0.01
done
if kill -0 "$FAILURE_SERVER_PID" 2>/dev/null; then
echo "expected EXIT cleanup to stop the local server after driver failure" >&2
exit 1
fi
FAILURE_SERVER_PID=""
fi
awk -F, 'NR == 2 { if ($6 != "A1") exit 1 } END { if (NR != 2) exit 1 }' "$FAILURE_OUT_DIR/abba_schedule.csv"
[[ ! -e "$FAILURE_OUT_DIR/summary.md" ]]
[[ ! -e "$FAILURE_OUT_DIR/candidate_gate.md" ]]
[[ ! -e "$FAILURE_OUT_DIR/baseline_drift_gate.md" ]]
done
echo "hotpath warp ABBA tests passed"