Files
VoelinClient/scripts/it-smoke.sh
T
Claude 908e5566c4 M2: tsc-audio, tsc-store and tsctl voice
- tsc-audio: Opus voice/music encoder producing TeamSpeak voice packets,
  framer, rubato resampling, WAV I/O, tone/Goertzel helpers, cpal
  capture/playback over lock-free ring buffers; the vendored
  AudioHandler is the jitter buffer/mixer.
- tsc-store: SQLite (bundled, WAL, 0600) with migrations for identities,
  bookmarks, settings and paged chat history; Secrets trait with memory
  and OS keyring backends.
- tsctl voice send (WAV or tone, real time) / record (mix to WAV,
  --expect-tone check). The smoke test now includes a voice round-trip:
  1 kHz tone ratio ~0.95 on TS3 and TS6.
- Dev profile: no debug info for dependencies (target/ 16 GB -> 2.4 GB).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-25 13:56:01 +00:00

114 lines
3.8 KiB
Bash
Executable File

#!/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
# 4. voice: a 1 kHz tone sent by one client is recorded by another
#
# 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"
}
# One client records while another sends a tone; Goertzel checks the result.
voice_roundtrip() {
local addr=$1 out="$STATE_DIR/voice.log"
"$TSCTL" connect "$addr" --nick recorder voice record "$STATE_DIR/voice.wav" \
--seconds 6 --expect-tone 1000 >"$out" 2>&1 &
local recorder=$!
sleep 2
"$TSCTL" connect "$addr" --nick talker voice send --tone 1000 --seconds 2 >/dev/null
if ! wait "$recorder"; then
cat "$out"
fail "voice tone not received"
fi
grep "tone ratio" "$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 ""
voice_roundtrip "$addr"
done
log "all smoke tests passed"