Skip to content

fix(tests): pick a port free on loopback too in the wildcard port-probe test (#4445) - #4446

Merged
vybe merged 1 commit into
devfrom
fix/4445-port-probe-test-flake
Nov 10, 2026
Merged

vybe merged 1 commit into
devfrom
fix/4445-port-probe-test-flake

Conversation

@trinity-ability

Copy link
Copy Markdown
Contributor

Fixes #4445

What

test_wildcard_probe_sees_a_bind_on_another_local_address bound (127.0.0.2, 0) and then bound 127.0.0.1 on the same port. The kernel only guarantees the port is free on the address that was asked, so when another socket on the CI runner already held it on 127.0.0.1 the second bind raised EADDRINUSE. The earlier is_port_available(port) is False assertion could also pass for the wrong reason in that case. It failed twice in a row on #4443, whose tested tree was byte-identical to dev.

_hold_port_free_on_loopback now checks that 127.0.0.1 can bind the port while the other-address bind is held, and retries (up to 50) if not. Test-only change; no production code touched.

Test plan

  • pytest tests/unit/test_ent1117_port_probe_bind_only.py: 6 passed (macOS)
  • Mutation 1, the loopback check removed from the helper: the new regression test test_port_choice_skips_a_port_already_taken_on_loopback goes red
  • Mutation 2, is_port_available binding 127.0.0.1 instead of 0.0.0.0: the wildcard test goes red, so the property it pins is still enforced
  • The Linux 127.0.0.2 path runs in CI (pytest (head, seed 12345))

Journey Impact: none: test-only fix to a unit test's port selection; no user journey changes

🤖 Generated with Claude Code

…be test (#4445)

test_wildcard_probe_sees_a_bind_on_another_local_address bound (127.0.0.2, 0)
and then bound 127.0.0.1 on the same port. The kernel only guarantees the
port free on the address asked, so whenever another socket on the runner held
it on 127.0.0.1 the loopback bind raised EADDRINUSE (and the busy assertion
passed for the wrong reason). Seen twice in a row on #4443.

_hold_port_free_on_loopback now confirms the 127.0.0.1 side is bindable while
the other-address bind is held, retrying up to 50 times. Regression test
test_port_choice_skips_a_port_already_taken_on_loopback injects a port busy
on 127.0.0.1 and asserts it is skipped.

Fixes #4445

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Validated: test-only fix for #4445; both mutations red locally (loopback check removed → regression test red; probe on 127.0.0.1 → wildcard test red).

@vybe
vybe merged commit 8fe1ec7 into dev Nov 10, 2026
22 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.

2 participants