Repository navigation
Keep the refused-connection test from racing other tests - #187
Merged
Merged
Conversation
a_connection_error_is_retried bound a listener on an ephemeral port, dropped it and expected every connection to that port to be refused. Between the drop and the client's attempts, another test running in parallel (mockito servers bind ephemeral ports) could receive the same port, so the client got an answer and the retry count was not 2. The test now keeps the listener bound for its whole duration, so the port cannot be reused. The listener never accepts, so each attempt times out (short client timeout), which the client retries the same way as a refused connection. A reset after accept would not be retried, as it is not a connect error, so accepting and closing was not used. The assertions are unchanged: Error::Transport and exactly 2 retries. Closes #183 Signed-off-by: d0ubl3g <48954024+d0ubl3g@users.noreply.github.com>
This was referenced Oct 15, 2026
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.
Cause
a_connection_error_is_retriedbound an ephemeral port, dropped the listener and expected connections to be refused. A parallel test (mockito binds ephemeral ports) could take that port in between, so the client got an answer and the retry count was not 2.Fix
The listener stays bound for the whole test, so the port cannot be reused. It never accepts: each attempt times out (client timeout 200 ms), which the client retries like a connection error. Accept-and-close was not used because a reset after accept is not
is_connectand would not be retried. Assertions are unchanged (Error::Transport, exactly 2 retries). The other bound listener in the file is kept alive until its thread is joined, so it needed no change.Checks
cargo test -q -p hodeishield-api --test api50 times in a loop: 0 failures.cargo fmt --all -- --check,cargo clippy --workspace --all-targets --locked -- -D warningsandcargo test --workspace --lockedpass.Closes #183