Skip to content

test(e2e): run the PortReservation child-bind tests off Linux - #2795

Merged
thiras merged 2 commits into
mainfrom
claude/2787-port-tests-non-linux
Oct 31, 2026
Merged

thiras merged 2 commits into
mainfrom
claude/2787-port-tests-non-linux

Conversation

@yigitdot

@yigitdot yigitdot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2787: items 1, 2 and 3b. 3a stays open.

1. PortReservation is tested off Linux. child_binds_a_reservation and child_rebinds_a_reservation_after_a_restart (formerly child_binds_a_held_reservation and held_reservation_survives_a_child_restart) were Linux-only. They now run off Linux too. Off Linux, PortReservation::tcp() releases its socket when it is made (ports.rs:75). On macOS that release is required, because a held socket blocks the child's SO_REUSEADDR bind. Before, changing that line to hold the socket passed every test and broke every macOS anvil-e2e journey. The ports module doc and the PortReservation doc now say that only Linux holds a reserved TCP port. held_reservation_is_never_an_ephemeral_bind and reservation_refuses_a_plain_bind stay Linux-only, because they check the Linux hold.

2. ephemeral_low() is checked against the kernel. udp_bind_to_port_zero_never_lands_below_ephemeral_low makes 1,000 UDP bind(127.0.0.1:0) calls and fails if any port is below ephemeral_low(). That is the premise UdpPortClaim rests on. Off Linux, ephemeral_low() is a fixed 49152. On a host whose range starts 100 ports lower, a run lands below it about six times. On Linux the test checks the /proc read. UDP only, because the premise is about UDP and macOS hands out TCP ports in sequence.

3b. The imports are trimmed. use super::* already brings in Ipv4Addr, SocketAddr and the socket2 types, so the header is use std::net::{TcpListener, UdpSocket}; with no cfg gates. Only EPHEMERAL_PICKS stays Linux-only.

Not in this PR. 3a (the UDP-exhaustion and /proc read-failure error paths) stays open on #2787. 3c is settled without a macOS CI job: the macOS cargo-clippy pre-commit hook guards this file.

Verified on macOS (aarch64-apple-darwin):

  • cargo nextest run -p decdn-e2e -E 'binary(decdn_e2e)': 52/52 pass.
  • Mutation check: with ports.rs:75 changed to _socket: Some(socket), both child-bind tests fail with EADDRINUSE (errno 48). With the change reverted, they pass.
  • env CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets and cargo fmt -- --check pass, and both commits ran every pre-commit hook.
  • A review found no flakiness: 3,600 parallel runs of the three tests on macOS, 0 failures.
  • Linux has not been run locally. No Linux target is installed here, so the ubuntu clippy and test CI jobs cover it.

🤖 Generated with Claude Code

child_binds_a_reservation and child_rebinds_a_reservation_after_a_restart
now run off Linux too. On macOS they fail if PortReservation holds its
socket, which blocks the child's SO_REUSEADDR bind there.

A new test, bind_to_port_zero_never_lands_below_ephemeral_low, checks
the premise UdpPortClaim rests on: the kernel's bind(…:0) never hands
out a port below ephemeral_low().

The test module takes Ipv4Addr, SocketAddr and the socket2 types from
`use super::*`, so no import needs a cfg gate.

Part of #2787.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 30, 2026 23:02

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

…rt docs

udp_bind_to_port_zero_never_lands_below_ephemeral_low makes UDP binds
only. UdpPortClaim's premise is about UDP, and macOS hands out TCP
ports in sequence (net.inet.tcp.randomize_ports is 0), so the TCP
binds added little. The ZERO_BINDS doc gives the detection numbers.

The ports module doc and the PortReservation doc say that only Linux
holds a reserved TCP port. On macOS a held socket blocks the child's
SO_REUSEADDR bind, so off Linux the reservation releases it.

The child-bind tests run off Linux too: child_binds_a_held_reservation
and held_reservation_survives_a_child_restart are named
child_binds_a_reservation and
child_rebinds_a_reservation_after_a_restart. The CHANGELOG entry says
which two tests run off Linux.

Part of #2787.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yigitdot yigitdot changed the title test(e2e): run the port-reservation bind tests on every target test(e2e): run the PortReservation child-bind tests off Linux Oct 30, 2026
@github-code-quality

github-code-quality Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust, Solidity

Rust / code-coverage/cargo-llvm-cov

main 0bd2393 claude/2787-port-tes... a1bcff2 +/-
77% 77% 0%
View coverage of the 3 most impacted files.
File main 0bd2393 claude/2787-port-tes... a1bcff2 +/-
crates/client/src/scheduler.rs 95% 94% -1%
crates/node/src...nt/serve_leg.rs 91% 90% -1%
crates/client/src/lib.rs 89% 89% 0%

Solidity / code-coverage/forge

main 0bd2393 claude/2787-port-tes... a1bcff2 +/-
92% 92% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 30, 2026 23:33 UTC

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@yigitdot
yigitdot requested a review from thiras October 31, 2026 00:02
@thiras
thiras merged commit 4ece849 into main Oct 31, 2026
38 checks passed
@thiras
thiras deleted the claude/2787-port-tests-non-linux branch October 31, 2026 01:26
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.

3 participants