Repository navigation
Retry LLM proxy test binds that lose their port - #7329
Merged
Merged
Conversation
The LLM proxy tests pick a port by binding and closing it, then New binds it again. A parallel test can take the port in between, which failed TestHandler_Returns502OnTokenError in CI with 'address already in use'. Create proxies through a helper that retries on another port when the bind finds the port taken. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7329 +/- ##
==========================================
- Coverage 82.27% 82.25% -0.02%
==========================================
Files 935 935
Lines 95159 95285 +126
==========================================
+ Hits 78288 78381 +93
- Misses 16866 16899 +33
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rdimitrov
approved these changes
Nov 26, 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
The LLM proxy tests pick a port with
freePort, which binds127.0.0.1:0, closes the listener and returns the port number.Newthen binds that port. Another test running in parallel can take the port between those two steps. That failedTestHandler_Returns502OnTokenErrorin CI withbind: address already in use(seen on #4844, where a re-run passed).newProxyOnFreePort. It builds the config on a fresh port, retries on another port (up to 5 attempts) whenNewfails withEADDRINUSE, and closes the listener on test cleanup.Newto succeed. Tests that expectNewto fail before binding still callNewdirectly.Type of change
Test plan
task test)task test-e2e)task lint-fix)Linting is left to CI because the local
golangci-lintcrashes on the Go 1.27 toolchain.Special notes for reviewers
This only changes test code;
Newis unchanged. The alternative is to letNewaccept an already-bound listener, which removes the race entirely but adds a constructor option used only by tests. Retrying keeps production code untouched. On Windows the bind error doesn't matchsyscall.EADDRINUSE, so a collision there still fails as before.🤖 Generated with Claude Code