Skip to content

test(http): bind port 0 and read the bound address, ending the port race - #74

Merged
CryptoJones merged 1 commit into
mainfrom
fix/http-test-port-race
Oct 24, 2026
Merged

CryptoJones merged 1 commit into
mainfrom
fix/http-test-port-race

Conversation

@CryptoJones

Copy link
Copy Markdown
Owner

Fixes the flaky http_gateway_token_gates_access failure seen on #73.

Cause: each scylla-http test picked a free port with TcpListener::bind("127.0.0.1:0"), released it, then passed it to the gateway. In that gap a parallel test's gateway could take the same port. The token test then reached an ungated gateway and got 200 where it expected 401. This was a test race, not an auth bug.

Fix:

  • scylla-http announces the address it actually bound (server.server_addr()), so 127.0.0.1:0 works and the startup line shows the real port.
  • A shared tests/common helper starts the gateway on port 0, reads that line, and keeps stderr drained. api.rs, conformance.rs and tls.rs use it.

Clippy (-D warnings) is clean, and cargo test -p scylla-http passed three runs in a row on ronin28.

The same free-port pattern is in scylla-graphql, scylla-rpc and scylla-serve tests. This PR doesn't change those.

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

🤖 Generated with Claude Code

https://claude.ai/code/session_01JMTyE9inRv7Knv6jkmgDZs

The scylla-http tests picked a free port, released it, then passed it to the
gateway. A parallel test's gateway could take the port first and answer in its
place: http_gateway_token_gates_access then saw 200 from an ungated gateway
where it expected 401.

scylla-http now announces the address it actually bound, so 127.0.0.1:0 works.
A shared tests/common helper starts the gateway on port 0 and reads that line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JMTyE9inRv7Knv6jkmgDZs
@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 5a37f4cb-32c8-4752-9be6-ae7904d605c0
Commits

Reviewing files that changed from the base of the PR and between bc6afdc and 1be59cb.

Files selected for processing: 5
  • crates/scylla-http/src/main.rs
  • crates/scylla-http/tests/api.rs
  • crates/scylla-http/tests/common/mod.rs
  • crates/scylla-http/tests/conformance.rs
  • crates/scylla-http/tests/tls.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CryptoJones
CryptoJones merged commit d07ca7e into main Oct 24, 2026
3 checks passed
@CryptoJones
CryptoJones deleted the fix/http-test-port-race branch October 24, 2026 18:53
CryptoJones added a commit that referenced this pull request Oct 24, 2026
…ng the port race (#76)

The scylla-rpc, scylla-graphql and scylla-serve tests picked a free port,
released it, then passed it to the server. A parallel test's server could take
the port first and answer in its place: connection_cap_refuses_the_surplus_connection
then reached an uncapped server and got success where it expected a refusal.

scylla-graphql and scylla-serve now announce the address they actually bound,
so port 0 works (scylla-rpc-serve already printed listener.local_addr()). Each
crate gets a shared tests/common helper that starts the server on port 0 and
reads the address from its startup line, the same way #74 fixed scylla-http.


Claude-Session: https://claude.ai/code/session_01JMTyE9inRv7Knv6jkmgDZs

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant