Skip to content

Test: Bind to port 0 for automatic port selection and report that to the fixture#134

Merged
OpsBotPrime merged 2 commits into
masterfrom
reinier/test-report-port
Jul 16, 2026
Merged

Test: Bind to port 0 for automatic port selection and report that to the fixture#134
OpsBotPrime merged 2 commits into
masterfrom
reinier/test-report-port

Conversation

@ReinierMaas

@ReinierMaas ReinierMaas commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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-timeout to trigger instead of delivering us a nice error message.

@ReinierMaas ReinierMaas self-assigned this Jul 16, 2026
@ReinierMaas ReinierMaas force-pushed the reinier/test-report-port branch 2 times, most recently from c4a1525 to e08a325 Compare July 16, 2026 10:09
@ReinierMaas ReinierMaas changed the base branch from reinier/rust-edition-2024-resolver-3 to master July 16, 2026 10:09
@ReinierMaas ReinierMaas requested review from Copilot and jerbaroo and removed request for jerbaroo July 16, 2026 10:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 0 and 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.

Comment thread opsqueue/src/config.rs Outdated
Comment thread opsqueue/src/server.rs
Comment thread libs/opsqueue_python/tests/conftest.py
Comment thread libs/opsqueue_python/tests/conftest.py Outdated
Comment thread libs/opsqueue_python/tests/conftest.py Outdated
Comment thread libs/opsqueue_python/tests/conftest.py
@ReinierMaas ReinierMaas requested a review from jerbaroo July 16, 2026 11:36
Comment thread libs/opsqueue_python/tests/conftest.py
@jerbaroo

Copy link
Copy Markdown
Contributor

This likely fixes #20

@ReinierMaas

Copy link
Copy Markdown
Contributor Author

@OpsBotPrime merge!

ReinierMaas and others added 2 commits July 16, 2026 15:34
…eport that to the fixture

Approved-by: ReinierMaas
Priority: Normal
Auto-deploy: false
@OpsBotPrime

Copy link
Copy Markdown
Contributor

Rebased as 73d79d4, waiting for CI …

@OpsBotPrime

Copy link
Copy Markdown
Contributor

CI job 🟡 started.

@OpsBotPrime OpsBotPrime force-pushed the reinier/test-report-port branch from feb3fde to 73d79d4 Compare July 16, 2026 13:40
@OpsBotPrime OpsBotPrime merged commit 73d79d4 into master Jul 16, 2026
0 of 7 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.

CI keeps failing due to timeout

4 participants