Repository navigation
test(sdk): reproduce client lifecycle bugs - #4344
Conversation
|
Thanks for the PR. It is labeled Slash commands (own line, regular comment) move it around the queue:
See CONTRIBUTING.md for details. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4344 +/- ##
=============================================
- Coverage 87.84% 54.59% -33.26%
Complexity 1577 1577
=============================================
Files 1290 1287 -3
Lines 228835 182436 -46399
Branches 192195 145796 -46399
=============================================
- Hits 201015 99595 -101420
- Misses 23092 78209 +55117
+ Partials 4728 4632 -96
🚀 New features to boost your workflow:
|
|
|
|
/skill team-review-slim |
There was a problem hiding this comment.
Summary: Review of a test-only change that adds five #[ignore]d SDK lifecycle tests for #4287: WebSocket connect after shutdown, disconnect after shutdown, and the heartbeat and request paths that undo an explicit disconnect. The heartbeat test cannot fail on the current SDK, because get_me() answers from the local auth state while the heartbeat's redial waits out its cooldown, and CI compiles these tests but never runs them, so every finding here comes from reading the checkout.
Counts: critical 0, warning 1, nit 1, simplification 1
This review was generated by Claude Code 2.1.284 on deepseek-flash[1m]. Review the output before you act on it.
|
/ready |
|
/request-review @hubcio |
hubcio
left a comment
There was a problem hiding this comment.
nit: Client::shutdown at core/common/src/traits/client.rs:54 has only a plain // comment, and neither trait method states the lifecycle contract these tests pin. the fix PR is a good place to document it on the trait.
Agreed, I will document the lifecycle contract on the |
|
/ready |
9a0be2c to
2f26941
Compare
Which issue does this PR address?
Relates to #4287 (tests for problems 1 to 4)
Rationale
The Rust SDK does not keep the lifecycle contract of its clients. A client that is shut down can connect again, and an explicit
disconnect()does not hold until the nextconnect(). As agreed on #4287 and on Discord, the first step is to prove these bugs with failing tests. The#[ignore]reasons keep a trace in the code that the lifecycle is broken until the fixes land.What changed?
No test covered what happens after
shutdown()or after an explicitdisconnect()with auto-login credentials.core/integration/tests/sdk/client_lifecycle.rsnow pins the expected behavior in four tests (10 cases), all marked#[ignore]because they fail on the current SDK:disconnect(), on TCP, WebSocket and QUIC.disconnect(),ping()and thenget_stats()must fail withNotConnectedon the SDK side at once, without a reconnect, on TCP, WebSocket and QUIC. One test sends both requests, so it also catches a fix that stops only the first request.shutdown(),disconnect()must keep the client shut down, on TCP, WebSocket and QUIC.The auto-login clients come from connection strings with a zero reconnect cooldown, so no reconnect hides behind a pause. Each ignore reason says how to run the test.
The heartbeat test also reproduces problem 8 on QUIC. A heartbeat redial blocks
disconnect()inendpoint.wait_idle(), and the call never returns. The test boundsdisconnect()to 5 s, so this case fails instead of hanging. The hang depends on timing: the redial must land inside the drain of the old connection. When it misses, the QUIC case fails on the heartbeat assertion instead, as TCP and WebSocket do.Each test carries the suggested fix in a TODO. A fix PR applies the TODO and removes the
#[ignore]of the tests that it fixes. This PR does not cover problems 5 to 7, because they are races that need fault injection to reproduce reliably.Local Execution
I used Zed in devcontainer mode. The build and the tests ran in the devcontainer, and
prekran on macOS.Passed:
cargo fmt --allandcargo clippy -p integration --all-features --all-targets -- -D warnings.Passed: a normal run ignores the 10 cases, so CI stays green:
Passed: with
--ignored, the 10 cases fail, each on its own assertion, with the value it got:Passed: the heartbeat test fails on all three transports in 3 out of 3 runs.
Passed: pre-commit hooks with
SKIP=web-lint prek run --all-files. I skippedweb-lintbecause this PR does not changeweb/.AI Usage