diff --git a/crates/voelin-core/tests/live.rs b/crates/voelin-core/tests/live.rs index 105aa04..5c637a6 100644 --- a/crates/voelin-core/tests/live.rs +++ b/crates/voelin-core/tests/live.rs @@ -1,8 +1,10 @@ //! Engine against the development servers (dev/docker-compose.yml). //! Runs only with `VOELIN_LIVE=1`; `scripts/it-smoke.sh` sets it. +use std::sync::LazyLock; use std::time::Duration; +use tokio::sync::RwLock; use tokio::sync::broadcast::Receiver; use tokio::time::{Instant, timeout_at}; use voelin_core::{ @@ -15,6 +17,17 @@ fn live() -> bool { std::env::var("VOELIN_LIVE").is_ok_and(|v| v == "1") } +/// The TeamSpeak 6 server's banners are the server's, and `ts6_banners` sets and +/// unsets them there. While it does, whatever else connects to the server is +/// told the addresses of those banners, and an engine fetches what it is told +/// (as it should): the requests of such an engine reached the HTTP server of +/// `ts6_banners`, which counts the requests of the engine under test, and the +/// test failed on `disabled policy must prevent HTTP requests` in every run +/// that had the tests of this file run side by side (as they do). The tests +/// that connect to the server hold this shared, `ts6_banners` exclusively: it +/// runs with the server to itself, and the others before or after it. +static TS6: LazyLock> = LazyLock::new(|| RwLock::new(())); + /// Wait for an event matching `f`, failing after 20 s. async fn wait_for( rx: &mut Receiver, @@ -131,6 +144,7 @@ async fn ts6_engine() { if !live() { return; } + let _server = TS6.read().await; engine_roundtrip("127.0.0.1:9988", query(voelin_query::Transport::Ssh, "127.0.0.1:10022")) .await; } @@ -258,6 +272,7 @@ async fn ts6_channel_joins() { if !live() { return; } + let _server = TS6.read().await; channel_joins("127.0.0.1:9988", query(voelin_query::Transport::Ssh, "127.0.0.1:10022")).await; } @@ -329,6 +344,7 @@ async fn ts6_banners() { if !live() { return; } + let _server = TS6.write().await; let voice_addr = std::env::var("VOELIN_BANNER_VOICE_ADDR").unwrap_or_else(|_| "127.0.0.1:9988".into()); let query_addr = @@ -512,6 +528,7 @@ async fn ts6_avatars() { if !live() { return; } + let _server = TS6.read().await; let voice_addr = std::env::var("VOELIN_BANNER_VOICE_ADDR").unwrap_or_else(|_| "127.0.0.1:9988".into()); let dir = std::env::temp_dir().join(format!("voelin-live-avatars-{}", std::process::id())); diff --git a/scripts/it-smoke.sh b/scripts/it-smoke.sh index 466ae84..12990ff 100755 --- a/scripts/it-smoke.sh +++ b/scripts/it-smoke.sh @@ -536,6 +536,12 @@ done log "TeamSpeak session (voelin-core ts_session) against both servers: link conformance subset, chat, refused moves, poke, voice, files" VOELIN_LIVE=1 cargo test --quiet -p voelin-core --lib ts_session::live_tests -- --test-threads=1 2>&1 | grep -E "test result|panicked|timed out" || fail "TeamSpeak session tests failed" +# The engine tests of one binary run side by side and share the TeamSpeak 6 +# server: ts6_banners sets the server's banners, which every other engine that +# connects meanwhile fetches, so crates/voelin-core/tests/live.rs lets it run +# alone (a lock the TS6 tests hold, ts6_banners exclusively). It used to fail +# on `disabled policy must prevent HTTP requests` in every run of this stage. +# Not run with --test-threads=1: that hid the problem, it did not remove it. log "engine (voelin-core) against both servers, media pipeline through TS6" VOELIN_LIVE=1 cargo test --quiet -p voelin-core --features media-desktop --test live --test stream_live --test media_live 2>&1 | grep -E "test result|panicked|timed out" || fail "engine tests failed"