dev: docker-compose TS3/TS6 servers and tsctl smoke test

- dev/docker-compose.yml: TeamSpeak 3.13 and TeamSpeak 6 beta13.1,
  pinned by digest, REGISTRY override for the Docker Hub mirror.
- scripts/it-smoke.sh: tree, server chat and channel chat
  round-trips on both servers; redeems the one-time ServerAdmin key.
- tsctl raw: send an arbitrary command (used to relax anti-flood on
  the dev servers; later for probing TS6 stream commands).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
This commit is contained in:
Claude committed 2026-09-25 13:04:41 +00:00
1 parent 51a19594d0
commit ebeec4c2e3
5 files changed
+157 -1

No files matched your search

+96
View File
@@ -0,0 +1,96 @@
#!/usr/bin/env bash
# Integration smoke test: tsctl against the TS3 and TS6 servers from
# dev/docker-compose.yml.
#
# For each server it checks:
# 1. connect + channel tree (channelsubscribeall)
# 2. server chat between two clients
# 3. channel chat between two clients
#
# Usage: scripts/it-smoke.sh [ts3|ts6]... (default: both)
# Env: TSCTL=path/to/tsctl (default: builds target/debug/tsctl)
# COMPOSE_FILE=dev/docker-compose.yml
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"
mkdir -p "$STATE_DIR"
if [[ -z "${TSCTL:-}" ]]; then
cargo build --quiet -p tsctl
TSCTL=target/debug/tsctl
fi
declare -A PORTS=([ts3]=9987 [ts6]=9988)
SERVERS=("$@")
[[ ${#SERVERS[@]} -eq 0 ]] && SERVERS=(ts3 ts6)
log() { printf '\n== %s\n' "$*"; }
fail() { printf 'FAIL: %s\n' "$*" >&2; exit 1; }
compose_logs() { docker compose -f "$COMPOSE_FILE" logs --no-color "$1" 2>&1; }
# Wait until the server printed its ServerAdmin privilege key, then echo it.
privilege_key() {
local svc=$1 key=""
for _ in $(seq 1 60); do
key=$(compose_logs "$svc" | grep -o 'token=[^ ]*' | head -1 | cut -d= -f2 || true)
[[ -n "$key" ]] && break
sleep 1
done
[[ -n "$key" ]] || fail "$svc did not print a privilege key"
echo "$key"
}
# Prepare an identity in the server's admin group. The privilege key only works
# once, so the identity is kept in $STATE_DIR for later runs (`down -v` resets).
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
mv "$id.tmp" "$id"
# The rapid test connections would trip the per-IP anti-flood ban.
"$TSCTL" connect "$addr" --identity "$id" --nick admin raw \
"serveredit virtualserver_antiflood_points_needed_ip_block=100000 virtualserver_antiflood_points_needed_command_block=100000" >/dev/null
fi
echo "--identity $id"
}
# Start a listener, send one message, and check the listener received it.
chat_roundtrip() {
local addr=$1 kind=$2 sender_args=$3
local token="smoke-$kind-$RANDOM$RANDOM" out="$STATE_DIR/listen.log"
"$TSCTL" connect "$addr" --nick listener listen --expect "$token" --timeout 20 >"$out" 2>&1 &
local listener=$!
# Give the listener time to connect before sending.
for _ in $(seq 1 40); do grep -q "listener" "$out" 2>/dev/null && break; sleep 0.25; done
# shellcheck disable=SC2086
"$TSCTL" connect "$addr" --nick sender $sender_args chat "$kind" "$token"
if ! wait "$listener"; then
cat "$out"
fail "$kind chat message not received"
fi
grep -F "[$kind] sender" "$out"
}
for svc in "${SERVERS[@]}"; do
port=${PORTS[$svc]:?unknown server $svc}
addr="127.0.0.1:$port"
log "$svc ($addr)"
admin=$(admin_args "$svc" "$addr")
tree=$("$TSCTL" connect "$addr" --nick tree-check tree)
echo "$tree"
grep -q "tree-check" <<<"$tree" || fail "own client missing from tree"
# Guests may not use the server chat by default, so the sender is the admin.
chat_roundtrip "$addr" server "$admin"
chat_roundtrip "$addr" channel ""
done
log "all smoke tests passed"