From f31d976bfc3e248e08ba9c18ba7e9089b42fad70 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 25 Sep 2026 13:57:50 +0000 Subject: [PATCH] smoke: keep state in dev/.state, kill background clients on exit The admin identity that redeemed the one-time privilege key lived in target/, so cargo clean broke later runs. Also print how to reset the servers when the key is already used. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G --- .gitignore | 1 + scripts/it-smoke.sh | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index b83d222..ec81357 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target/ +/dev/.state/ diff --git a/scripts/it-smoke.sh b/scripts/it-smoke.sh index aa2d7af..0f284e3 100755 --- a/scripts/it-smoke.sh +++ b/scripts/it-smoke.sh @@ -16,8 +16,11 @@ set -euo pipefail cd "$(dirname "$0")/.." export RUST_BACKTRACE=0 RUST_LOG="${RUST_LOG:-error}" COMPOSE_FILE="${COMPOSE_FILE:-dev/docker-compose.yml}" -STATE_DIR="target/it-smoke" +# Survives `cargo clean`: holds the admin identity that redeemed the one-time key. +STATE_DIR="${SMOKE_STATE_DIR:-dev/.state}" mkdir -p "$STATE_DIR" +# Never leave background clients behind. +trap 'kill $(jobs -p) 2>/dev/null || true' EXIT if [[ -z "${TSCTL:-}" ]]; then cargo build --quiet -p tsctl @@ -51,8 +54,11 @@ admin_args() { local svc=$1 addr=$2 id="$STATE_DIR/$svc-admin.json" if [[ ! -f "$id" ]]; then "$TSCTL" identity new --out "$id.tmp" --force >/dev/null - "$TSCTL" connect "$addr" --identity "$id.tmp" --nick admin \ - --privilege-key "$(privilege_key "$svc")" tree >/dev/null + if ! "$TSCTL" connect "$addr" --identity "$id.tmp" --nick admin \ + --privilege-key "$(privilege_key "$svc")" tree >/dev/null; then + fail "could not redeem the $svc privilege key (already used?). Reset the servers: + docker compose -f $COMPOSE_FILE down -v && docker compose -f $COMPOSE_FILE up -d && rm -rf $STATE_DIR" + fi mv "$id.tmp" "$id" # The rapid test connections would trip the per-IP anti-flood ban. "$TSCTL" connect "$addr" --identity "$id" --nick admin raw \