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:
1 parent
51a19594d0
commit
ebeec4c2e3
5 files changed
+157
-1
No files matched your search
@@ -0,0 +1,48 @@
|
||||
# Local TeamSpeak servers for development and integration tests.
|
||||
#
|
||||
# docker compose -f dev/docker-compose.yml up -d
|
||||
# scripts/it-smoke.sh
|
||||
#
|
||||
# Each server prints a one-time ServerAdmin privilege key to its log on first
|
||||
# start; the smoke test reads it from there. `down -v` resets the servers.
|
||||
#
|
||||
# query_ip_allowlist.txt allowlists private ranges: clients reach the servers
|
||||
# through the Docker bridge, and allowlisted IPs skip the anti-flood bans that
|
||||
# rapid test connections would otherwise trigger. Development use only.
|
||||
#
|
||||
# Images are pinned by digest; bump by pulling the new tag and copying its digest.
|
||||
# If Docker Hub rate-limits you, use its mirror: REGISTRY=mirror.gcr.io
|
||||
name: tsc-dev
|
||||
|
||||
services:
|
||||
ts3:
|
||||
# teamspeak:3.13
|
||||
image: ${REGISTRY:-docker.io}/library/teamspeak@sha256:6dfdfb22869adf50e1b66d024b360b786d57a85ea09e8e8fdb6cca23949b2813
|
||||
environment:
|
||||
TS3SERVER_LICENSE: accept
|
||||
TS3SERVER_IP_ALLOWLIST: /etc/ts3server/query_ip_allowlist.txt
|
||||
ports:
|
||||
- "9987:9987/udp" # voice
|
||||
- "10011:10011" # raw ServerQuery
|
||||
- "30033:30033" # file transfer
|
||||
volumes:
|
||||
- ts3-data:/var/ts3server
|
||||
- ./query_ip_allowlist.txt:/etc/ts3server/query_ip_allowlist.txt:ro
|
||||
|
||||
ts6:
|
||||
# teamspeaksystems/teamspeak6-server:latest as of 2026-09-22 (6.0.0-beta13.1)
|
||||
image: ${REGISTRY:-docker.io}/teamspeaksystems/teamspeak6-server@sha256:d845f803aecf842c2df034c959c23ff2462357bacafb3807500885c5ec170fa1
|
||||
environment:
|
||||
TSSERVER_LICENSE_ACCEPTED: accept
|
||||
ports:
|
||||
- "9988:9987/udp" # voice (mapped to 9988 so both servers can run)
|
||||
- "10022:10022" # SSH ServerQuery
|
||||
- "10080:10080" # HTTP WebQuery
|
||||
- "30034:30033" # file transfer
|
||||
volumes:
|
||||
- ts6-data:/var/tsserver
|
||||
- ./query_ip_allowlist.txt:/var/tsserver/query_ip_allowlist.txt:ro
|
||||
|
||||
volumes:
|
||||
ts3-data:
|
||||
ts6-data:
|
||||
@@ -0,0 +1,5 @@
|
||||
127.0.0.1/32
|
||||
::1/128
|
||||
10.0.0.0/8
|
||||
172.16.0.0/12
|
||||
192.168.0.0/16
|
||||
Executable
+96
@@ -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"
|
||||
@@ -113,6 +113,9 @@ pub enum Action {
|
||||
#[arg(long)]
|
||||
timeout: Option<u64>,
|
||||
},
|
||||
/// Send a raw, already escaped command (e.g. `serveredit virtualserver_name=Test\\sServer`)
|
||||
/// and wait for the result. Combine with `--log-commands` to see the answer.
|
||||
Raw { command: String },
|
||||
/// Interactive session. Type `/help` for commands.
|
||||
Repl,
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use tsclientlib::{
|
||||
ChannelId, ClientId, Connection, DisconnectOptions, MessageHandle, MessageTarget, StreamItem,
|
||||
data,
|
||||
};
|
||||
use tsproto_packets::packets::OutCommand;
|
||||
use tsproto_packets::packets::{Direction, Flags, OutCommand, PacketType};
|
||||
|
||||
use crate::{Action, ChatTarget, ConnectArgs, identity, tree, versions};
|
||||
|
||||
@@ -53,6 +53,10 @@ pub async fn run(args: ConnectArgs) -> Result<()> {
|
||||
Action::Listen { json, expect, timeout } => {
|
||||
listen(&mut con, *json, expect.as_deref(), timeout.map(Duration::from_secs)).await
|
||||
}
|
||||
Action::Raw { command } => {
|
||||
let cmd = OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, command);
|
||||
send_and_wait(&mut con, cmd, "command").await.map(|()| println!("ok"))
|
||||
}
|
||||
Action::Repl => repl(&mut con).await,
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user