Repository navigation
test(linux): cover the spawn-failure reply and the idle/busy read switch - #77
Merged
Merged
Conversation
…tch (#75) Three tests in src/attach/liveness_tests.rs: - a_call_thread_that_cannot_start_is_answered_with_an_error: forces the call-thread start to fail and asserts a JSON-RPC -32603 error with the request's id (number and string), no reply for a notification or non-JSON frame, and an in-flight count back at 0 (no busy-count leak). - a_call_queues_its_reply_before_it_stops_counting: applies the socket loop's rule (load the count, then drain) to 500 quick calls; once the count reads zero the reply must already be queued. - a_finished_call_is_answered_before_the_idle_read_timeout: fake runtime, idle read stretched to 5 s, no pings or keepalive; a `sleep 0.3` call must be answered in under 2 s. Refactor for injectability (no behaviour change): - spawn_call delegates to spawn_call_on(text, calls, start), where `start` runs the boxed call job; production passes thread::Builder::spawn. - DialTuning gains idle_read_poll (Default = IDLE_READ_POLL, 250 ms), used by serve_socket in place of the constant. Verification: - Raspberry Pi (Debian 13 aarch64): cargo test --release -> 36 passed, 0 failed (33 before + 3 new). - Fail-without-fix, same host, scratch copy only (not committed): - read switch disabled (`if false && busy`): idle-timeout test FAILED (reply took ~5 s). - InFlight dropped before the reply is sent: queue-order test FAILED 5/5 runs, idle-timeout test FAILED. - spawn-failure reply not sent: spawn-failure test FAILED. - restored: 36 passed. - M4 Mac mini: cargo fmt --check OK; cargo clippy --release [--all-targets] -- -D warnings clean.
Contributor
Author
|
Review: opus5 and sol both LGTM at 40b8b81. CI green (all 7 checks pass), mergeable, merge state CLEAN. LOW follow-ups (non-blocking):
|
Merged
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.
Fixes #75
Adds the two tests left as LOW follow-ups on #72, in
poc/reverse-attach-linux/src/attach/liveness_tests.rs.Tests
a_call_thread_that_cannot_start_is_answered_with_an_error: forces the call-thread start to fail. A request gets a JSON-RPC-32603error with its own id (number and string ids). A notification or a non-JSON frame gets no reply. The in-flight count returns to 0 in every case, so a failed start does not leak the busy count.a_call_queues_its_reply_before_it_stops_counting: applies the socket loop's rule (read the in-flight count, then drain the outbox) to 500 quick calls. Once the count reads zero, the reply must already be queued. This guards the send-before-decrement ordering.a_finished_call_is_answered_before_the_idle_read_timeout: fake runtime with no pings and no client keepalive, and the idle read stretched to 5 s. Asleep 0.3call must be answered in under 2 s, so a reply that waits for the idle read timeout fails the test.Refactor for injectability (no behaviour change)
spawn_callnow delegates tospawn_call_on(text, calls, start).startreceives the boxed call job; production passesthread::Builder::spawn, and the test passes a closure that returns an error.DialTuninggainsidle_read_poll.DefaultkeepsIDLE_READ_POLL(250 ms), andserve_socketreads it from the tuning instead of the constant.Verification
cargo test --releasegave 36 passed, 0 failed (33 existing + 3 new).if false && busy): the idle-timeout test failed (the reply took about 5 s).InFlightdropped before the reply is sent: the queue-order test failed in 5 of 5 runs, and the idle-timeout test failed too.cargo fmt --checkpassed, andcargo clippy --release [--all-targets] -- -D warningswas clean.