Test: Bind to port 0 for automatic port selection and report that to the fixture#134
Merged
Conversation
c4a1525 to
e08a325
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses flaky Python integration tests caused by occasionally selecting the same “random free port” and then timing out while the Opsqueue server retries binding. It switches tests to bind Opsqueue to port 0 (letting the OS choose an available port) and introduces a mechanism for reporting the actual bound port back to the test fixture.
Changes:
- Add a CLI/config option to pass a pipe file descriptor into Opsqueue and write the final bound port to it after binding.
- Update server startup to report the bound port when available.
- Update the Python test fixture to start Opsqueue with
--port 0and read the bound port from the pipe.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| opsqueue/src/server.rs | Writes the bound port to a provided pipe after binding, for port 0 use cases. |
| opsqueue/src/config.rs | Adds a new CLI/config field and parser for passing a pipe FD for bound-port reporting. |
| libs/opsqueue_python/tests/conftest.py | Uses --port 0 and reads the assigned port from a pipe instead of picking a random port. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jerbaroo
reviewed
Jul 16, 2026
jerbaroo
approved these changes
Jul 16, 2026
Contributor
|
This likely fixes #20 |
Contributor
Author
|
@OpsBotPrime merge! |
…eport that to the fixture Approved-by: ReinierMaas Priority: Normal Auto-deploy: false
Contributor
|
Rebased as 73d79d4, waiting for CI … |
Contributor
|
CI job 🟡 started. |
feb3fde to
73d79d4
Compare
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.
Closes: #20
I discovered why the tests sometimes flake and time out. The test suite by accident selected the same random port from the range and then Opsqueue couldn't bind to that port. Due to the prolonged retry behaviour for binding to the port this caused
pytest-timeoutto trigger instead of delivering us a nice error message.