fix: harden integration tests against macOS port reuse races#840
Merged
Conversation
Add readiness channels between server threads and the main thread in two tests (compressed_sse_retry_drains_first_response_before_replay and schemeless_https_connect_error_suggests_plaintext_url) so run_fetch is not called until the server accept loop is running. Increase run_fetch_opts transient-error retries from 4 to 9 with exponential backoff (25ms → 1s cap) to absorb longer macOS kernel port-reuse delays.
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.
Summary
Fixes flaky
compressed_sse_retry_drains_first_response_before_replaytest on macOS CI.Root Cause
macOS port reuse races when integration tests run in parallel — the test spawns a server thread and immediately calls
run_fetchwith no synchronization. The fetch binary getsECONNREFUSEDbefore the thread enters its accept loop.Changes
tests/http.rs— Addedmpscreadiness channels to two tests with manualTcpListener+ thread patterns. The main thread now waits for the server thread to enter its accept loop before callingrun_fetch/run_fetch_once.tests/support/common.rs— Hardenedrun_fetch_optsretry loop: 4→9 retries with exponential backoff (25ms → 1s cap, ~3.6s total budget vs ~100ms before). This absorbs longer macOS kernel port-reuse delays.Validation
cargo fmt --check✅cargo clippy --locked --all-targets --all-features -- -D warnings✅compressed_sse_retry_drains_first_response_before_replaypasses locally ✅