From e9a5df4f127f3e3cae4561dc108cad8129422ee3 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 12 Nov 2026 22:01:15 +0000 Subject: [PATCH] Rewrite smoke test: single container, execution + version checks - Run all checks in one container instead of ~45 `docker run`s. - Execute incident-critical tools (tcpdump, strace, gdb, bpftrace, nmap, dig, openssl, ...) rather than only `command -v`, which cannot catch wrong-arch binaries or missing shared libraries. - Assert kubectl/yq/stern/grpcurl versions match the Dockerfile ARGs. - Assert kubectl completion and the motd banner load for the interactive shell, and that non-interactive shells stay silent. No longer swallows failures with `|| true`. - Add --db-clients to verify the INSTALL_DB_CLIENTS=true variant. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_014iDTyB5N8EdZyyZo4ymUVR --- scripts/smoke-test.sh | 105 +++++++++++++++++++++++++++++++----------- 1 file changed, 78 insertions(+), 27 deletions(-) diff --git a/scripts/smoke-test.sh b/scripts/smoke-test.sh index 71b9fe4..12e35fd 100755 --- a/scripts/smoke-test.sh +++ b/scripts/smoke-test.sh @@ -1,40 +1,91 @@ #!/usr/bin/env bash -# Smoke-test a built k8s-debug image: every advertised tool must exist and -# the pinned binaries must run. Usage: scripts/smoke-test.sh [image] +# Smoke-test a built k8s-debug image. +# +# scripts/smoke-test.sh [image] [--db-clients] +# +# Checks (all inside ONE container, so it costs a single container start): +# 1. every advertised tool exists on PATH +# 2. tools that matter during an incident actually execute (catches +# wrong-arch downloads and missing shared libraries, which `command -v` +# cannot) +# 3. pinned tool versions match the ARGs in the Dockerfile +# 4. the interactive shell config loads (alias, completion, banner) +# --db-clients additionally requires redis-cli, psql and mysql (image built +# with INSTALL_DB_CLIENTS=true). set -euo pipefail -IMAGE="${1:-k8s-debug:dev}" +IMAGE="k8s-debug:dev" +DB_CLIENTS=false +for a in "$@"; do + case "$a" in + --db-clients) DB_CLIENTS=true ;; + *) IMAGE="$a" ;; + esac +done + +DOCKERFILE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/Dockerfile" +arg() { sed -n "s/^ARG $1=//p" "$DOCKERFILE" | head -n1; } + +# --- Test body: runs inside the container. Prints FAIL lines, exits non-zero. +read -r -d '' BODY <<'INNER' || true +fail=0 +bad() { echo "FAIL: $*"; fail=1; } -TOOLS=( - curl wget dig nslookup drill ping traceroute mtr tcpdump nmap ncat nc socat +tools="curl wget dig nslookup drill ping traceroute mtr tcpdump nmap ncat nc socat ss ip iptables nft conntrack ethtool iperf3 openssl strace ltrace gdb lsof htop pidstat iostat iotop bpftrace ps - jq yq kubectl stern grpcurl git ssh python3 vi nano -) + jq yq kubectl stern grpcurl git ssh python3 vi nano" +[ "$DB_CLIENTS" = true ] && tools="$tools redis-cli psql mysql" +for t in $tools; do command -v "$t" >/dev/null || bad "missing tool: $t"; done -fail=0 -for t in "${TOOLS[@]}"; do - if ! docker run --rm --entrypoint bash "$IMAGE" -c "command -v $t" >/dev/null; then - echo "MISSING: $t" - fail=1 - fi -done +# Must execute, not just exist. +run() { "$@" >/dev/null 2>&1 || bad "does not run: $*"; } +run kubectl version --client +run yq --version +run stern --version +run grpcurl -version +run jq --version +run tcpdump --version +run strace -V +run gdb --version +run bpftrace --version +run nmap --version +run dig -v +run openssl version +run iperf3 --version +run python3 --version + +# Pinned versions must match the Dockerfile ARGs. +ver() { #