Author SHA1 Message Date
faumarayandClaude Fable 5.1 e807df40e5 docs: ci.md quotes the right git error, removes root's files, names the bare clone, follows main's loopback and D-Bus tests; .scratch/ ignored
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-25 02:04:08 +03:00
faumaray a8dbc5ba74 Merge remote-tracking branch 'origin/main' into phase5/tests-under-runner 2026-10-25 02:03:16 +03:00
faumarayandClaude Sonnet 5.5 1de2725f19 Remove a cancelled download's part file after its task has stopped
The download test, which 61458df of this branch made wait for the part file,
exposed a defect of the link: a download reports Started just before it opens its part file, and the
open ran on tokio's blocking pool. Link::cancel() aborted the task and removed
the part file at once; when the cancel came between Started and the end of the
open, there was no file yet to remove, the abort cannot stop an open that is
already on the blocking pool, and the open then made an empty `<name>.part`
next to the target after the transfer had been reported Cancelled. The user
sees a leftover file, and a later download with `resume` continues from it.

files::receive now makes the directory and opens the part file with std::fs in
one step (the same kind of small blocking call as Sink::offset and the removal
in cancel, which already ran on the loop), so an abort, which takes effect at
an await, cannot come in the middle of it. Link::cancel() keeps the task's
JoinHandle instead of its AbortHandle, aborts the task, and removes the part
file and reports Cancelled from a task of its own after the aborted one has
stopped: the file the task made is then there to be found, or the task never
got to make one. Cancelled is therefore reported after the removal and after
the task has stopped, where it was reported before both.

The test goes back to the shape it had before 61458df: it cancels as soon as
the transfer is Started (and now fails loudly if it never was). That shape
failed in 10 of 100 runs of the voelin-core lib tests three at a time with 16
busy loops beside them on a 32-core machine, and in the final runs of the CI
test step in the runner image of this task (the second of three); with this
change it failed in none of 200 such runs. The link and files tests pass.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 23:07:48 +03:00
faumarayandClaude Sonnet 5.5 443559aa79 Take the keyframe baseline of the layer-format test after the streamer has settled
stream::tests::layer_formats_reach_the_live_stream asserts that telling the
sink the same layer format twice asks for no second keyframe: it drains the
sink's keyframe requests, changes the format, waits for the request that
follows, tells the same format again and expects none within 200 ms. It failed
once ("nothing changed", stream.rs:1326) in the first of the three final runs of
the CI test step in the runner image of this task, with the machine busy with
another job.

Requests reach the sink from the stream going live, from the streamer's own
view of its viewer connecting (PeerEvent::Connected, a moment after the viewer
sees WatchState::Connected, which is all the test waited for), from the
viewer's picture requests, and from a changed layer. The test drained once,
right after the viewer's side was connected, so a request of one of the first
three that arrives later is taken for the one the changed format asked for, and
the real one then arrives after the "same again" and is counted as a change.
This could not be reproduced here (0 in 400 runs of the single test, 32 at a
time with 48 busy loops, nor in 200 runs of the lib tests); the change closes
those windows as far as they can be named: the test waits for the streamer's
own Connected (StreamViewers) as well, and drains until a moment longer than
the merge interval of requests (250 ms) passes with no request, before the
format is changed. The assertions are those of before.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 21:42:15 +03:00
faumarayandClaude Sonnet 5.5 272de7a13d Read the streamer's stats until they show what the viewer already saw
Two voelin-core tests read Streamer::stats() once, at the moment a consumer had
seen the effect, and the stats lag behind it:

- stream::tests::test_pattern_through_stream_tasks asserted `video_frames >= 15`
  right after the viewer had decoded 15 pictures. The encoder counts a frame
  after the sink has taken it (`sink.send_video(..)`, then `fetch_add`), so the
  15th picture can be at the viewer first: video_frames was 14 with
  captured_frames 15 and the picture on screen.
- media::tests::an_automatic_bitrate_follows_the_stream asserted the layer's
  bitrate in the stats right after the sink had been told the layer's format;
  the stats had 0 (the layer's target is stored by the encoder thread, not by
  the call that tells the sink).

Both now poll for the value with a deadline (5 s, and 10 s as the test's other
waits), which is the same assertion without the order of two threads. Before,
on a 32-core machine with 32 busy loops beside the runs: the first failed on
that assertion in 7 of 150 runs of the stream tests six at a time, the second
in 19 of 120 runs of the voelin-core lib tests six at a time. After, in 200
runs of the lib tests three at a time with 16 busy loops beside them, neither
failed on these assertions.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 21:42:03 +03:00
faumarayandClaude Sonnet 5.5 61458df625 Cancel the download test's transfer only once its part file is made
link::tests::a_file_is_downloaded_through_the_connection_the_link_opens waited
for the Started state and then cancelled, expecting the part file to be gone
100 ms later. The download reports Started just before it opens the part file
(files::download, then receive), and the open runs on tokio's blocking pool. A
cancel that arrives in between finds no part file to remove (link cancel()
removes it at once and reports Cancelled), the aborted task cannot stop the
open that is already going on, and the part file is made after the cancel:
`assert!(!part.exists())` failed. It did so in the second of the final runs of
the CI test step in the runner image of this task, and in 10 of 100 runs of
the voelin-core lib tests with three of them at a time and 16 busy loops
beside them on a 32-core machine (none in 200 such runs with this change).

The test now waits for the part file itself, which is what "the transfer
waits in the middle" means, and checks that Started was reported.

This is a real, if small, defect of the product that the test exposed: a
cancel in the moment between Started and the end of the open leaves an empty
`<name>.part` next to the target. It is not fixed here: closing it takes
reporting Started after the open (it also feeds the chat and the preview size
limit) or waiting for the aborted task before the part is removed, which is a
change of the transfer code and not of a test. Recorded in the report of this
branch.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 21:41:37 +03:00
faumarayandClaude Sonnet 5.5 637ee58979 Record log lines in the tests through one subscriber for the whole process
web::tests::info_lines read the lines a closure logs with
tracing::subscriber::with_default. While that scoped subscriber is the only
one alive, tracing-core registers a callsite that another thread meets first
against that thread's own default, which is none, and the callsite stays
disabled for every thread. session::banner_tests::
a_failing_banner_is_logged_once_with_its_address flakes this way (lines == []):
it failed in one of eight runs of the CI test step in the runner image of
this task (assertion `left == right` failed: [] left: 0 right: 1 at
session.rs:2541; it passed in the other seven). Several other tests reach the same
"banner not downloaded" callsite through image_finished while it runs.

info_lines now installs a recording subscriber as the global default the first
time it is called, and each call records into a buffer of its own thread, so
every callsite is registered against the same subscriber and no scoped
dispatcher is created or dropped while tests run. The result is the same: the
lines `f` logged at info and above on its thread. The new test
info_lines_see_a_callsite_another_thread_met_first fails with the old helper
(lines == []) and passes with the new one.

The same change is 4be37e1 on phase4/seam-followups (not merged yet; it
measured 1 failure in 300 runs of banner_tests before and 0 in 600 after),
taken here unchanged so that a CI run of this branch does not stop on it and
the two branches merge without a conflict.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 20:08:50 +03:00
faumarayandClaude Sonnet 5.5 9aea876437 Ask improve_level for more than the test identity already has
ts::identity::tests::improve_level_keeps_the_key made its identity with
Identity::create(), which stops at the first counter whose level is 8 or more,
and asked improve_level for 13. About one identity in 32 has 13 or more
already, and improve_level then returns it as it is, so the assertion that the
counter grew fails. The test does not depend on the machine: it failed 9 times
in 300 runs of the single test on a developer machine, and once in the
offline run in the runner image of this task, a CI run that fails one time in
about thirty for it.

The target is now three levels above what the identity has, so the search
always runs. The assertions on the level, the callbacks and the counter use
that target.

