Skip to content

fix: keep the refused upstream port reserved in messages tests - #517

Merged
haoshan98 merged 2 commits into
mainfrom
fix/messages-test
Nov 10, 2026
Merged

haoshan98 merged 2 commits into
mainfrom
fix/messages-test

Conversation

@maralbahari

@maralbahari maralbahari commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

messages_test failed on CI after #506 merged, in two tests at once:

  • messages_returns_anthropic_error_for_unreachable_upstream got 200 instead of 502.
  • messages_provider_tools_preserve_proxy_body_and_stream_events counted 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 answered 200, 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 502 path the tests check, and no other test can take the port while the socket is alive. The new refused_upstream() helper is shared by both tests.

health_test.rs (two tests) and agentic_process/tests.rs use 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 warnings and pre-commit passed.

🤖 Generated with Claude Code

@maralbahari maralbahari changed the title test: keep the refused upstream port reserved in messages tests fix: keep the refused upstream port reserved in messages tests Nov 10, 2026
@haoshan98
haoshan98 merged commit 6b42ed7 into main Nov 10, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants