Skip to content

Data streams v2 (1/5): conformance test harness - #329

Draft
1egoman wants to merge 2 commits into
mainfrom
ds/1-test-harness
Draft

1egoman wants to merge 2 commits into
mainfrom
ds/1-test-harness

Conversation

@1egoman

@1egoman 1egoman commented Nov 30, 2026 •

Copy link
Copy Markdown

Part 1 of 5 of the data streams v2 stack. Merge in order; each part is mergeable on its own.

  1. Data streams v2 (1/5): conformance test harness #329: Conformance test harness 👈 this PR
  2. Data streams v2 (2/5): read incoming data streams through FFI readers #330: Read incoming data streams through FFI readers (fixes receiving from other SDKs)
  3. Data streams v2 (3/5): add sendText / sendBytes / sendFile #331: Add sendText / sendBytes / sendFile
  4. Data streams v2 (4/5): add ByteStreamReader::writeToFile and a receive size limit #332: Add ByteStreamReader::writeToFile and a receive size limit
  5. Data streams v2 (5/5): move writers to FFI writer handles; add streamText / streamBytes #333: Move writers to FFI writer handles; add streamText / streamBytes

This stack replaces #321, #322 and #325 (same code, reordered so each step stands on its own).

Adds the helpers for end-to-end data stream tests ported from the Rust livekit-data-stream crate, plus the 5 receive tests that already pass on main. There's no SDK change. The rest of the stack adds the remaining ported tests next to the code that makes them pass.

Helpers (src/tests/common/data_stream_test_utils.h)

  • FfiPeer drives the other participant through the raw FFI, so it sends exactly what Python, Unity and the other FFI-based SDKs send:
    • its one-shot sends and writers go through the Rust outgoing manager (data streams v2: inline and compressed streams);
    • its raw header / chunk / trailer requests send hand-built v1 packets.
  • RawPacketSniffer records the raw stream packets a room receives. The raw header event carries neither inline_content nor compression, so:
    • "inline" means a header arrived with no chunk or trailer packets;
    • "compressed" means the chunk bytes differ from the payload and are smaller.
  • TextStreamCollector / ByteStreamCollector receive through the public C++ API and record content, info and errors.
  • The helpers use only API that exists on main, so the receive tests in part 2 build against both the old and new receive paths.

Also:

  • scripts/set-test-tokens.sh now mints an optional LIVEKIT_TOKEN_C (cpp-test-c) for tests that need a third participant. Tests that need it skip without it. CI already sources the script.
  • RoomTestAccess::roomHandleId is added.

Tests

test_data_stream_conformance_receive_v1.cpp starts with the 5 v1 receive tests that pass on main:

  • v1 text and byte round trips;
  • trailer attributes;
  • empty chunks;
  • a remote writer's trailer attributes.

The other 12 v1 tests fail on main and land in part 2 with the fix.

Verification (local, macOS arm64, livekit-server --dev)

  • Unit tests: 364/364.
  • Full integration suite: 75 pass, 3 fail (see below), 1 skip.
  • Without the fix: the 12 v1 receive tests left out of this PR fail on this branch, which is main plus tests.
  • Every commit builds and passes the unit tests.
  • Formatting: clang-format is clean on all changed files. Docs build OK. The release symbol leak check is OK.
  • The 3 failing integration tests are the DataTrackE2ETest schema tests (DefineAndGetSchema, DefineAndGetCustomSchemaEncoding, DefineDuplicateSchemaFails). They fail on main on this machine too, and the 1 skip is the token-server test.
  • Windows and Linux are covered only by CI.

🤖 Generated with Claude Code

1egoman and others added 2 commits November 30, 2026 14:47
Shared helpers for porting the Rust livekit-data-stream crate's tests to
end-to-end C++ tests:

- FfiPeer drives a room's participant through the raw FFI, so it sends
  exactly what another FFI-based SDK sends: one-shot sends and stream
  writers go through the Rust outgoing manager (data streams v2), and raw
  header/chunk/trailer requests send hand-built v1 packets.
- RawPacketSniffer records the raw stream packets a room receives.
- Text/ByteStreamCollector receive through the public C++ API and record
  content, info and errors.

The harness only uses API that predates the FFI reader/writer port, so
tests built on it compile before and after that port.

Also mint an optional LIVEKIT_TOKEN_C (cpp-test-c) for tests that need a
third participant, and add RoomTestAccess::roomHandleId.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ports the incoming-manager tests of the Rust livekit-data-stream crate
that the current C++ receive path already handles: v1 text and byte
round trips, trailer attribute merging, empty chunks, and a remote text
writer's trailer attributes.

The other v1 tests (duplicate chunks, length and gap errors, close
reasons, orphan packets, disconnects) fail on main and land with the
receive-path fix that makes them pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

⚠️ Memory checks need attention.

CI run · Commit e440a87

Memory tester results

Iterations: 100
Warmup: 20
Blocking limits: RSS growth ≤ 24 MiB; thread growth ≤ 10.
Advisory limits: RSS growth ≤ 8 MiB; thread growth ≤ 0.

Scenario RSS 0→20 RSS 20→100 Threads 0→20 Threads 20→100 Status
audio-track +17.32 MiB +0.15 MiB +7 0 ✅ PASS
video-track +18.23 MiB +0.16 MiB +7 0 ✅ PASS
data-track +13.11 MiB +0.09 MiB +1 0 ✅ PASS
room-reuse +13.05 MiB +0.09 MiB +1 0 ✅ PASS
room-client-leave +13.09 MiB +0.16 MiB +1 0 ✅ PASS
room-server-delete +15.62 MiB -0.20 MiB +1 0 ✅ PASS
capture-clock +119.29 MiB +0.62 MiB +8 0 ✅ PASS
capture-pattern +120.70 MiB -5.67 MiB +7 +1 ⚠️ ADVISORY
capture-gstreamer +35.28 MiB +0.32 MiB +9 0 ✅ PASS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant