panic at vk server topology, add vk to e2e

This commit is contained in:
kulikov0 committed 2026-09-16 16:43:50 +02:00
1 parent 0cb812677a
commit 1cf840756a
11 files changed
+168 -51

No files matched your search

+1
View File
@@ -2,6 +2,7 @@
# Empty room = platform is SKIPPED (harness refuses to create a new call). # Empty room = platform is SKIPPED (harness refuses to create a new call).
# To allow creating fresh rooms per run, set ALLOW_NEW_ROOMS=1. # To allow creating fresh rooms per run, set ALLOW_NEW_ROOMS=1.
ROOM_VK=""
ROOM_TELEMOST="" ROOM_TELEMOST=""
ROOM_WBSTREAM="" ROOM_WBSTREAM=""
ROOM_DION="" ROOM_DION=""
+5 -3
View File
@@ -12,9 +12,11 @@ No external network is used.
## Platforms and scenarios ## Platforms and scenarios
Platforms: telemost, wbstream, dion, bitrix. VK is not supported because it has no Platforms: telemost, wbstream, dion, bitrix, vk. A platform skips the scenarios it
headless SOCKS joiner. A platform skips the scenarios it does not support. For does not support: dion supports only connect and kick, vk only connect and dc.
example, dion supports only connect and kick.
`vk` runs only when named, needs `relay/relay` from `./build-go.sh`, and opens the VK
captcha in your browser.
| Scenario | Joiner | | Scenario | Joiner |
|----------|--------| |----------|--------|
+60
View File
@@ -8,6 +8,8 @@ FAIL_FAST="${FAIL_FAST:-1}"
ABORT_RUN=0 ABORT_RUN=0
CHILD_PIDS="" CHILD_PIDS=""
JOINER_PIDS="" JOINER_PIDS=""
JOINER_FIFO=""
RESOLVER_PID=""
SINK_PID="" SINK_PID=""
SINK_PORT="" SINK_PORT=""
SINK_FILE="" SINK_FILE=""
@@ -83,6 +85,13 @@ stop_sink() {
} }
kill_joiners() { kill_joiners() {
if [ -n "$RESOLVER_PID" ]; then
kill "$RESOLVER_PID" 2>/dev/null
RESOLVER_PID=""
fi
exec 3>&-
rm -f "$JOINER_FIFO"
JOINER_FIFO=""
for _p in $JOINER_PIDS; do kill "$_p" 2>/dev/null; done for _p in $JOINER_PIDS; do kill "$_p" 2>/dev/null; done
for _p in $JOINER_PIDS; do wait "$_p" 2>/dev/null; done for _p in $JOINER_PIDS; do wait "$_p" 2>/dev/null; done
JOINER_PIDS="" JOINER_PIDS=""
@@ -142,6 +151,57 @@ wait_socks() {
return 1 return 1
} }
resolve_host() {
if command -v getent >/dev/null 2>&1; then
getent ahostsv4 "$1" 2>/dev/null | awk '{print $1; exit}'
elif command -v dig >/dev/null 2>&1; then
dig +short A "$1" 2>/dev/null | grep -m1 '^[0-9]'
else
ping -c1 -W1 "$1" 2>/dev/null | sed -n '1s/.*(\([0-9.]*\)).*/\1/p'
fi
}
answer_resolves() {
_lf="$1"
_done=0
while :; do
_total=$(grep -c '^RESOLVE:' "$_lf" 2>/dev/null || true)
[ -n "$_total" ] || _total=0
while [ "$_done" -lt "$_total" ]; do
_done=$((_done + 1))
_host=$(grep '^RESOLVE:' "$_lf" | sed -n "${_done}p" | sed 's/^RESOLVE://')
_ip=$(resolve_host "$_host")
[ -n "$_ip" ] || _ip="0.0.0.0"
log " resolve $_host -> $_ip"
printf '%s\n' "$_ip" >&3
done
sleep 1
done
}
open_captcha() {
_lf="$1"
_end=$(($(now) + CONNECT_TIMEOUT))
while [ "$(now)" -lt "$_end" ]; do
_url=$(grep -m1 -o 'CAPTCHA:http://[^[:space:]]*' "$_lf" 2>/dev/null | sed 's/^CAPTCHA://')
if [ -n "$_url" ]; then
log " captcha required, opening $_url"
if command -v open >/dev/null 2>&1; then
open "$_url"
elif command -v xdg-open >/dev/null 2>&1; then
xdg-open "$_url"
else
log " no browser opener on this host, solve it manually at $_url"
fi
return 0
fi
nc -z "$PROBE_HOST" "$JOINER_PORT" 2>/dev/null && return 0
proc_alive "$JOINER_PID" || return 1
sleep 1
done
return 0
}
probe_once() { probe_once() {
_sp="$1" _sp="$1"
_nonce="ping-$_sp-$PROBE_SEQ" _nonce="ping-$_sp-$PROBE_SEQ"
+10
View File
@@ -3,6 +3,7 @@ set -u
cookies_path() { cookies_path() {
_p="$1" _p="$1"
case "$_p" in case "$_p" in
vk) _f="cookies-vk.json" ;;
telemost) _f="cookies-yandex.json" ;; telemost) _f="cookies-yandex.json" ;;
wbstream) _f="cookies-wbstream.json" ;; wbstream) _f="cookies-wbstream.json" ;;
dion) _f="cookies-dion.json" ;; dion) _f="cookies-dion.json" ;;
@@ -26,7 +27,16 @@ room_value() {
pf_select() { pf_select() {
PF_NAME="$1" PF_NAME="$1"
PF_JOINER_MODE=""
case "$1" in case "$1" in
vk)
PF_CREATOR="$HEADLESS/vk/headless-vk-creator"
PF_JOINER="$E2E_ROOT/relay/relay"
PF_JOINER_MODE="vk-headless-joiner"
PF_CREATOR_ROOM_FLAG="--vk-link"
PF_READY_RE="\[vk-ws\] Connected"
PF_CAPS="connect dc"
;;
telemost) telemost)
PF_CREATOR="$HEADLESS/telemost/headless-telemost-creator" PF_CREATOR="$HEADLESS/telemost/headless-telemost-creator"
PF_JOINER="$HEADLESS/telemost-joiner/headless-telemost-joiner" PF_JOINER="$HEADLESS/telemost-joiner/headless-telemost-joiner"
+4 -22
View File
@@ -23,30 +23,12 @@ usage() {
cat >&2 <<EOF cat >&2 <<EOF
Usage: $0 [platform...] [scenario...] Usage: $0 [platform...] [scenario...]
Live end-to-end harness: brings up a headless creator, connects one or more Platforms: $ALL_PLATFORMS vk
headless joiners, and proves each tunnel by echoing a nonce through the joiner's
SOCKS5 to a local sink (no external network, no rate limits).
Platforms: $ALL_PLATFORMS
Scenarios: $ALL_SCENARIOS Scenarios: $ALL_SCENARIOS
connect one joiner, default video tunnel
dc one joiner, --tunnel-mode dc
kcp one joiner, --reliable (KCP)
dual one joiner, --dual-track
kick two joiners on one room, expect the first to be kicked
No args runs every applicable scenario on every platform. Unsupported No args runs every applicable scenario on every platform, except vk.
platform/scenario pairs are skipped.
Cookies: COOKIES_DIR (default repo root) holds cookies-<platform>.json, or set See headless/tests/README.md.
COOKIES_<PLATFORM> to a explicit path. Missing cookies skip that platform.
Env: CREATE_TIMEOUT CONNECT_TIMEOUT PROBE_TIMEOUT KICK_TIMEOUT PORT_BASE
Examples:
$0
$0 bitrix
$0 wbstream dc kick
EOF EOF
} }
@@ -59,7 +41,7 @@ for _arg in "$@"; do
usage usage
exit 0 exit 0
;; ;;
telemost | wbstream | dion | bitrix) vk | telemost | wbstream | dion | bitrix)
RUN_PLATFORMS="$RUN_PLATFORMS $_arg" RUN_PLATFORMS="$RUN_PLATFORMS $_arg"
;; ;;
connect | dc | kcp | dual | kick) connect | dc | kcp | dual | kick)
+21
View File
@@ -103,6 +103,10 @@ start_joiner() {
alloc_port alloc_port
JOINER_PORT="$ALLOC_PORT" JOINER_PORT="$ALLOC_PORT"
JOINER_LOG=$(mktemp -t e2e-joiner.XXXXXX) JOINER_LOG=$(mktemp -t e2e-joiner.XXXXXX)
if [ -n "$PF_JOINER_MODE" ]; then
start_stdin_joiner "$_variant"
return
fi
_flags=$(pf_variant_flags "$_variant") _flags=$(pf_variant_flags "$_variant")
$JOINER_WRAP "$PF_JOINER" "$PF_LINK_FLAG" "$JOIN_LINK" --socks-host "$JOINER_SOCKS_HOST" --socks-port "$JOINER_PORT" $_flags >"$JOINER_LOG" 2>&1 & $JOINER_WRAP "$PF_JOINER" "$PF_LINK_FLAG" "$JOIN_LINK" --socks-host "$JOINER_SOCKS_HOST" --socks-port "$JOINER_PORT" $_flags >"$JOINER_LOG" 2>&1 &
JOINER_PID=$! JOINER_PID=$!
@@ -110,6 +114,23 @@ start_joiner() {
track_joiner "$JOINER_PID" track_joiner "$JOINER_PID"
} }
start_stdin_joiner() {
_tunnel_mode=video
[ "$1" = "dc" ] && _tunnel_mode=dc
JOINER_FIFO=$(mktemp -u -t e2e-joiner-fifo.XXXXXX)
mkfifo "$JOINER_FIFO"
$JOINER_WRAP "$PF_JOINER" --mode "$PF_JOINER_MODE" --socks-host "$JOINER_SOCKS_HOST" --socks-port "$JOINER_PORT" <"$JOINER_FIFO" >"$JOINER_LOG" 2>&1 &
JOINER_PID=$!
track_pid "$JOINER_PID"
track_joiner "$JOINER_PID"
exec 3>"$JOINER_FIFO"
answer_resolves "$JOINER_LOG" &
RESOLVER_PID=$!
track_pid "$RESOLVER_PID"
printf 'AUTH:{"joinLink":"%s","displayName":"e2e","tunnelMode":"%s"}\n' "$JOIN_LINK" "$_tunnel_mode" >&3
open_captcha "$JOINER_LOG"
}
joiner_up() { joiner_up() {
wait_socks "$1" "$CONNECT_TIMEOUT" && probe_ready "$1" "$PROBE_TIMEOUT" wait_socks "$1" "$CONNECT_TIMEOUT" && probe_ready "$1" "$PROBE_TIMEOUT"
} }
+1
View File
@@ -7,6 +7,7 @@ RUN apt-get update \
COPY work /work COPY work /work
RUN chmod +x /work/headless/*/headless-* \ RUN chmod +x /work/headless/*/headless-* \
/work/relay/relay \
/work/headless/tests/*.sh \ /work/headless/tests/*.sh \
/work/headless/tests/stand/*.sh /work/headless/tests/stand/*.sh
+1 -1
View File
@@ -25,7 +25,7 @@ RUN_PLATFORMS=""
RUN_SCENARIOS="" RUN_SCENARIOS=""
for _arg in "$@"; do for _arg in "$@"; do
case "$_arg" in case "$_arg" in
telemost | wbstream | dion | bitrix) RUN_PLATFORMS="$RUN_PLATFORMS $_arg" ;; vk | telemost | wbstream | dion | bitrix) RUN_PLATFORMS="$RUN_PLATFORMS $_arg" ;;
connect | dc | kcp | dual | kick) RUN_SCENARIOS="$RUN_SCENARIOS $_arg" ;; connect | dc | kcp | dual | kick) RUN_SCENARIOS="$RUN_SCENARIOS $_arg" ;;
*) *)
log "unknown argument: $_arg" log "unknown argument: $_arg"
+47 -18
View File
@@ -8,6 +8,7 @@ CTX="$DIR/.context"
IMAGE=wlb-e2e-stand IMAGE=wlb-e2e-stand
COMPONENTS="\ COMPONENTS="\
vk/headless-vk-creator \
telemost/headless-telemost-creator \ telemost/headless-telemost-creator \
wbstream/headless-wbstream-creator \ wbstream/headless-wbstream-creator \
dion/headless-dion-creator \ dion/headless-dion-creator \
@@ -21,23 +22,11 @@ usage() {
cat >&2 <<EOF cat >&2 <<EOF
Usage: stand.sh build | run [platform...] [scenario...] | sh Usage: stand.sh build | run [platform...] [scenario...] | sh
Dockerized live e2e: each of creator and joiner runs in its own network build cross-build linux binaries, docker build
namespace (distinct IP), so same-host WebRTC ICE does not collide. Traffic is
proved by echoing a nonce through the joiner's SOCKS5 to a sink on the creator's
loopback - no external network, no rate limits.
build cross-build linux binaries, stage cookies, docker build
run run the netns harness in a privileged container run run the netns harness in a privileged container
sh drop into a shell in the container for debugging sh drop into a shell in the container for debugging
Platforms: telemost wbstream dion bitrix (VK has no headless SOCKS joiner) See headless/tests/README.md.
Scenarios: connect dc kcp dual kick
Cookies are mounted from cookies-<platform>.json at the repo root on run.
Examples:
stand.sh build
stand.sh run
stand.sh run bitrix dc kick
EOF EOF
exit 1 exit 1
} }
@@ -55,12 +44,36 @@ build_context() {
GOOS=linux GOARCH="$arch" CGO_ENABLED=0 \ GOOS=linux GOARCH="$arch" CGO_ENABLED=0 \
go -C "$REPO/headless/$d" build -trimpath -ldflags="-s -w" -o "$CTX/work/headless/$d/$b" . go -C "$REPO/headless/$d" build -trimpath -ldflags="-s -w" -o "$CTX/work/headless/$d/$b" .
done done
mkdir -p "$CTX/work/relay"
echo "building relay (linux/$arch)..."
GOOS=linux GOARCH="$arch" CGO_ENABLED=0 \
go -C "$REPO/relay" build -trimpath -ldflags="-s -w" -o "$CTX/work/relay/relay" .
cp "$E2E/lib.sh" "$E2E/platforms.sh" "$E2E/scenarios.sh" "$CTX/work/headless/tests/" cp "$E2E/lib.sh" "$E2E/platforms.sh" "$E2E/scenarios.sh" "$CTX/work/headless/tests/"
[ -f "$E2E/.env" ] && cp "$E2E/.env" "$CTX/work/headless/tests/"
cp "$DIR/netns.sh" "$DIR/netns-run.sh" "$CTX/work/headless/tests/stand/" cp "$DIR/netns.sh" "$DIR/netns-run.sh" "$CTX/work/headless/tests/stand/"
cp "$DIR/Dockerfile" "$CTX/Dockerfile" cp "$DIR/Dockerfile" "$CTX/Dockerfile"
} }
bridge_captcha() {
_container="$1"
_pidfile="$2"
_seen=""
while :; do
sleep 2
for _url in $(docker logs "$_container" 2>&1 | grep -o 'http://127\.0\.0\.1:[0-9][0-9]*/' | sort -u); do
_port=$(echo "$_url" | sed 's|.*:\([0-9][0-9]*\)/|\1|')
case " $_seen " in
*" $_port "*) continue ;;
esac
_seen="$_seen $_port"
echo "captcha at $_url, bridging into the joiner namespace"
ncat -l 127.0.0.1 "$_port" --keep-open \
--sh-exec "docker exec -i $_container ip netns exec joiner ncat 127.0.0.1 $_port" &
echo $! >>"$_pidfile"
open "$_url" 2>/dev/null || echo "open it yourself: $_url"
done
done
}
case "${1:-}" in case "${1:-}" in
build) build)
build_context build_context
@@ -74,11 +87,27 @@ case "${1:-}" in
f="$REPO/cookies-$c.json" f="$REPO/cookies-$c.json"
[ -f "$f" ] && cookie_mounts="$cookie_mounts -v $f:/cookies/cookies-$c.json" [ -f "$f" ] && cookie_mounts="$cookie_mounts -v $f:/cookies/cookies-$c.json"
done done
docker run --rm --cap-add=NET_ADMIN --cap-add=SYS_ADMIN \ env_mount=""
[ -f "$E2E/.env" ] && env_mount="-v $E2E/.env:/work/headless/tests/.env"
container="$IMAGE-run"
pidfile=$(mktemp -t wlb-captcha.XXXXXX)
docker rm -f "$container" >/dev/null 2>&1 || true
bridge_captcha "$container" "$pidfile" &
watcher=$!
status=0
docker run --rm --name "$container" --cap-add=NET_ADMIN --cap-add=SYS_ADMIN \
-e FAIL_FAST="${FAIL_FAST:-1}" \ -e FAIL_FAST="${FAIL_FAST:-1}" \
-e COOKIES_DIR=/cookies \ -e COOKIES_DIR=/cookies \
$cookie_mounts \ $cookie_mounts $env_mount \
"$IMAGE" /work/headless/tests/stand/netns-run.sh "$@" "$IMAGE" /work/headless/tests/stand/netns-run.sh "$@" || status=$?
if kill "$watcher" 2>/dev/null; then
wait "$watcher" 2>/dev/null || true
fi
if [ -s "$pidfile" ]; then
kill $(cat "$pidfile") 2>/dev/null || true
fi
rm -f "$pidfile"
exit "$status"
;; ;;
sh) sh)
docker run --rm -it --cap-add=NET_ADMIN --cap-add=SYS_ADMIN \ docker run --rm -it --cap-add=NET_ADMIN --cap-add=SYS_ADMIN \
+15 -4
View File
@@ -398,8 +398,9 @@ func (b *Bridge) handleVKMessage(raw []byte) {
log.Printf("[vk-ws] Topology changed to %s", topo) log.Printf("[vk-ws] Topology changed to %s", topo)
b.topology = topo b.topology = topo
if topo != TopologyDirect { if topo != TopologyDirect {
b.bounceForServerTopology("SERVER topology") // b.bounceForServerTopology("SERVER topology")
return // return
b.failForServerTopology("SERVER topology")
} }
case "participant-joined", "participant-added": case "participant-joined", "participant-added":
@@ -407,8 +408,9 @@ func (b *Bridge) handleVKMessage(raw []byte) {
b.peers[int64(pid)] = struct{}{} b.peers[int64(pid)] = struct{}{}
log.Printf("[vk-ws] Participant %d joined (total: %d)", int64(pid), len(b.peers)) log.Printf("[vk-ws] Participant %d joined (total: %d)", int64(pid), len(b.peers))
if b.topology != TopologyDirect { if b.topology != TopologyDirect {
b.bounceForServerTopology("participant joined under SERVER") // b.bounceForServerTopology("participant joined under SERVER")
return // return
b.failForServerTopology("participant joined under SERVER")
} }
} }
@@ -505,6 +507,11 @@ func (b *Bridge) initRelay() {
b.p2p.Init() b.p2p.Init()
} }
func (b *Bridge) failForServerTopology(reason string) {
log.Fatalf("[vk-ws] %s -> VK moved this call to server topology, it cannot be tunneled, create a new call and connect again", reason)
}
// unused, reconnecting no longer recovers DIRECT
func (b *Bridge) bounceForServerTopology(reason string) { func (b *Bridge) bounceForServerTopology(reason string) {
b.mu.Lock() b.mu.Lock()
if b.bouncing { if b.bouncing {
@@ -521,6 +528,10 @@ func (b *Bridge) bounceForServerTopology(reason string) {
sfu := b.sfu sfu := b.sfu
b.mu.Unlock() b.mu.Unlock()
// if alreadySuppressed {
// log.Fatalf("[vk-ws] %s -> still SERVER after %d reconnects and screenshare suppression, this call runs through the VK server and cannot be tunneled, create a new call", reason, count)
// }
if suppress { if suppress {
log.Printf("[vk-ws] %s -> reconnect #%d, suppressing screenshare to settle single-track DIRECT", reason, count) log.Printf("[vk-ws] %s -> reconnect #%d, suppressing screenshare to settle single-track DIRECT", reason, count)
} else { } else {
+3 -3
View File
@@ -86,7 +86,7 @@ func (h *VKHeadlessJoiner) runWithAuth(jsonParams string) {
TunnelMode string `json:"tunnelMode"` TunnelMode string `json:"tunnelMode"`
VP8FPS int `json:"vp8Fps"` VP8FPS int `json:"vp8Fps"`
VP8Batch int `json:"vp8Batch"` VP8Batch int `json:"vp8Batch"`
DualTrack bool `json:"dualTrack"` // DualTrack bool `json:"dualTrack"` // VK does not support dual track
} }
if err := json.Unmarshal([]byte(jsonParams), &params); err != nil { if err := json.Unmarshal([]byte(jsonParams), &params); err != nil {
log.Printf("vk-joiner: failed to parse auth params: %v", err) log.Printf("vk-joiner: failed to parse auth params: %v", err)
@@ -111,11 +111,11 @@ func (h *VKHeadlessJoiner) runWithAuth(jsonParams string) {
authParams["tunnelMode"] = params.TunnelMode authParams["tunnelMode"] = params.TunnelMode
authParams["vp8Fps"] = params.VP8FPS authParams["vp8Fps"] = params.VP8FPS
authParams["vp8Batch"] = params.VP8Batch authParams["vp8Batch"] = params.VP8Batch
authParams["dualTrack"] = params.DualTrack // authParams["dualTrack"] = params.DualTrack
if patched, err := json.Marshal(authParams); err == nil { if patched, err := json.Marshal(authParams); err == nil {
authJSON = string(patched) authJSON = string(patched)
} }
} }
log.Printf("vk-auth: sending join params to relay (mode=%s dualTrack=%v)", params.TunnelMode, params.DualTrack) log.Printf("vk-auth: sending join params to relay mode=%s", params.TunnelMode)
h.inner.RunWithParams(authJSON) h.inner.RunWithParams(authJSON)
} }