Repository navigation
fix: keep the refused upstream port reserved in messages tests - #517
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: maral <[email protected]>
maralbahari
requested review from
bbrowning,
franciscojavierarceo,
haoshan98,
jiahuei,
leseb,
noobHappylife,
qandrew and
tjtanaa
as code owners
November 10, 2026 11:30
haoshan98
approved these changes
Nov 10, 2026
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.
Summary
messages_testfailed on CI after #506 merged, in two tests at once:messages_returns_anthropic_error_for_unreachable_upstreamgot200instead of502.messages_provider_tools_preserve_proxy_body_and_stream_eventscounted 2 upstream requests instead of 1.Both come from one flaky setup, not from #506. The two "unreachable upstream" tests bound
127.0.0.1:0, read the address, and dropped the listener to free the port. Tests in the file run in parallel, so the OS could hand that port to another test's mock upstream. The "unreachable" request then reached that mock: it answered200, and the other test saw an extra request.The tests now keep the port reserved for their whole run with a socket that is bound but never listens. Connections to it are refused, which is the
502path the tests check, and no other test can take the port while the socket is alive. The newrefused_upstream()helper is shared by both tests.health_test.rs(two tests) andagentic_process/tests.rsuse the same drop-the-listener pattern and could flake the same way. This PR leaves them unchanged to stay a quick fix.Test Plan
cargo test -p agentic-server --test messages_test: 16 passed, and 20 consecutive runs passed with no failure.cargo clippy -p agentic-server --tests -- -D warningsand pre-commit passed.🤖 Generated with Claude Code