Repository navigation
test(rpc,graphql,serve): bind port 0 and read the bound address, ending the port race - #76
Merged
Merged
Conversation
…ng the port race 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. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JMTyE9inRv7Knv6jkmgDZs
|
Warning Review limit reachedYou'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 3 minutes. View limit details
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. Comment |
CryptoJones
added a commit
that referenced
this pull request
Oct 24, 2026
…slot (#77) connection_cap_refuses_the_surplus_connection still failed on main after #76. The port race was gone; this failure was a second race inside the test. The readiness client's slot is freed asynchronously on the server, so the raw "hog" connection could arrive while that slot was still counted. The server then refused the hog itself, and the "surplus" client got the free slot and succeeded. The test now checks that the hog really holds the slot before it tries the surplus client. A refused hog reads EOF; a hog holding the slot reads nothing, because the server is waiting for its handshake. The test reconnects until the hog holds the slot. This replaces the fixed 500 ms sleep. Claude-Session: https://claude.ai/code/session_01JMTyE9inRv7Knv6jkmgDZs Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Cause
The
scylla-rpc,scylla-graphqlandscylla-serveintegration tests picked a "free" port by binding127.0.0.1:0, reading the port, and dropping the listener. Then they started the server on that port. Between the drop and the server's bind, a parallel test's server could take the same port, and the test would end up talking to the wrong server. That is howscylla-rpc/tests/remote.rsconnection_cap_refuses_the_surplus_connectionfailed on main: it reached an uncapped server from another test and got success where it expected a refusal.Fix
This is the same fix #74 made for
scylla-http: start the server on port 0, so the OS hands it a port nothing else holds, and read the address it actually bound from its startup line.scylla-rpc-servealready printedlistener.local_addr(), so the binary is unchanged. A newtests/common/mod.rsspawn_server(envs)starts it on127.0.0.1:0and parses the address from the stderr startup line. It keeps draining stderr in a thread and returns(Server, addr).remote.rs,conformance.rsandtls.rsnow use it. The same env vars are still passed: the token,SCYLLA_RPC_MAX_CONN,SCYLLA_RPC_HANDSHAKE_SEC, and the TLS cert/key paths.server.server_addr().to_ip()(the bound address) in place of the requested one. The message wording is unchanged. A matchingtests/commonhelper is used byapi.rs(which still passesSCYLLA_GRAPHQL_TOKEN) and byconformance.rs.listener.local_addr()'s port in place of the requested one. Wording is unchanged, and the line still goes to stdout. Thetests/commonhelper passes port0, reads the address from stdout, andserve.rs'sget/wait_readynow take that address.Every per-file
free_port()and duplicatedServerguard is deleted. Test semantics are unchanged.Ran
cargo fmt --allcargo clippy --workspace --all-targets -- -D warnings: cleancargo test --workspace --locked: all passcargo test -p scylla-rpc -p scylla-graphql -p scylla-serve --locked, 4 runs in a row: all passProudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/
🤖 Generated with Claude Code
https://claude.ai/code/session_01JMTyE9inRv7Knv6jkmgDZs