Wrap SimulateScenario to test server-initiated reconnect/leave paths#197
Draft
alan-george-lk wants to merge 3 commits into
Draft
Wrap SimulateScenario to test server-initiated reconnect/leave paths#197alan-george-lk wants to merge 3 commits into
alan-george-lk wants to merge 3 commits into
Conversation
…coverage Maps all client-initiated (disconnect(), destructor, shutdown, signals) and server-initiated (kDisconnected, kEos, reconnect, FFI panic) connection paths, their interactions, and the current unit/integration test coverage for each, including identified gaps. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… paths Adds the Rust SimulateScenario FFI hook to the lifecycle analysis: enum mapping, its status (supported by the core but unwrapped in C++), and how it complements a fake event injector for closing the server-initiated coverage gaps (S1/S3). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds Room::simulateScenario(SimulateScenario) over a new FfiClient::simulateScenarioAsync, a public SimulateScenario enum, and the proto mapping — mirroring the disconnect() async pattern. This surfaces the Rust core's chaos/reconnect hook so tests can drive the previously zero-coverage server-initiated paths in-band, without server-admin calls. Tests: - unit: simulateScenario on a disconnected room throws (no server needed) - integration: SignalReconnect and FullReconnect drive onReconnecting/ onReconnected; ServerLeave drives a server-initiated onDisconnected Updates docs/connection-lifecycle.md coverage matrix accordingly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
While mapping every connect/disconnect path in the SDK, the one glaring coverage gap was the server-initiated paths —
onReconnecting/onReconnectedand server-drivenonDisconnectedhad zero tests, because nothing on the client could drive them without a live server plus out-of-band server-admin calls (delete room / remove participant).The Rust core already exposes a chaos/E2E hook for exactly this —
SimulateScenario— at the FFI boundary (SimulateScenarioRequest→ asyncSimulateScenarioCallback), but the C++ layer never surfaced it. This PR wraps it and uses it to close the reconnect coverage gap, and adds a written analysis of all connect/disconnect paths.What changed
New
SimulateScenarioAPI (mirrors the existingdisconnect()async pattern layer-for-layer):SimulateScenariopublic enum inroom_event_types.h(9 variants:SignalReconnect,NodeFailure,ServerLeave,Migration,ForceTcp/Tls,FullReconnect,DisconnectSignalOnResume,Speaker), documented as a testing/chaos hooktoProto(SimulateScenario)inroom_proto_converter.cppFfiClient::simulateScenarioAsync(room_handle, scenario)+ thekSimulateScenariocase inExtractAsyncIdRoom::simulateScenario(SimulateScenario)— grabs the handle under lock, throws if not connected, blocks on the FFI callback, returns whether it was accepted (same deadlock caveat asdisconnect())Tests:
SimulateScenarioOnDisconnectedRoomThrows(no server needed — verifies the not-connected guard)test_room_reconnect.cpp):SignalReconnectResumesSessionandFullReconnectReestablishesSessionassertonReconnecting→onReconnected;ServerLeaveDisconnectsasserts a server-initiatedonDisconnectedDocs:
docs/connection-lifecycle.md— full matrix of client- and server-initiated connect/disconnect paths, their interactions, and per-path test coverage, updated to reflect the new coverage.Reviewer notes
-fsyntax-only) against the real generated protobuf headers from a localbuild-debugtree using that build's exact flags — all pass, confirming the proto symbol names match the pinned submodule. A full build + integration run against a live server (LIVEKIT_URL/LIVEKIT_TOKEN_A) is still needed to confirm runtime behavior.ServerLeavesemantics (disconnect vs. reconnect) were inferred from the FFI proto comments, not observed — worth confirming when the integration suite runs.simulateScenariois exposed on the publicRoomAPI (matching rust-sdks and client-sdk-js), documented as testing/chaos-only. Happy to move it behind a test-only seam (e.g. gated onLIVEKIT_TEST_ACCESS) if preferred.src/room_event_converter.cppappears to be dead code (not in CMake, includes a nonexistent header, stubtoDisconnectReasonreturningUnknown) — left out of this PR; flagged for a follow-up.🤖 Generated with Claude Code