The same change is 9254e08 on phase4/seam-followups (which also fixes four
other tests that fail on their own and is not merged yet): it is taken here
unchanged so that a CI run of this branch does not stop on it, and the two
branches merge without a conflict.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 19:53:00 +03:00
faumarayandClaude Sonnet 5.5 172bee5337 Say what the tests print when they skip only as precisely as the code does
The table of docs/ci.md quoted one skip message per row, but the tests print
several wordings per piece (for the H.264 encoder: "skipped: no H.264
encoder", "skipped: needs VP8 and H.264 encoders", "no h264_vaapi or H.264
decoder, skipped"; for FFmpeg: "FFmpeg not installed, skipped", "no FFmpeg with
libavformat, skipped", ...), and some live tests return without printing. The
rows now say a skipped line naming the piece, and keep an exact string only
where the code has exactly that one.

The row on DNS and the internet sat under a column headed "The image has no",
which read as if the job had no network; it has, for apt, rustup and crates.
The column is now headed "A test cannot count on" and the row says the tests
use no DNS or internet and names the #[ignore]d ones that would.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 19:11:42 +03:00
faumarayandClaude Sonnet 5.5 ac6937289d Name in docs/ci.md the job image the runner really registers
Runner setup told to register ubuntu-24.04:docker://ghcr.io/catthehacker/
ubuntu:act-24.04 while the new section on the tests says the test step runs in
docker.gitea.com/runner-images:ubuntu-24.04. The runner of this machine
(gitea-runner-performance, register script of its NixOS unit) is registered
with ubuntu-24.04:docker://docker.gitea.com/runner-images:ubuntu-24.04, and
`docker ps` shows its CI tasks running that image, so the label line was the
stale one. It now names that image, the network list names its registry in
place of GHCR, and the tests section says it is the image of the
ubuntu-24.04 label.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 19:11:03 +03:00
faumarayandClaude Sonnet 5.5 cd08498092 Make the documented image run start cargo, and its VoelinProtocol mirror work
The docker run that docs/ci.md prints for the tests under the job image hung
for ever once the apt and rustup setup was done: bash -c execs its last
command, so xvfb-run became the container's process 1 and never started cargo
(probed: with the runner image and xvfb installed, xvfb-run -a as process 1
stays up with an idle Xvfb, and the same command under --init finishes). The
command now has --init. The runner is not affected: it starts its steps with
docker exec.

The hint for the private dependency is part of the block now, so the block
runs as printed: the bare clone is mounted at /protocol.git (it was never
mounted into the container before) and `git config` runs with -C /, because a
git worktree's .git file points outside the /src mount and git config in /src
exits 128 with "gitfile does not point to a valid repository".

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 19:11:03 +03:00
faumarayandClaude Fable 5.1 6e0df5178e Merge phase4/seam-followups: the gate's identity-text minor, the H9 edge list, five flaky tests
CI / Linux checks (push) Failing after 27m35s
An unreadable TeamSpeak identity is refused without its key in the text (the
classification of from_blob shared as from_json); VoiceOptions fields and
Backends::set_account documented; docs/session-seam.md 17.6 holds the complete
engine/ts edge list for the second half; improve_level, the contacts database
reopen, the banner log subscriber, the two localhost tests and the portal proxy
test made deterministic. Sonnet review accepted; its five minors (two more
DatabaseBusy/port races in tests/gateway.rs, a 1-in-130 voice handshake flake,
the from_json doc, the proxy wrapper's success check) go to the next
test-hygiene round.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-24 17:32:58 +03:00
faumarayandClaude Sonnet 5.5 8541d7c9e5 Document what the Linux job image lacks and how the tests cope
The test step runs as root in docker.gitea.com/runner-images:ubuntu-24.04
with only the apt packages of the system-dependencies action. docs/ci.md now
says how to run the CI's test command in that image with --no-fail-fast, and
lists what the image has no (a regular user, sound card, PipeWire daemons, a
session bus, GPU and VA-API, FFmpeg, an H.264 encoder, Wayland, a browser, the
TeamSpeak dev servers) with what each kind of test does about it. It also
records that two voelin-core tests fail on a machine whose ::1 swallows
connections, whatever the change under test is.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 17:16:19 +03:00
faumarayandClaude Sonnet 5.5 2c9c739732 Make an_unwritable_path_fails_at_once hold for root
The test started a recording at /nonexistent-root-dir/x/clip.webm and expected
an error. Recorder::start creates the missing parent directories, which a
regular user cannot do below / but root can: under the runner image (Gitea
run 1091, docker.gitea.com/runner-images:ubuntu-24.04, root) the call
succeeded, created /nonexistent-root-dir and left a file behind.

The test now builds its unwritable paths in a temporary directory from things
that fail for every user: a path below a regular file (ENOTDIR, so
create_dir_all fails) and a path that names an existing directory (EISDIR, so
File::create fails). The unknown-container name is checked in the same place
and also asserts that no file was created. Reproduced in the runner image as
root with the old test failing and the new one passing.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 16:42:41 +03:00
faumarayandClaude Fable 5.1 c91a3b719d Merge phase5/media-codec-test: peer_config_follows_codecs on a machine without an H.264 encoder
CI / Linux checks (push) Failing after 25m38s
The first CI run that could fetch the private dependency failed on this test
under the runner image. It now states preferred_codec's contract on any
machine. Reproduced and shown green inside docker.gitea.com/runner-images:ubuntu-24.04.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-24 15:34:27 +03:00
faumarayandClaude Sonnet 5.5 f374f5797b Record the round after the gate in the design of the session seam
17.8: the commits of the follow-up round, the five flaky tests (all fixed, how
each was reproduced and what the evidence is, including the two that are
rewrites and the one that was never seen again), and what ran on both
toolchains: fmt and clippy per commit, the lib suite ten times in a row on
each with no exclusions, the integration tests, cargo doc, the workspace check
with the environment that made it build, and the smoke script before and after
on fresh stacks. The status line names the round.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 15:26:46 +03:00
faumarayandClaude Sonnet 5.5 c35bbb5ba8 Run the portal proxy test on a bus of its own, or say it checked nothing
voelin-platform's tests/proxy.rs says to run it under dbus-run-session, and
without DBUS_SESSION_BUS_ADDRESS it returned at once. With one set it ran on
the desktop's bus and failed at "the portal leaves the bus": the test has its
stand-in release org.freedesktop.portal.Desktop, and the first call afterwards
starts the real xdg-desktop-portal, which the bus can start by name; it
answers instead of the "missing" the test expects for a minute. A private bus
from plain dbus-run-session starts it the same way (the test failed the same
three times under it here), so the documented way did not work on a desktop
that has the portal installed.

The test now runs itself again under dbus-run-session with a bus configuration
of its own, a session bus without service directories, so that nothing on it
can be started by name. Without dbus-run-session, or when the bus does not
come up, it says "skipped, nothing was checked" with the reason and passes;
when the test ran on its bus and failed, it fails with the output. The
stand-in and the assertions are the ones that were there.

On the bus with the default services the same inner test still fails as
before (checked by hand), and on the bus of its own it passes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 14:32:53 +03:00
faumarayandClaude Sonnet 5.5 a90bb70ee6 Let the test SOCKS proxy dial localhost at the IPv4 loopback
web::tests::pictures_go_through_the_proxy_named_for_each_hop downloads
http://localhost:<port>/banner through a SOCKS5h proxy of its own and asserts
that the proxy was given the name "localhost:<port>". The test proxy then
connected to that name through the system's resolver, and on a machine that
resolves localhost to ::1 only (this one) the server, which listens on
127.0.0.1, was not reachable: the download timed out after 20 s.

The proxy still reports the name it was given, as SOCKS5h says, and dials
localhost at 127.0.0.1 like the server it stands in front of.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 14:29:29 +03:00
faumarayandClaude Sonnet 5.5 e614a1c3f1 Probe localhost at the IPv4 loopback in the discovery test
discover::tests::without_records_the_gateway_itself_is_asked starts a server on
127.0.0.1 and has the discovery ask the gateway at "127.0.0.1",
"127.0.0.1:9987" and "localhost". The probe connected to the name through the
system's resolver, and on a machine that resolves localhost to ::1 only (this
one) nothing listens there: the third address found no gateway.

The test helper that makes the probe, probing, connects to localhost at
127.0.0.1 instead. What the test checks is that the gateway is asked at the
name localhost, not what the resolver makes of it, so it no longer depends on
the resolver.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 14:29:29 +03:00
faumarayandClaude Sonnet 5.5 4be37e1fd1 Record log lines in the tests through one subscriber for the whole process
web::tests::info_lines read the lines a closure logs with
tracing::subscriber::with_default. While that scoped subscriber is the only
one alive, tracing-core registers a callsite that another thread meets first
against that thread's own default, which is none, and the callsite stays
disabled for every thread. session::banner_tests::
a_failing_banner_is_logged_once_with_its_address flaked this way (lines == [],
once in a full run of slice 3); several other tests reach the same
"banner not downloaded" callsite through image_finished while it runs. The old
helper failed 1 of 300 runs of banner_tests, and always on a single thread
that meets the callsite first (the new test below).

info_lines now installs a recording subscriber as the global default the first
time it is called, and each call records into a buffer of its own thread, so
every callsite is registered against the same subscriber and no scoped
dispatcher is created or dropped while tests run. The result is the same: the
lines `f` logged at info and above on its thread. The new test
info_lines_see_a_callsite_another_thread_met_first fails with the old helper
(lines == []) and passes with the new one; the new helper failed 0 of 600
runs of the same tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 14:28:07 +03:00
faumarayandClaude Sonnet 5.5 0d67dd7433 Reopen the contacts database after the first engine has closed it
voice_features::contacts_are_kept_in_the_database dropped its engine and opened
the same database again at once. Dropping an Engine does not close the history
database: the engine task ends later, the history writer is joined there, and
closing the connection checkpoints the write-ahead log under an exclusive lock
with fsyncs. The second History::open waits for that lock only for the 5 s busy
timeout, and fails with DatabaseBusy when a loaded disk makes the close take
longer (seen as 3 failures in 8 runs, 10 in 24 with eight runs at a time).

The test now waits until the -wal file is gone, which SQLite does when the last
connection closes, before it reopens: the restart of a process, as the test
means it. With every fsync of the test process delayed by 6 s (strace -e
inject=fsync,fdatasync:delay_enter=6000000) the old test failed every time at
the reopen with DatabaseBusy, and the new one passes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 14:24:30 +03:00
faumarayandClaude Sonnet 5.5 9254e08daa Ask improve_level for more than the test identity already has
ts::identity::tests::improve_level_keeps_the_key made its identity with
Identity::create(), which stops at the first counter whose level is 8 or more,
and asked improve_level for 13. About one identity in 32 has 13 or more
already, and improve_level then returns it as it is, so the assertion that the
counter grew failed: 8 failures in 300 runs of the single test before this
change, 0 in 300 after.

The target is now three levels above what the identity has, so the search
always runs. The assertions on the level, the callbacks and the counter use
that target.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 14:21:22 +03:00
faumarayandClaude Sonnet 5.5 96ff0e0028 Write down the complete edge list between the engine and src/ts for H9
17.6 of docs/session-seam.md named two engine-to-ts edges; the Opus gate of the
merge found the rest. Each line was checked with rg and cargo tree:

- the engine into src/ts: Backends::default and register_teamspeak, the uid and
  id rule of the projection, gateway.rs from_blob/to_blob (H5), the public
  voelin_core::ts paths and their users in voelinctl and the UI crates, the
  API docs that link into ts, and the test-only edges;
- what a TeamSpeak connector in another crate cannot do with
  Backends::register (no LocalCtx, no StreamPort): streams across the crate
  boundary need H2 or a public extension trait;
- src/ts into engine-private items (link, stream, files, offline, the crate
  root, settings), with the conclusion that the "by git tag" step needs H1 and
  H2 or a shared vocabulary crate, else voelin-core and voelin-gateway-ts form
  a cycle;
- what else keeps tsclientlib and tsproto in voelin-core's tree, so that the
  exit check needs H5 too, and voelin-store, voelin-stream and
  voelin-gateway-proto lose the dependency;
- the split of stream.rs;
- the same key-quoting leak in voelin-store's Store::identity, not closed.

The H9 row of 11.2 points to the list and no longer says the exit check holds
after H1-H3 alone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 14:20:02 +03:00
faumarayandClaude Sonnet 5.5 563482db72 Document VoiceOptions.nickname and server_password; correct Backends::set_account
Both fields were carried over from ConnectOptions without a doc: what the
nickname is on each kind of server and that an empty one falls back to the
link's nickname parameter; that the server password is Hello.password, falls
back to the link's password parameter and is not the channel's.

Backends::set_account said the connectors use the account (the QUIC
connector's certificate, the TeamSpeak connector's myTS ID proof). No connector
reads ConnectParams.account yet: the TeamSpeak one is given the myTeamSpeak
account through TsConnector's setters, and the QUIC connector does not exist.
The doc says so and names H4 as the step that moves the proof to this hook.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 14:17:16 +03:00
faumarayandClaude Sonnet 5.5 a856f90c6b Refuse an unreadable TeamSpeak identity without its key in the text
The Opus gate of the merge found that ts_session::inner_options put the raw
serde_json error into the refusal of an identity it cannot read, and tsproto's
key visitor reports a key that does not import as invalid_value(Unexpected::Str(
key), ..), so the private key string reached LinkEvent::Disconnected(Some(text)),
Event::Error and the UI status line.

The classification ts::identity::from_blob already had (malformed, cut short,
not an identity, unreadable, with line and column, never the value) is now
ts::identity::from_json, which takes the JSON text; from_blob and inner_options
both use it, so the refusal is worded in one place. A credential that is not
UTF-8 is refused as "it is not text".

Tests: identity::tests (a key that lost its last two characters: the JSON
reader's own message quotes it, from_json and from_blob do not; no 8-character
piece of the key), ts_session::tests (inner_options), link::tests (the
LinkEvent::Disconnected text through SessionLink with the real connector) and
session_fake (ConnectVoice through the engine: the Disconnected state, the
Error event and every event after it). All three connector-side tests fail with
the serde_json text put back.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 14:16:06 +03:00
18 changed files with 757 additions and 76 deletions

No files matched your search

+2
View File
@@ -2,3 +2,5 @@
/dev/.state/
/dist/
/.cargo/
# agent scratch of a worktree (the MAO policy in CLAUDE.md)
/.scratch/
+7 -2
View File
@@ -453,10 +453,15 @@ mod tests {
lookups
}
/// `lookups` asking the real `/.well-known/tsgw` at `port`.
/// `lookups` asking the real `/.well-known/tsgw` at `port`. A name is
/// connected to through the system's resolver, except `localhost`: the
/// servers of the tests listen on 127.0.0.1, and some machines resolve
/// `localhost` to `::1` only. (The test cares that the gateway is asked at
/// the name `localhost`, not what the resolver makes of it.)
fn probing(mut lookups: Lookups, port: u16) -> Lookups {
lookups.probe = Arc::new(move |name| {
async move { timeout(PROBE_TIMEOUT, well_known(&name, port)).await.ok()?.ok() }.boxed()
let host = if name == "localhost" { "127.0.0.1".to_owned() } else { name };
async move { timeout(PROBE_TIMEOUT, well_known(&host, port)).await.ok()?.ok() }.boxed()
});
lookups
}
+14 -11
View File
@@ -199,19 +199,22 @@ async fn receive<R: AsyncRead + Unpin>(
let mut done = offset;
match sink {
Sink::File { part, dest, append } => {
// The directory and the file are made in one step, without a pause in
// which the task could be stopped: a cancel stops the task, waits for
// it and then removes the part file, so what the task made must be
// there by then (a pending open on the blocking pool would not be).
if let Some(dir) = part.parent().filter(|d| !d.as_os_str().is_empty()) {
tokio::fs::create_dir_all(dir)
.await
.map_err(|e| format!("{}: {e}", dir.display()))?;
std::fs::create_dir_all(dir).map_err(|e| format!("{}: {e}", dir.display()))?;
}
let mut file = tokio::fs::OpenOptions::new()
.create(true)
.write(true)
.append(*append)
.truncate(!*append)
.open(part)
.await
.map_err(|e| format!("{}: {e}", part.display()))?;
let mut file = tokio::fs::File::from_std(
std::fs::OpenOptions::new()
.create(true)
.write(true)
.append(*append)
.truncate(!*append)
.open(part)
.map_err(|e| format!("{}: {e}", part.display()))?,
);
let received = async {
while done < size {
let n = stream.read(&mut buf).await.map_err(|e| e.to_string())?;
+7 -3
View File
@@ -166,9 +166,13 @@ impl Backends {
self.register_local(Arc::new(connector));
}
/// The device's Voelin account, for the connectors that use it (the QUIC
/// connector's certificate, the TeamSpeak connector's myTS ID proof).
/// None is the default: nothing uses an account yet.
/// The device's Voelin account, which every connect hands the connector as
/// `ConnectParams::account`. No connector reads it yet: the TeamSpeak
/// connector takes the myTeamSpeak account it presents from its own setters
/// ([`TsConnector::set_myts_identity`], [`TsConnector::set_myts_data`]), and a
/// Voelin host's connector (the QUIC one, for its certificate) does not exist
/// yet. Follow-up H4 of `docs/session-seam.md` (11.2) moves the myTeamSpeak
/// proof from those setters to this hook. None is the default.
pub fn set_account(&mut self, agent: Option<Arc<dyn AccountAgent>>) {
self.account = agent;
}
+8
View File
@@ -64,6 +64,10 @@ pub struct VoiceOptions {
/// scheme (`ts3server://`, `teamspeak://`, a Voelin host's `voelin://`)
/// that picks the connector ([`Backends`]).
pub address: String,
/// The name shown on the server: `Hello.nickname` to a Voelin host, the
/// client name on a TeamSpeak server (which may refuse or change it). When
/// it is empty, the `nickname` parameter of an `address` that is a
/// TeamSpeak link applies.
pub nickname: String,
/// The identity to connect with: a TeamSpeak identity
/// ([`crate::ts::identity::to_blob`]) for a TeamSpeak server, a Voelin key
@@ -76,6 +80,10 @@ pub struct VoiceOptions {
/// `<platform>@<version>`); `None` is the native platform's. A spec that is
/// none ends the connect with the reason. Other backends ignore it.
pub client_version: Option<String>,
/// The password of the server (`Hello.password`), for one that has a
/// password. When it is `None` or empty, the `password` parameter of an
/// `address` that is a TeamSpeak link applies. Not the password of
/// `channel` (that is `channel_password`).
pub server_password: Option<String>,
/// Channel path to join, e.g. `Lobby/Sub`, or `/<id>`.
pub channel: Option<String>,
+19 -13
View File
@@ -77,7 +77,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::time::{Duration, Instant};
use tokio::sync::mpsc;
use tokio::task::AbortHandle;
use tokio::task::JoinHandle;
use tracing::{debug, info, warn};
use voelin_audio::EncodedVoice;
use voelin_model::replica::{Replica, SCHEMA_GENERATION, ScopeId};
@@ -325,7 +325,7 @@ async fn drive(
/// A transfer a user can cancel.
struct Running {
task: AbortHandle,
task: JoinHandle<()>,
part: Option<PathBuf>,
report: Report,
/// The server has opened it (a part file may exist).
@@ -1479,7 +1479,7 @@ impl Conn {
receive.await;
}
});
self.running(transfer, Running { task: task.abort_handle(), part, report, started });
self.running(transfer, Running { task, part, report, started });
}
fn upload(
@@ -1560,7 +1560,7 @@ impl Conn {
let stored = async move { done.await.map(|_| ()).map_err(|e| text(&e, false)) };
files::upload_to(body, stored, from, size, offset, progress, task_report).await;
});
self.running(transfer, Running { task: task.abort_handle(), part: None, report, started });
self.running(transfer, Running { task, part: None, report, started });
}
fn running(&mut self, transfer: Option<TransferId>, running: Running) {
@@ -1572,15 +1572,21 @@ impl Conn {
fn cancel(&mut self, id: TransferId) {
match self.transfers.remove(&id) {
Some(running) if !running.task.is_finished() => {
running.task.abort();
// A part file exists once the server has opened the transfer.
if running.started.load(Ordering::Acquire)
&& let Some(part) = running.part
{
let _ = std::fs::remove_file(part);
}
(running.report)(TransferState::Cancelled);
Some(Running { task, part, report, started }) if !task.is_finished() => {
task.abort();
// The part file goes once the task has stopped, not at once: the task
// opens it in one step (files::download), so it is there or it never
// will be, and a removal that came before the open would leave it.
tokio::spawn(async move {
let _ = task.await;
// A part file exists once the server has opened the transfer.
if started.load(Ordering::Acquire)
&& let Some(part) = part
{
let _ = std::fs::remove_file(part);
}
report(TransferState::Cancelled);
});
}
_ => debug!(id, "cancel: no such transfer (finished?)"),
}
+32
View File
@@ -607,6 +607,12 @@ async fn a_file_is_downloaded_through_the_connection_the_link_opens() {
}
tokio::time::sleep(Duration::from_millis(10)).await;
}
assert!(
states.lock().unwrap().iter().any(|s| matches!(s, TransferState::Started { .. })),
"the transfer started: {:?}",
states.lock().unwrap()
);
// Cancelled the moment it is Started, when its part file may be opening.
rig.give(LinkCmd::CancelTransfer(3));
assert_eq!(final_state(&states).await, TransferState::Cancelled);
rig.quiet();
@@ -981,6 +987,32 @@ async fn a_connect_that_fails_is_a_disconnect_with_the_reason() {
);
}
/// An identity that cannot be read ends the connect with a disconnect whose
/// text says where it is wrong and holds none of the key: the JSON reader's
/// own message quotes a key that does not import, and the engine shows this
/// text as the error of the connection.
#[tokio::test(flavor = "multi_thread")]
async fn an_identity_that_cannot_be_read_is_a_disconnect_without_the_key() {
let (json, cut) = crate::ts::identity::json_with_a_cut_key();
let mut options = VoiceOptions::new("ts3server://127.0.0.1:9", "tester");
options.identity = Some(IdentityBlob::teamspeak("uid=", 8, json));
let link = SessionLink::new(Backends::default());
let (_cmd_tx, cmd_rx) = mpsc::unbounded_channel();
let (event_tx, mut events) = mpsc::unbounded_channel();
link.spawn(options, LocalCtx::standalone().link, cmd_rx, event_tx);
let event = within("the end", events.recv()).await;
let LinkEvent::Disconnected(Some(text)) = event else {
panic!("a disconnect with the reason of the refusal")
};
assert!(
text.starts_with(
"the TeamSpeak identity cannot be read: not an identity at line 1, column "
),
"{text}"
);
crate::ts::identity::assert_holds_no_piece_of(&text, &cut);
}
// ---- the TeamSpeak side alone ---------------------------------------------------
/// A `LinkSession` over a recorder, made the way a connector makes it.
+6 -1
View File
@@ -3540,7 +3540,12 @@ mod tests {
let count = lock(&sink.formats).len();
tokio::time::sleep(Duration::from_millis(200)).await;
assert_eq!(lock(&sink.formats).len(), count);
assert_eq!(streamer.stats().layers[0].bitrate, auto_bitrate(640, 480, 30));
// The stats follow the sink's being told, not the other way round.
let deadline = Instant::now() + Duration::from_secs(10);
while streamer.stats().layers[0].bitrate != auto_bitrate(640, 480, 30) {
assert!(Instant::now() < deadline, "{:?}", streamer.stats().layers);
tokio::time::sleep(Duration::from_millis(20)).await;
}
let update = StreamerConfigUpdate { fps: Some(15), ..StreamerConfigUpdate::default() };
streamer.reconfigure(&codecs, update).unwrap();
told(15).await;
+34 -5
View File
@@ -1295,9 +1295,21 @@ mod tests {
// Before the viewer asks: its offer is made after this.
sink.layer_format(0, format(60_000_000));
handles[1].send(StreamCmd::Watch { stream_id: "s-1".into() });
wait(&mut rx, |e| match e {
Event::WatchState { session: 2, state: WatchState::Connected, .. } => Some(()),
_ => None,
// Connected for the viewer and for the streamer, in either order: the
// streamer asks for a keyframe when its viewer connects, a moment after
// the viewer has seen the connection.
let (mut watching, mut served) = (false, false);
wait(&mut rx, |e| {
match e {
Event::WatchState { session: 2, state: WatchState::Connected, .. } => {
watching = true;
}
Event::StreamViewers { session: 1, viewers } => {
served |= viewers.iter().any(|v| v.state == ViewerState::Connected);
}
_ => {}
}
(watching && served).then_some(())
})
.await;
// 3840x2160 at 60 fps is level 5.2 (0x34) in both profiles.
@@ -1312,7 +1324,15 @@ mod tests {
sink.take_layer_keyframes(&mut layers);
layers.contains(0)
};
keyframes();
// What asked for a keyframe so far (going live, the viewer's connecting
// and its first picture request) is done when a moment longer than the
// merging interval of requests (250 ms) passes with none.
for _ in 0..50 {
tokio::time::sleep(Duration::from_millis(300)).await;
if !keyframes() {
break;
}
}
sink.layer_format(0, format(9_000_000));
timeout(Duration::from_secs(5), async {
while !keyframes() {
@@ -1701,7 +1721,16 @@ mod tests {
let stats = pipeline.stats();
assert_eq!(stats.codec, Some(Codec::Vp8));
assert!(stats.error.is_none(), "{stats:?}");
let sent = streamer.stats();
// The encoder counts a frame once the sink has taken it, so the picture
// can be at the viewer before the count has moved.
let mut sent = streamer.stats();
for _ in 0..500 {
if sent.video_frames >= 15 && sent.audio_frames > 0 {
break;
}
tokio::time::sleep(Duration::from_millis(10)).await;
sent = streamer.stats();
}
assert!(sent.video_frames >= 15 && sent.audio_frames > 0, "{sent:?}");
handles[0].send(StreamCmd::Stop);
+63 -5
View File
@@ -255,8 +255,20 @@ pub fn from_blob(blob: &IdentityBlob) -> Result<Identity, IdentityError> {
blob.kind
)));
}
serde_json::from_str(&blob.json).map_err(|e| {
// Where the JSON is wrong, not what it says: it holds a private key.
from_json(&blob.json)
}
/// The TeamSpeak identity in `json`, the text [`to_blob`] writes and the key
/// store keeps; every reader of that text refuses it through here.
///
/// What does not read is refused in words that say how it is wrong
/// (malformed, cut short, not an identity, unreadable) and where (line and
/// column), and never what it holds: the text holds a private key, and the
/// message of the JSON reader quotes a value it refuses (`tsproto` reports a
/// key that does not import as an invalid value, the key string and all), so
/// that message is never shown, not in an error, an event or a log.
pub(crate) fn from_json(json: &str) -> Result<Identity, IdentityError> {
serde_json::from_str(json).map_err(|e| {
let what = match e.classify() {
serde_json::error::Category::Syntax => "malformed",
serde_json::error::Category::Eof => "cut short",
@@ -271,6 +283,27 @@ pub fn from_blob(blob: &IdentityBlob) -> Result<Identity, IdentityError> {
})
}
/// The JSON of a fresh identity whose key lost its last two characters (a key
/// that does not import), and that cut key.
#[cfg(test)]
pub(crate) fn json_with_a_cut_key() -> (String, String) {
let mut json = serde_json::to_value(Identity::create()).unwrap();
let key = json["key"].as_str().unwrap().to_owned();
let cut = key[..key.len() - 2].to_owned();
json["key"] = cut.clone().into();
(json.to_string(), cut)
}
/// Fail if `text` holds any 8 characters in a row of `secret`.
#[cfg(test)]
pub(crate) fn assert_holds_no_piece_of(text: &str, secret: &str) {
assert!(secret.len() >= 8 && secret.is_ascii());
for piece in secret.as_bytes().windows(8) {
let piece = std::str::from_utf8(piece).unwrap();
assert!(!text.contains(piece), "{text:?} holds {piece:?} of the key");
}
}
/// The TeamSpeak 3 `.ini` export of an identity, which the official client
/// and every other tool reads.
pub fn export(nickname: &str, identity: &Identity) -> String {
@@ -615,18 +648,43 @@ mod tests {
}
}
/// The JSON reader's own message quotes a key that does not import, so the
/// refusal is worded by `from_json` and holds none of the key.
#[test]
fn a_key_that_does_not_import_is_refused_without_quoting_it() {
let (json, cut) = json_with_a_cut_key();
let raw = serde_json::from_str::<Identity>(&json).unwrap_err().to_string();
assert!(raw.contains(&cut), "the reader's own message quotes the key: {raw}");
for error in [
from_json(&json).unwrap_err().to_string(),
from_blob(&IdentityBlob::teamspeak("x", 8, json.clone())).unwrap_err().to_string(),
] {
assert!(
error.starts_with(
"the TeamSpeak identity cannot be read: not an identity at line 1, column "
),
"{error}"
);
assert_holds_no_piece_of(&error, &cut);
}
}
#[test]
fn improve_level_keeps_the_key() {
let identity = synthetic();
// A fresh identity stops at the first counter whose level is 8 or more,
// and about one in 32 has 13 or more already, which `improve_level`
// returns as it is: ask for more than this one has, whatever it has.
let target = identity.level() + 3;
let levels = std::sync::Mutex::new(Vec::new());
let better = improve_level(&identity, 13, &AtomicBool::new(false), |l| {
let better = improve_level(&identity, target, &AtomicBool::new(false), |l| {
levels.lock().unwrap().push(l);
})
.unwrap();
assert!(better.level() >= 13);
assert!(better.level() >= target);
assert_eq!(better.key().to_pub().get_uid(), identity.key().to_pub().get_uid());
assert!(better.counter() > identity.counter());
assert!(levels.into_inner().unwrap().iter().any(|l| *l >= 13));
assert!(levels.into_inner().unwrap().iter().any(|l| *l >= target));
// Cancelled: nothing.
assert!(improve_level(&identity, 60, &AtomicBool::new(true), |_| {}).is_none());
// Already there: the same identity.
+36 -4
View File
@@ -43,7 +43,7 @@ use voelin_proto::link::{
use voelin_proto::v1::{self, response::Result as Answer};
use self::driver::{Cmd, Config, Driver, Parts, rejected};
use super::{ConnectOptions, ServerLink, TsLink, versions};
use super::{ConnectOptions, ServerLink, TsLink, identity, versions};
use crate::BackendInfo;
use crate::link::{
BoxDuplex, LinkCmd, LinkCtx, LinkEvent, LocalConnected, LocalConnector, LocalCtx, StreamPort,
@@ -82,9 +82,14 @@ fn inner_options(params: &ConnectParams, ctx: &LocalCtx) -> Result<ConnectOption
let identity = match &params.credential {
Credential::Foreign { kind: IDENTITY_KIND, blob } if blob.is_empty() => None,
Credential::Foreign { kind: IDENTITY_KIND, blob } => {
Some(serde_json::from_slice(blob).map_err(|e| {
SessionError::Protocol(format!("the TeamSpeak identity cannot be read: {e}"))
})?)
// The refusal never quotes the JSON: it holds the private key, and the
// JSON reader's own message would show a key that does not import.
let json = std::str::from_utf8(blob).map_err(|_| {
SessionError::Protocol(
"the TeamSpeak identity cannot be read: it is not text".into(),
)
})?;
Some(identity::from_json(json).map_err(|e| SessionError::Protocol(e.to_string()))?)
}
_ => {
return Err(SessionError::Protocol(
@@ -754,6 +759,33 @@ mod tests {
assert!(!futures::executor::block_on(confirm));
}
/// An identity that cannot be read ends the connect with words that say
/// where it is wrong and hold none of the key: the JSON reader's own
/// message quotes a key that does not import, and this text reaches the
/// event bus and the status line.
#[test]
fn an_identity_that_cannot_be_read_is_refused_without_the_key() {
let (json, cut) = identity::json_with_a_cut_key();
let mut sent = params(&VoiceOptions::new("ts.example.com", "nick"));
sent.credential = Credential::Foreign { kind: "teamspeak", blob: Bytes::from(json) };
let error = inner_options(&sent, &LocalCtx::standalone()).unwrap_err();
let SessionError::Protocol(text) = error else { panic!("a protocol error: {error:?}") };
assert!(
text.starts_with(
"the TeamSpeak identity cannot be read: not an identity at line 1, column "
),
"{text}"
);
identity::assert_holds_no_piece_of(&text, &cut);
// Not even text.
sent.credential =
Credential::Foreign { kind: "teamspeak", blob: Bytes::from_static(&[b'{', 0xff]) };
let error = inner_options(&sent, &LocalCtx::standalone()).unwrap_err();
let SessionError::Protocol(text) = error else { panic!("a protocol error: {error:?}") };
assert_eq!(text, "the TeamSpeak identity cannot be read: it is not text");
}
#[test]
fn the_params_carry_what_the_session_needs_and_no_account_yet() {
let sent = params(&VoiceOptions::new("ts.example.com", "nick"));
+71 -10
View File
@@ -960,11 +960,27 @@ pub(crate) mod tests {
/// What `f` logs at info (and above) on this thread: each line its
/// message, then its fields (` name=value`).
///
/// One recording subscriber is installed for the whole test process, the
/// first time this is called, and each call records into a buffer of its
/// own thread. A scoped one (`tracing::subscriber::with_default`) loses
/// lines: while it is the only subscriber alive, a callsite that another
/// test's thread meets first is registered against that thread's own
/// default, which is none, and stays disabled for every thread, so the
/// lines of the test that reads them are gone
/// (`session::banner_tests::a_failing_banner_is_logged_once_with_its_address`
/// failed with no lines at all, once in about thirty runs of the suite).
pub(crate) fn info_lines<T>(f: impl FnOnce() -> T) -> (T, Vec<String>) {
use std::cell::RefCell;
use std::sync::Once;
use tracing::field::{Field, Visit};
use tracing::span;
struct Lines(Arc<Mutex<Vec<String>>>);
thread_local! {
/// The lines of the `info_lines` running on this thread, if any.
static LINES: RefCell<Option<Vec<String>>> = const { RefCell::new(None) };
}
#[derive(Default)]
struct Line(String, String);
impl Visit for Line {
@@ -975,7 +991,8 @@ pub(crate) mod tests {
}
}
}
impl tracing::Subscriber for Lines {
struct Recorder;
impl tracing::Subscriber for Recorder {
fn enabled(&self, metadata: &tracing::Metadata<'_>) -> bool {
*metadata.level() <= tracing::Level::INFO
}
@@ -985,19 +1002,57 @@ pub(crate) mod tests {
fn record(&self, _: &span::Id, _: &span::Record<'_>) {}
fn record_follows_from(&self, _: &span::Id, _: &span::Id) {}
fn event(&self, event: &tracing::Event<'_>) {
let mut line = Line::default();
event.record(&mut line);
self.0.lock().unwrap().push(line.0 + &line.1);
LINES.with(|lines| {
if let Some(lines) = lines.borrow_mut().as_mut() {
let mut line = Line::default();
event.record(&mut line);
lines.push(line.0 + &line.1);
}
});
}
fn enter(&self, _: &span::Id) {}
fn exit(&self, _: &span::Id) {}
}
let lines = Arc::new(Mutex::new(Vec::new()));
let result = tracing::subscriber::with_default(Lines(lines.clone()), f);
let lines = lines.lock().unwrap().clone();
/// Ends the recording of this thread, also when `f` panics.
struct Recording;
impl Drop for Recording {
fn drop(&mut self) {
LINES.with(|lines| lines.borrow_mut().take());
}
}
static INSTALL: Once = Once::new();
INSTALL.call_once(|| {
tracing::subscriber::set_global_default(Recorder)
.expect("no other global tracing subscriber in the tests");
// Makes every callsite decide again with the subscriber in place, also
// one that a thread was registering while it was being installed
// (creating a `Dispatch` rebuilds the cached interest of all of them).
drop(tracing::Dispatch::new(Recorder));
});
LINES.with(|lines| *lines.borrow_mut() = Some(Vec::new()));
let _recording = Recording;
let result = f();
let lines = LINES.with(|lines| lines.borrow_mut().take().unwrap_or_default());
(result, lines)
}
/// The lines of `info_lines` do not depend on which thread met a callsite
/// first: this one is met on another thread, which records nothing, before
/// the thread that reads the lines meets it.
#[test]
fn info_lines_see_a_callsite_another_thread_met_first() {
fn log() {
tracing::info!("met");
}
let ((), lines) = info_lines(|| {
std::thread::spawn(log).join().unwrap();
log();
});
assert_eq!(lines, ["met"]);
}
fn temp_dir(tag: &str) -> std::path::PathBuf {
let dir = std::env::temp_dir().join(format!("voelin-web-{tag}-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&dir);
@@ -1375,9 +1430,15 @@ pub(crate) mod tests {
};
let mut port = [0u8; 2];
client.read_exact(&mut port).await.unwrap();
let target = format!("{host}:{}", u16::from_be_bytes(port));
let port = u16::from_be_bytes(port);
let target = format!("{host}:{port}");
targets.send(target.clone()).unwrap();
let mut server = TcpStream::connect(target).await.unwrap();
// The proxy resolves the name it is given (SOCKS5h). `localhost` is
// 127.0.0.1 to it, whatever this machine's resolver says: some answer
// `::1` only, and the servers of the tests listen on 127.0.0.1.
let dial =
if host == "localhost" { format!("127.0.0.1:{port}") } else { target };
let mut server = TcpStream::connect(dial).await.unwrap();
client.write_all(&[5, 0, 0, 1, 0, 0, 0, 0, 0, 0]).await.unwrap();
let _ = tokio::io::copy_bidirectional(&mut client, &mut server).await;
});
+52 -1
View File
@@ -10,7 +10,9 @@
//! dedup of a message that comes twice, history, transfers, offline messages,
//! the features of a host, a reconnect and the media of a session are the
//! engine's own behaviour; nothing here needs a TeamSpeak server or a
//! TeamSpeak type.
//! TeamSpeak type, except `a_teamspeak_identity_that_cannot_be_read_is_refused_without_the_key`,
//! which runs the engine's own TeamSpeak connector up to its refusal of an
//! identity.
use std::path::PathBuf;
use std::sync::Arc;
@@ -163,6 +165,12 @@ impl Harness {
fn on(connector: FakeConnector) -> Self {
let mut backends = Backends::empty();
backends.register(Arc::new(connector.clone()));
Self::with_backends(backends, connector)
}
/// The engine on `backends`; `connector` is the fake host the test may
/// have registered in them (a test that registers none leaves it unused).
fn with_backends(backends: Backends, connector: FakeConnector) -> Self {
let engine =
Engine::start_with_backends(Settings::in_memory(), History::in_memory(), backends);
let events = engine.subscribe();
@@ -1502,3 +1510,46 @@ async fn a_teamspeak_identity_without_json_is_refused_and_no_session_is_made() {
assert!(handle.close_reason().is_none());
assert_eq!(h.connector.connects().len(), 1);
}
/// A TeamSpeak identity whose key does not import ends the connect with words
/// that say where the JSON is wrong and never show the key: the JSON reader's
/// own message quotes it, and the text is the reason of the disconnect, the
/// `Error` event and the status line the UI makes of it. This is the one test
/// of the file that runs the engine's own TeamSpeak connector
/// (`Backends::default()`): the refusal is that connector's and comes before
/// any network.
#[tokio::test(flavor = "multi_thread")]
async fn a_teamspeak_identity_that_cannot_be_read_is_refused_without_the_key() {
let mut json = serde_json::to_value(tsclientlib::Identity::create()).unwrap();
let key = json["key"].as_str().unwrap().to_owned();
// The key lost its last two characters.
let cut = key[..key.len() - 2].to_owned();
json["key"] = cut.clone().into();
let mut options = VoiceOptions::new("ts3server://127.0.0.1:9", "tester");
options.identity = Some(IdentityBlob::teamspeak("uid=", 8, json.to_string()));
let mut h = Harness::with_backends(Backends::default(), FakeConnector::new());
h.engine.send(Command::ConnectVoice { session: SESSION, options: Box::new(options) });
let state = h.state(|s| s.voice == VoiceState::Disconnected).await;
assert_eq!((state.own_channel, state.own_client), (None, None));
let error = h.error().await;
assert!(
error.starts_with(
"voice: the TeamSpeak identity cannot be read: not an identity at line 1, column "
),
"{error}"
);
// Nothing the engine reported afterwards holds a piece of the key either.
let mut shown = vec![error];
while let Ok(Ok(event)) =
tokio::time::timeout(Duration::from_millis(300), h.events.recv()).await
{
shown.push(format!("{event:?}"));
}
for text in &shown {
for piece in cut.as_bytes().windows(8) {
let piece = std::str::from_utf8(piece).unwrap();
assert!(!text.contains(piece), "{text:?} holds {piece:?} of the key");
}
}
}
@@ -3,6 +3,7 @@
//! in the client database). The round trips against real servers are in
//! `scripts/it-smoke.sh` (`voelinctl engine`).
use std::path::{Path, PathBuf};
use std::time::Duration;
use tokio::sync::broadcast;
@@ -22,6 +23,29 @@ async fn next<T>(rx: &mut broadcast::Receiver<Event>, mut f: impl FnMut(Event) -
.expect("event in time")
}
/// Wait until nothing has the SQLite database at `path` open any more, as when
/// the process that had it has ended: SQLite deletes the write-ahead log
/// (`<path>-wal`) when the last connection closes.
///
/// A dropped `Engine` is not that yet. Its task ends later, the history writer
/// is joined there, and closing the connection checkpoints the log under an
/// exclusive lock, with fsyncs. A connection opened meanwhile waits for the
/// lock only as long as the busy timeout (5 s) and then fails with
/// `DatabaseBusy`, which a loaded disk makes happen (with every fsync taking
/// 6 s it happens every time).
async fn closed(path: &Path) {
let mut wal = path.as_os_str().to_owned();
wal.push("-wal");
let wal = PathBuf::from(wal);
tokio::time::timeout(Duration::from_secs(120), async {
while wal.exists() {
tokio::time::sleep(Duration::from_millis(10)).await;
}
})
.await
.expect("the engine's database connection closed");
}
#[tokio::test(flavor = "multi_thread")]
async fn requests_without_voice_fail_with_their_ids() {
let engine = Engine::start();
@@ -165,6 +189,7 @@ async fn contacts_are_kept_in_the_database() {
engine.history().flush();
}
// A new engine attaches the database later: the contacts come back.
closed(&path).await;
let engine = Engine::start();
let mut rx = engine.subscribe();
engine.send(Command::AttachHistory(History::open(&path).unwrap()));
@@ -350,7 +350,22 @@ mod tests {
#[test]
fn an_unwritable_path_fails_at_once() {
assert!(Recorder::start("/nonexistent-root-dir/x/clip.webm", 0, 2).is_err());
assert!(Recorder::start("clip.mp4", 0, 2).is_err());
let dir = dir("unwritable");
// A path below a regular file fails for every user, root included
// (ENOTDIR). A directory that is merely missing would be created, and
// a read-only one is written to by root.
let file = dir.join("not-a-directory");
std::fs::write(&file, b"x").unwrap();
assert!(Recorder::start(file.join("x").join("clip.webm"), 0, 2).is_err());
// The directory is there and the file cannot be created because the
// path names a directory (EISDIR, again for every user).
let named_like_a_file = dir.join("clip.webm");
std::fs::create_dir(&named_like_a_file).unwrap();
assert!(Recorder::start(&named_like_a_file, 0, 2).is_err());
// A name that asks for no known container is refused before any file
// is created.
assert!(Recorder::start(dir.join("clip.mp4"), 0, 2).is_err());
assert!(!dir.join("clip.mp4").exists());
std::fs::remove_dir_all(&dir).ok();
}
}
+69 -7
View File
@@ -1,8 +1,10 @@
//! The desktop's proxy through a stand-in xdg-desktop-portal on the
//! session bus. Run it on a private bus:
//! `dbus-run-session -- cargo test -p voelin-platform --test proxy`;
//! without a session bus it checks nothing. Its own test binary: answers
//! are kept process-wide.
//! The desktop's proxy through a stand-in xdg-desktop-portal on a session
//! bus. The test runs itself again under `dbus-run-session` on a bus of its
//! own that starts no services: on a desktop's bus the real portal is running
//! or startable, and when the stand-in leaves the bus (as the test has it do)
//! the real one is started and answers instead. Without `dbus-run-session`,
//! or a bus daemon for it, the test says so and checks nothing. Its own test
//! binary: answers are kept process-wide.
#![cfg(all(unix, not(target_os = "macos"), feature = "portal"))]
@@ -11,6 +13,9 @@ use std::sync::atomic::{AtomicU32, Ordering};
use voelin_platform::proxy::proxy_for;
/// Set for the run on the bus of its own.
const ON_ITS_OWN_BUS: &str = "VOELIN_PROXY_TEST_ON_ITS_OWN_BUS";
/// What the GNOME portal answers: a SOCKS proxy for one host, none for the
/// others.
struct Resolver {
@@ -34,10 +39,67 @@ impl Resolver {
}
}
/// The configuration of the bus of its own: a session bus without the service
/// directories, so that nothing on it can be started by name. Its socket is
/// made in `dir`.
fn bus_config(dir: &std::path::Path) -> String {
format!(
r#"<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<type>session</type>
<listen>unix:tmpdir={}</listen>
<auth>EXTERNAL</auth>
<policy context="default">
<allow send_destination="*" eavesdrop="true"/>
<allow eavesdrop="true"/>
<allow own="*"/>
</policy>
</busconfig>
"#,
dir.display()
)
}
/// Run this test again under `dbus-run-session` on a bus of its own, and say
/// nothing was checked when that bus cannot be had.
fn on_a_bus_of_its_own() {
let dir = std::env::temp_dir();
let config = dir.join(format!("voelin-proxy-test-bus-{}.conf", std::process::id()));
std::fs::write(&config, bus_config(&dir)).unwrap();
let run = std::process::Command::new("dbus-run-session")
.arg(format!("--config-file={}", config.display()))
.arg("--")
.arg(std::env::current_exe().unwrap())
.args(["--exact", "the_portal_names_the_proxy", "--nocapture", "--test-threads=1"])
.env(ON_ITS_OWN_BUS, "1")
.output();
let _ = std::fs::remove_file(&config);
let run = match run {
Ok(run) => run,
Err(e) => {
eprintln!("skipped, nothing was checked: dbus-run-session cannot be run ({e})");
return;
}
};
let text =
format!("{}{}", String::from_utf8_lossy(&run.stdout), String::from_utf8_lossy(&run.stderr));
if run.status.success() {
return;
}
// The test ran and failed, or the bus never came up.
assert!(
!text.contains("running 1 test"),
"the test failed on its own bus ({}):\n{text}",
run.status
);
eprintln!("skipped, nothing was checked: no bus of its own could be started:\n{text}");
}
#[tokio::test]
async fn the_portal_names_the_proxy() {
if std::env::var_os("DBUS_SESSION_BUS_ADDRESS").is_none() {
eprintln!("no session bus: run under dbus-run-session");
if std::env::var_os(ON_ITS_OWN_BUS).is_none() {
on_a_bus_of_its_own();
return;
}
let lookups = Arc::new(AtomicU32::new(0));
+89 -6
View File
@@ -46,17 +46,20 @@ the separate `release.yml` workflow below.
this label (the left side must match the workflow's `runs-on`):
```text
ubuntu-24.04:docker://ghcr.io/catthehacker/ubuntu:act-24.04
ubuntu-24.04:docker://docker.gitea.com/runner-images:ubuntu-24.04
```
Configure this in the runner's labels when registering/configuring it;
an `ubuntu-latest` label alone does not match. The job image must provide
Bash, Git, the OpenSSH client, Node.js for checkout v4, and root or
passwordless sudo for apt.
an `ubuntu-latest` label alone does not match. This is the image of the
runner that runs this repository's CI, and the one the tests are checked
against ([Tests under the job image](#tests-under-the-job-image)). The job
image must provide Bash, Git, the OpenSSH client, Node.js for checkout v4,
and root or passwordless sudo for apt.
3. Allow network access from the runner and job container to the Gitea
instance, GitHub (checkout action, dependencies and RustSec advisories),
GHCR (runner image), Ubuntu apt mirrors, rustup distribution servers,
crates.io and dependency/license sources used by cargo-about. The
`docker.gitea.com` (runner image), Ubuntu apt mirrors, rustup
distribution servers, crates.io and dependency/license sources used by
cargo-about. The
workspace also depends on the **private** VoelinProtocol repository
(`voelin-identity`, over SSH), so the job needs read access to it and the
server's SSH port. The workflows set that up themselves from a repository
@@ -102,6 +105,86 @@ all step results. Local YAML/shell checks do not prove that a particular
Gitea instance, runner registration, network policy or resource allocation
can complete this job.
### Tests under the job image
The test step runs as **root** in an Ubuntu 24.04 container of the
`ubuntu-24.04` label ([Runner setup](#runner-setup):
`docker.gitea.com/runner-images:ubuntu-24.04`, `HOME=/root`) to which only
the apt packages of the system-dependencies action are added. A test that
assumes a developer machine fails there, and a run takes about an hour, so
check a change to the tests the way CI runs them, with every failing test of
every crate listed in one go (`--no-fail-fast`):
```sh
# A bare clone of the private VoelinProtocol repository (see below the block):
# git clone --bare ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git <dir>
: "${PROTOCOL_GIT:?path of a bare clone of VoelinProtocol}"
# Root owns what the container writes: keep it in a directory of its own
# (.scratch/ is in .gitignore; see below the block for its removal).
mkdir -p .scratch
docker run --rm --init -v "$PWD":/src -w /src -e HOME=/root \
-v "$PROTOCOL_GIT":/protocol.git:ro -e CARGO_NET_GIT_FETCH_WITH_CLI=true \
-e CARGO_HOME=/src/.scratch/cargo -e RUSTUP_HOME=/src/.scratch/rustup \
-e CARGO_TARGET_DIR=/src/.scratch/target \
docker.gitea.com/runner-images:ubuntu-24.04 bash -c '
git -C / config --global url."file:///protocol.git".insteadOf \
ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git
apt-get update && apt-get install -y --no-install-recommends \
build-essential ca-certificates cmake curl git jq pkg-config python3 \
libasound2-dev libfontconfig1-dev libxkbcommon-dev libvpx-dev \
libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev xvfb xauth
curl --proto =https --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --profile minimal --default-toolchain none
. "$CARGO_HOME/env" && rustup toolchain install
xvfb-run -a bash -c "VOELIN_X11_TEST_DISPLAY=\$DISPLAY \
cargo test --workspace --locked --no-fail-fast"'
```
`--init` is required: `bash -c` runs its last command, `xvfb-run`, as the
container's process 1, and that never gets to start `cargo` (the command
hangs). The runner starts its steps with `docker exec` in a container whose
process 1 is something else, so CI itself is not affected.
The private VoelinProtocol dependency needs the deploy key
([below](#voelinprotocol-access)). The block reads it from a local bare clone
instead: `PROTOCOL_GIT` is mounted at `/protocol.git` and git is told to use
it in place of the SSH URL (with `CARGO_NET_GIT_FETCH_WITH_CLI=true`, as in CI,
so that cargo runs the `git` command), which leaves `Cargo.lock` as it is.
The `git config` is run with `-C /` because a git worktree's `.git` file points
outside the mount, and `git config` in `/src` then fails with `fatal: not a git
repository: (null)` (exit 128). To use the deploy key instead, set it up as
described below and leave out the `PROTOCOL_GIT` lines and the `git config`
command. What the container wrote under `.scratch/` belongs to root; remove it
from a container as well:
```sh
docker run --rm -v "$PWD/.scratch":/s alpine:3.20 rm -rf /s/target /s/cargo /s/rustup
```
What the image lacks, and what the tests do about it. A test that is about
the missing piece returns without testing it, in most cases after printing a
line that says it skipped and names the piece (the wording differs from test
to test), or is `#[ignore]`d with the reason, and passes; any other test does
not need the piece.
| A test cannot count on | What the tests do |
|---|---|
| Regular user (root writes anywhere and creates missing directories) | Nothing relies on a permission bit or a missing directory failing. A path that cannot be written is built from something that fails for root too: below a regular file (`ENOTDIR`) or naming a directory (`EISDIR`), as `an_unwritable_path_fails_at_once` of the recorder does. |
| Sound card (`/dev/snd`), PipeWire and WirePlumber daemons | `libpipewire` and ALSA are there to build against only. `tests/pipewire_apps.rs` needs `pipewire`, `wireplumber` and `dbus-daemon` and, without them, prints a skipped line that names them. The camera tests are `#[ignore]`d (a camera and PipeWire). |
| D-Bus session bus | `voelin-platform`'s portal proxy test runs itself again under `dbus-run-session` on a bus of its own and, where that cannot be run, prints `skipped, nothing was checked: dbus-run-session cannot be run`; the notification and capture-portal tests run only where no bus is configured, and check that talking to a missing service fails cleanly. |
| GPU, `/dev/dri`, VA-API, `/dev/udmabuf` | The VA-API and DMA-BUF tests print a skipped line that names what is missing: a usable `h264_vaapi`, `/dev/udmabuf` or VA-API surfaces to export. |
| FFmpeg libraries, `ffmpeg` and `ffprobe` | The FFmpeg tests of `voelin-media` and `voelin-core` print a skipped line that names what is missing (the libraries, `ffmpeg`, `ffprobe`). The studio tests that read a recording back with `ffprobe` write and check the file themselves and skip only the `ffprobe` check; the RTMP tests need all three and skip. |
| H.264 encoder (no FFmpeg, no GPU, no OpenH264 library: `VOELIN_OPENH264_LIB` is unset and the download test is `#[ignore]`d) | Tests that need an H.264 encoder print a skipped line that says no H.264 encoder is there. Tests of codec choice state what `preferred_codec` promises with whatever the machine can encode. VP8 and VP9 (libvpx) are built in, so their round trips run. |
| X11 or Wayland display | `xvfb-run` supplies one X11 display and the step hands it over as `VOELIN_X11_TEST_DISPLAY` to the X11 capture and hotkey tests. `VOELIN_WLROOTS_TEST_DISPLAY` is unset, so the wlroots capture test prints `skipped`. |
| Playwright and Chromium (the image has Node) | The browser interop tests print `skipped: set VOELIN_INTEROP=1 (needs node, Playwright and Chromium)`. |
| TeamSpeak dev servers | Without `VOELIN_LIVE=1` the live tests return at once (some print `skipped: set VOELIN_LIVE=1 with the dev servers running`); the gateway's live test is `#[ignore]`d (`needs a running tsgw and TeamSpeak server`). |
| DNS and internet while the tests run (the job needs the network for apt, rustup and crates before they start) | The tests use no DNS or internet; those that would are `#[ignore]`d with the reason: four resolver tests of `tsclientlib` (`needs DNS and the internet`) and the OpenH264 download test. |
`localhost` resolves to `::1` first in this image (it also has `127.0.0.1`).
The tests that reach a server of their own go to `127.0.0.1` by name, not
through `localhost`, so a machine where connections to `::1` hang (a
development machine with a VPN does that) changes nothing for them.
### VoelinProtocol access
The workspace depends on `voelin-identity` from the **private** repository
+206 -6
View File
@@ -3,8 +3,10 @@
Status: design (2026-10-20); slices 1, 2 and 3 are implemented (section 13
says how slice 1 differs from this text, sections 14 and 15 what its reviews
changed, section 16 what slice 2 built, found and corrected, section 17 what
slice 3 moved, changed and ran, and 17.7 the round after its review, which
brought the branch onto main `ad20979`); section 10 has the slices.
slice 3 moved, changed and ran, 17.7 the round after its review, which
brought the branch onto main `ad20979`, and 17.8 the round after the gate of the
merge; 17.6 has the complete edge list for the second half); section 10 has
the slices.
Design for the first half of plan step 7 (Phase 4): the engine consumes
`voelin_proto::link::Session`, `ServerLink` becomes an adapter over it, and
@@ -929,7 +931,7 @@ Nothing here blocks this half: each has a workaround above.
| H6 | Avatars and icons as attachments (`Image.attachment_id`, content-addressed cache) instead of channel-0 paths. |
| H7 | The UI on the replica (Phase 5): the old-model projection and F1-F10 go; `u16` client ids widen to `u32` participants. |
| H8 | Reconnect with backoff, resume tokens and persisted cursors move to `voelin-sdk` once it exists; the engine consumes the SDK. |
| H9 | Move `src/ts/` (with its live tests) to `voelin-gateway-ts` (features `basic`, `streams`), first behind a `ts` feature of `voelin-core`, then by git tag; the exit check of plan step 6, `cargo tree -p voelin-core -e normal \| grep -E 'tsclientlib\|tsproto'` empty, holds after H1-H3 and this. Two edges run from the engine into `src/ts/` and have to be cut first: `Backends::default` registers `ts::TsConnector` (the `ts` feature makes it optional), and `link/project.rs` and `link/session_link.rs` import `ts::ts_session::{entities::user_uid, ids}`, the id and uid rule that the projection undoes the synthetic ids with (it moves to the engine side, or into `voelin-model`'s replica conversion, which already has `uid_text`). |
| H9 | Move `src/ts/` (with its live tests) to `voelin-gateway-ts` (features `basic`, `streams`), first behind a `ts` feature of `voelin-core`, then by git tag; the exit check of plan step 6, `cargo tree -p voelin-core -e normal \| grep -E 'tsclientlib\|tsproto'` empty, holds after H1-H3, H5 and this (17.6 has the complete list of the edges between the engine and `src/ts/`, the stream split and the other crates that carry `tsclientlib`). The first two to cut run from the engine into `src/ts/`: `Backends::default` registers `ts::TsConnector` (the `ts` feature makes it optional), and `link/project.rs` and `link/session_link.rs` import `ts::ts_session::{entities::user_uid, ids}`, the id and uid rule that the projection undoes the synthetic ids with (it moves to the engine side, or into `voelin-model`'s replica conversion, which already has `uid_text`). |
### 11.3 Coordination
@@ -1634,9 +1636,112 @@ were fresh compose projects (`down -v`, `up -d`) for each smoke run.
### 17.6 Follow-ups
- **H9 gains two edges to cut** (11.2): `Backends::default` and the use of
`ts::ts_session::{entities::user_uid, ids}` in `link/project.rs` and
`link/session_link.rs`.
- **H9 starts from the complete edge list below.** The Opus gate of the merge
(2026-10-24) found that 11.2 names two edges and the tree has more. Each
line was checked with `rg` and `cargo tree` on the tree of the follow-up
round (`phase4/seam-followups`); file lines are given where the file did not
change in the round, items by name where it did.
1. **From the engine into `src/ts/`**: what has to be cut or moved before
`ts` can leave the crate.
| Where | What | Goes with |
|---|---|---|
| `link/backends.rs` | `use crate::ts::TsConnector`; `Backends::default` registers `TsConnector::new()`; `Backends::register_teamspeak(TsConnector)` is the only public way to register an in-process connector and goes through the crate-private `register_local(Arc<dyn LocalConnector>)` | H9: the `ts` feature makes `default` optional |
| `link/project.rs:20-21`, `link/session_link.rs:565, 973, 1328` | `ts::ts_session::entities::user_uid` and `ts::ts_session::ids::{self, FOREIGN_SYSTEM}`: the id and uid rule the projection undoes the synthetic ids with | H9: to the engine side, or into `voelin-model`'s replica conversion (`uid_text`) |
| `gateway.rs:98, 1209` | `ts::identity::{from_blob, to_blob}`: 98 is `login_identity` (the blob to the `tsclientlib::Identity` the gateway login is made of), 1209 is a test | H5: the gateway becomes a `Session` and takes the blob as a credential |
| `lib.rs:69` | `pub mod ts`: the public paths `voelin_core::ts::{identity, versions, TsConnector}` | H9: they move or are re-exported |
| outside the crate: `tools/voelinctl/src/{engine,identity,versions,client}.rs`, `crates/voelin-ui/src/{app,servers}.rs` and `settings_pages/bind.rs`, `crates/voelin-ui-vm/src/settings_pages/logic.rs`, `crates/voelin-core/tests/gateway.rs` | users of `voelin_core::ts::identity::*` and `ts::versions::*` (`to_blob`, `Found`, `import`, `import_new`, `discover`, `read`, `write_export`, `improve_level`, `LaunchImport`, `DEFAULT_NICKNAME`, `resolve`, `native_version`, `known_versions`, `client_metadata`) | H9: re-point to the new crate (`crates/voelin-ui*` belong to `phase5/ui-vm-2`) |
| docs: `lib.rs:8` (`ts::TsConnector`), `lib.rs:129` (`Command::ObserveGateway`: `ts::identity::to_blob`), `gateway.rs:103` (`to_blob`), `settings.rs:1138` (`import_new`); in `link/mod.rs` the module doc (`TsConnector`), `VoiceOptions::identity` (`to_blob`) and `VoiceOptions::client_version` (`ts::versions::resolve`) | intra-doc links into `ts`, which `cargo doc` with `-D warnings` resolves only while `ts` is in the crate | H9: reworded, or pointed at the new crate's docs |
A TeamSpeak connector in another crate has only
`Backends::register(Arc<dyn Connector>)`: `register_teamspeak` takes the
crate's own `TsConnector`, and `LocalConnector`, `LocalCtx`,
`LocalConnected` and `StreamPort` are crate-private. A plain `Connector`
is handed neither the `LocalCtx` (the event bus, `audio`, `stream_peer`)
nor a `StreamPort` (`Backends::connect` makes its `LocalConnected` with
`streams: None`), so its sessions have no TeamSpeak 6 streams. Streams
across the crate boundary need H2 first, or a public extension trait that
takes the place of `LocalConnector`.
*Test-only* edges, which move with the tests of each side:
`link/tests.rs` and `link/fake_link_tests.rs` (lines 30-31 of both) use
`ts::ts_session::LinkConnector` and `ts::{ConnectOptions, ServerLink}`;
the tests of `link/session_link.rs` use `ts_session::{backend_to_v1,
features_of}`; `link/tests.rs` uses the helpers
`ts::identity::{json_with_a_cut_key, assert_holds_no_piece_of}` and
`tests/session_fake.rs` builds a `tsclientlib::Identity` and runs
`Backends::default()` in one test (both from this round, with the gate's
minor).
2. **From `src/ts/` into engine-private items**: the reverse edges.
| Module of the engine | Items `src/ts/` uses |
|---|---|
| `crate::link` | `LinkCmd`, `LinkEvent`, `LinkCtx` (its `session`, `events`, `frames`, `settings`, `emit`, `done`), `Remote`, `BoxRead`, `BoxDuplex` (`ts/voice.rs`, `ts/ts_link.rs`, `ts/ts_session/driver.rs`); `LocalConnector`, `LocalCtx`, `LocalConnected`, `StreamPort`, `VERSION_PARAM`, `without_query` (`ts/ts_session/mod.rs`); `StreamEvent` (`driver.rs`) |
| `crate::stream` | `StreamCmd` (`voice.rs`, `driver.rs`), `StreamHandle`, `StreamInput` (`voice.rs`) |
| `crate::files` | `FileEntry`, `RequestId`, `TransferState`, and the functions `normalize_dir` and `join_path` (`voice.rs`, `driver.rs`) |
| `crate::offline` | `OfflineMessage`, `OfflineMessageInfo` (`voice.rs`, `driver.rs`) |
| the crate root | `Event`, `JoinFailure`, `BackendInfo`, `POKE_MESSAGE_MAX` |
| `crate::settings` | `SharedSettings`, through `LinkCtx.settings`, which `voice.rs` hands to the stream task |
| tests only | `crate::link::{Backends, VoiceOptions, connect_params}` (`ts_session/mod.rs`, `live_tests.rs`), `crate::link::media::TalkTracker` and `crate::link::project::{View, presence}` (`ts/book.rs`), `crate::settings::{SharedSettings, Settings}` and `crate::files::{Report, Sink}` (`ts/voice.rs`) |
Together with the first list this is a cycle: `voelin-core` would need
`voelin-gateway-ts` for `TsConnector` and the uid rule, and
`voelin-gateway-ts` needs `voelin-core` for every item above. So the "by
git tag" step of H9 needs **H1 and H2** (the TeamSpeak side speaks v1
through `Session`, which takes the place of `LinkCmd`, `LinkEvent`,
`LinkCtx`, `StreamPort` and the stream task's input) **or a shared
vocabulary crate** that holds the items above for both sides. Without
one of the two, only the first step, the `ts` feature of `voelin-core`,
is possible.
3. **What else keeps `tsclientlib` and `tsproto` in the tree.** The exit
check (`cargo tree -p voelin-core -e normal | grep -E 'tsclientlib|tsproto'`
empty) is not met by moving `src/ts/` alone:
- `voelin-core` itself: its four direct dependencies (`tsclientlib`,
`tsproto`, `tsproto-packets`, `tsproto-types`) leave with `src/ts/`,
but `gateway.rs` uses `tsclientlib::Identity` (`login_identity`,
`connect_watched`, `attempt`: H5) and `stream.rs` uses
`tsclientlib::ClientId` (item 4).
- Three more crates of `voelin-core`'s tree carry the dependency:
`voelin-store` (`store.rs` and `keystore.rs` take, read and check a
`tsclientlib::Identity`), `voelin-stream` (`proto.rs`, `session.rs`,
`discovery.rs`: `tsclientlib::{ClientId, InMessage, messages::c2s}` and
`tsproto_packets::packets::OutCommand`; H3 splits it) and
`voelin-gateway-proto` (`auth.rs`, `client.rs`:
`tsproto_types::crypto::EccKeyPrivP256`, the key of the gateway login;
H5). `cargo tree -p <crate> -e normal` shows it for each of the three.
- `voelin-query` and `voelin-observer` have none, so `query.rs` using
`voelin_query` is not an edge of the exit check; it goes with H5
because the query observer becomes a `Session` of a gateway daemon.
- So the exit check needs H1-H3, **H5**, a way for `voelin-store` to
handle a TeamSpeak identity without `tsclientlib`'s type, and H9.
4. **`stream.rs` must be split.** Stays with the engine: `StreamState`,
`WatchState`, `StreamFrame`, `StreamSink` and `LayerFormat` (public API),
`StreamCmd`, `OwnStreamEvent`, `kind_name`, `parse_kind` and
`parse_srtp_profiles` (`session.rs`), `media_codec` (`media.rs`) and the
re-exports of `stream_types` (`StreamInfo`, `StreamKind`, `StreamSetup`,
`ViewerInfo`, ...). Goes with the TeamSpeak 6 task: `StreamHandle`,
`StreamTask` and its helpers, `StreamInput`, the `StreamLookup` over the
gateway directory, and every use of `tsclientlib::ClientId` (the engine's
own ids are `u16`; `stream.rs` wraps them for `voelin-stream`).
5. **The engine API docs that link into `ts` move with it** (the last row of
the table of item 1): `VoiceOptions::identity` and
`Command::ObserveGateway` link `ts::identity::to_blob`,
`VoiceOptions::client_version` links `ts::versions::resolve`.
- **The same leak in `voelin-store`, not closed.** `Store::identity` and
`Store::identities` read the stored JSON of a TeamSpeak identity with `?`, so
an `Error::Json` whose text is the `serde_json` message, which quotes a key
that does not import, as the gate's minor did in the connector. The rows are
written from a `tsclientlib::Identity` (`add_identity`), so a damaged
database is the only way to such a row; the key store (`keystore.rs`) drops
the parse error for the same reason. `ts::identity::from_json` cannot be
used there (`voelin-core` depends on `voelin-store`); the fix is the same
classification in `voelin-store`, or `from_json` moved down.
- The bookmark tests of `link/connect.rs` that still sit in
`ts/ts_session/mod.rs` (17.2) belong next to it.
- `QueryLogin.allowlisted` goes with the query observer (H5), which becomes a
@@ -1720,3 +1825,98 @@ included.
The last bullet of 17.6 (documents that still name the old paths) is closed by
`76a884a`; the others stand.
### 17.8 The round after the gate (`phase4/seam-followups`)
The Opus gate of the merge (`c60acf9`) accepted it with one minor and notes for
H9. This round, on `phase4/seam-followups` from `c60acf9`, closes the minor,
writes the notes down (17.6) and deals with the five tests that failed on
their own on `main`. No history was rewritten. The `mao-*` agents were not
registered in the session, so a general-purpose agent played
`mao-implementer`, attempt 1.
| Commit | What |
|---|---|
| `a856f90` | The gate's minor. `ts::identity::from_json` is the classification `from_blob` had (malformed, cut short, not an identity, unreadable, with line and column, never the value), taking the JSON text; `from_blob` and `ts_session::inner_options` both use it. `inner_options` had put the `serde_json` error into the text, and `tsproto`'s key reader reports a key that does not import as `invalid_value(Unexpected::Str(key), ..)`, so the key reached `LinkEvent::Disconnected(Some(text))`, `Event::Error` and the status line. A credential that is not UTF-8 is "it is not text". Four tests, each with a key that lost its last two characters and none holding 8 characters in a row of the key: `identity::tests` (which also asserts that the reader's own message does quote it), `ts_session::tests` (`inner_options`), `link::tests` (the `Disconnected` text through `SessionLink` and the real connector) and `session_fake` (`ConnectVoice` through the engine with `Backends::default()`: the `Disconnected` state, the `Error` event and every event after it). The three connector-side ones fail with the `serde_json` text put back. |
| `563482d` | `VoiceOptions::nickname` and `server_password` have their docs; `Backends::set_account` says that no connector reads `ConnectParams.account` yet and that H4 moves the myTeamSpeak proof to it. |
| `96ff0e0` | The edge list of 17.6, and the H9 row of 11.2 pointing to it. |
| `9254e08` | `identity::tests::improve_level_keeps_the_key`. |
| `0d67dd7` | `voice_features::contacts_are_kept_in_the_database`. |
| `4be37e1` | `session::banner_tests::a_failing_banner_is_logged_once_with_its_address`, through `web::tests::info_lines`. |
| `e614a1c` | `discover::tests::without_records_the_gateway_itself_is_asked`. |
| `a90bb70` | `web::tests::pictures_go_through_the_proxy_named_for_each_hop`. |
| `c35bbb5` | `voelin-platform`'s `proxy::the_portal_names_the_proxy`. |
**The five flakes: all fixed, none recorded as known.** Two of the fixes are
rewrites of a test helper and a test, not one-line edits.
- `improve_level_keeps_the_key`: a fresh `Identity::create()` stops at the first
counter of level 8 or more and about one in 32 has 13 already, which
`improve_level` returns as it is. The test asks for three levels above what
its identity has. 8 failures in 300 runs of the single test before, 0 in 300
after.
- `contacts_are_kept_in_the_database`: dropping an `Engine` does not close the
history database. The engine task ends later, the history writer is joined
there, and closing the connection checkpoints the write-ahead log under an
exclusive lock with fsyncs; the second `History::open` waits for that lock
for the 5 s busy timeout only and fails with `DatabaseBusy` when a loaded
disk makes the close slower. A connection was still open (the `-wal` file
still there) in 23 of 24 instrumented runs, and 10 of those 24 (eight at a
time on a loaded machine) failed. The test now waits for the `-wal` file to
go (SQLite deletes it when the last connection closes) before it reopens.
With every fsync of the test process delayed by 6 s (`strace -f -e
inject=fsync,fdatasync:delay_enter=6000000`) the old test fails every time at
the reopen, and the new one passes.
- `a_failing_banner_is_logged_once_with_its_address` (`lines == []`):
`web::tests::info_lines` read the log with `tracing::subscriber::with_default`.
While that scoped subscriber is the only one alive, `tracing-core` registers
a callsite that another test's thread meets first against that thread's own
default (none) and the callsite stays disabled for every thread
(`callsite::Dispatchers::rebuilder`, `has_just_one`). Several tests of
`banner_tests` reach the same callsite through `image_finished`. The helper
now installs one recording subscriber as the global default the first time
and records into a buffer per thread. A new test (`info_lines_see_a_callsite_
another_thread_met_first`) fails with the old helper (`lines == []`, the
failure that was seen) and passes with the new one. The old helper failed 1 of
300 runs of `banner_tests`, the new one 0 of 600. The failure of the whole
suite did not occur in the twenty full runs below, so the evidence for this
fix is the mechanism, the new test and these rates.
- The two `localhost` tests fail where `localhost` resolves to `::1` only (the
servers of the tests listen on 127.0.0.1). The discovery test's `probing`
helper and the test SOCKS proxy dial `localhost` at 127.0.0.1; what the tests
check (the name the gateway is asked at, the name the proxy is given) is
unchanged.
- `the_portal_names_the_proxy` did not need `dbus-run-session` only: with a
session bus, on the desktop's or on a private one made by plain
`dbus-run-session`, it failed here three times out of three at "the portal
leaves the bus", because the bus can start the real `xdg-desktop-portal` by
name, which the first call after the stand-in has left does, and the real
one answers instead of the "missing for a minute" the test expects. The test
now runs itself again under `dbus-run-session` with a bus configuration of
its own, a session bus without service directories. Without
`dbus-run-session`, or when the bus does not come up, it prints "skipped,
nothing was checked" and the reason and passes. On the bus with the default
services the same test still fails (checked by hand).
**What ran.** The environment of 17.7, taken again: `nix shell` of `gcc cmake
gnumake pkg-config jq` and the `.dev` outputs of `alsa-lib openssl libvpx dav1d
pipewire fontconfig freetype libxkbcommon expat`, with `PKG_CONFIG_PATH` (the
`.dev` outputs), `LIBCLANG_PATH`, `BINDGEN_EXTRA_CLANG_ARGS` (`-isystem` the
`glibc.dev` headers: `libspa-sys` fails without) and, to run the binaries it
builds, `LD_LIBRARY_PATH` (the `.out` outputs of those: `libvpx.so.12`) set by
hand, and the 1.94 and nightly toolchains from their store paths in front of
`PATH`. The `dev rust-nightly` shell does not build here (`cargo-llvm-cov`).
With that, `cargo check --workspace --all-targets --locked` passes on 1.94, the
`voelin-ui`, `voelin-ui-vm`, `voelinctl`, `voelin-gateway` and `voelin-android`
targets included.
| Check | Result |
|---|---|
| `cargo fmt $(scripts/own-crates.sh) --check` | 1.94: clean at the head and at each of the nine commits, checked out detached one by one. `cargo fmt --all --check` as such is not clean at `c60acf9` on any toolchain: it includes the vendored `crates/proto`, which formats with upstream's nightly configuration, and the nightly `rustfmt` also reformats own files that 1.94's leaves alone (the CI runs the form above). |
| `cargo clippy -p voelin-core -p voelin-platform --all-targets --locked --no-deps -- -D warnings` | 1.94: clean at each of the nine commits, checked out detached one by one. |
| `cargo test -p voelin-core --locked --lib`, ten times in a row, no exclusions | Nightly: ten runs, each 252 passed, 2 ignored. 1.94: the same ten times. (The baseline of 17.5 and 17.7 had two failures in each run and needed `--skip`.) |
| `cargo test -p voelin-core --locked`, once | Both toolchains: green. Integration tests: `gateway` 9, `live` 6 and `stream_live` 3 (they skip without `VOELIN_LIVE`), `session_backends` 2, `session_fake` 20 passed and 2 ignored, `settings` 1, `voice_features` 3. |
| `cargo test -p voelin-platform --locked` | Both toolchains: 24 lib tests, `crash` 3, `proxy` 1 (on its own bus), `x11` 1 (skipped without a display), 2 doc tests. |
| `RUSTDOCFLAGS=-D warnings cargo doc --no-deps -p voelin-core --locked` | 1.94 and nightly: clean. |
| `Cargo.lock`, `THIRD_PARTY_NOTICES.md` | Unchanged: `git diff c60acf9 -- Cargo.lock Cargo.toml` is empty, so there was nothing to regenerate. |
| `scripts/it-smoke.sh ts3 ts6`, on `c60acf9` (before) and at the head (after) | The stack of `VoelinGateWay/dev/docker-compose.yml` as a compose project of its own (`voelin-seam-followups`), the state directory under the scratch directory. On a fresh stack each (`down -v`, `up -d` before each): both pass every per-server scenario of ts3 and ts6 (connect and tree, server and channel chat, voice tone, invisible presence, relay, gateway, history, pins and reactions, the engine's voice features, the TeamSpeak 6 streams), the TeamSpeak session module stage (12 passed, 2 ignored; 16.38 s before, 16.73 s after) and fail in the same place, the engine stage at `ts6_banners` (`live.rs:396`, 5 passed, 1 failed), the failure 17.5 and 17.7 record. Two more runs on the first stack, which was no longer fresh (before, then after), gave the same: the outputs have 100 lines each and differ only in ids, counters, tone ratios and the number of tests filtered out of the module stage (236 before, 240 after: this round's four unit tests). The very first run, on `c60acf9` on the first stack, stopped earlier, at the first gateway request of the admin identity of ts3 (`config_set` not answered, observe stayed `Connecting`); it did not repeat on the fresh stack at `c60acf9`, nor in any later run, and was not chased. |