Skip to content

Fix flaky heartbeat port allocation and run summarize_git tests in CI - #10

Merged
DNSGeek merged 2 commits into
masterfrom
claude/vibrant-poincare-f55a9c
Oct 18, 2026
Merged

DNSGeek merged 2 commits into
masterfrom
claude/vibrant-poincare-f55a9c

Conversation

@DNSGeek

@DNSGeek DNSGeek commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Two small, separate fixes for the Tests workflow, one commit each.

test_heartbeat.py: ask the OS for ports

_PortBox handed out consecutive ports from 53400, inside Linux's ephemeral range (32768-60999). Any outgoing connection on the runner could already hold one, and Heartbeat.start() then failed with "Address already in use", as test_no_split_brain_under_simultaneous_start did on #9.

The allocator now binds a throwaway socket to ("127.0.0.1", 0) with SO_REUSEADDR and reads back the kernel's choice. Pairs come back sorted so the lower port stays first (the election rule and several assertions rely on lower-port-wins), and no port is handed out twice in one process. The PORTS.pair() call sites are unchanged.

tests.yml: install requests

test_summarize_git.py's module fixture does pytest.importorskip("requests"), and the workflow only installed pytest, so all 23 summarize_git tests were reported as skipped in CI. The install step now installs requests alongside pytest.

Verification (local, Python 3.13)

  • pytest -q test_heartbeat.py three times: 14 passed each run (43-45 s).
  • Full suite with requests: 122 passed, 0 skipped.
  • After rebasing onto current master: test_summarize_git.py without requests = 23 skipped; with requests = 23 passed.
  • ruff check, black --check, isort --check-only, ssort --check: clean.

🤖 Generated with Claude Code

DNSGeek and others added 2 commits October 18, 2026 12:58
_PortBox handed out consecutive ports from 53400, inside Linux's
ephemeral range (32768-60999), so any outgoing connection on the CI
runner could already hold one and Heartbeat.start() then failed with
"Address already in use" (seen on PR #9 in
test_no_split_brain_under_simultaneous_start).

Reserve each port by binding a throwaway socket to ("127.0.0.1", 0)
and reading back the kernel's choice. Pairs are returned sorted so the
lower port stays first, which the election rule and the assertions
depend on, and a port is never handed out twice in one process. Call
sites are unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The module fixture does pytest.importorskip("requests"), and the
workflow only installed pytest, so every summarize_git test was
reported as skipped on GitHub. Install requests alongside pytest.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@DNSGeek
DNSGeek merged commit 66975f5 into master Oct 18, 2026
3 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.

1 participant