Skip to content

connectd/tests: fix test_announce_and_connect_via_dns on macOS#9143

Open
nGoline wants to merge 1 commit into
ElementsProject:masterfrom
nGoline:dns-announce-macos-fix
Open

connectd/tests: fix test_announce_and_connect_via_dns on macOS#9143
nGoline wants to merge 1 commit into
ElementsProject:masterfrom
nGoline:dns-announce-macos-fix

Conversation

@nGoline
Copy link
Copy Markdown
Collaborator

@nGoline nGoline commented May 18, 2026

Summary

  • Skip test_announce_and_connect_via_dns with a clear message when localhost.localdomain is not resolvable (macOS omits it from /etc/hosts by default)
  • Guard AI_ADDRCONFIG in try_connect_one_addr() with #ifndef __APPLE__: on macOS/BSD, AI_ADDRCONFIG opens temporary probe sockets that are not tracked by the io framework, causing dev_report_fds() to report them as unowned (**BROKEN**); Linux keeps the optimization unchanged

Closes #9012

Test plan

  • uv run pytest tests/test_gossip.py::test_announce_and_connect_via_dns -v passes on Linux
  • On macOS without localhost.localdomain in /etc/hosts: test is skipped with a descriptive message
  • On macOS with localhost.localdomain in /etc/hosts: no **BROKEN** fd messages from connectd at teardown

🤖 Generated with Claude Code

@nGoline nGoline requested a review from ddustin May 18, 2026 14:16
@nGoline nGoline force-pushed the dns-announce-macos-fix branch from 65e7503 to 89d3d46 Compare May 18, 2026 14:22
Two issues caused this test to fail or produce BROKEN log messages on macOS:

1. macOS does not include 'localhost.localdomain' in /etc/hosts by default,
   so the test's DNS-resolve step fails immediately.  Skip with a clear
   message if the hostname is not resolvable.

2. On macOS/BSD, AI_ADDRCONFIG is implemented by opening temporary probe
   sockets to test IPv4/IPv6 connectivity.  Those sockets are not registered
   with the io framework, so dev_report_fds() flags them as unowned (BROKEN).
   Guard AI_ADDRCONFIG with #ifndef __APPLE__ so Linux keeps the optimization
   while macOS avoids the fd-leak.

Changelog-None

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nGoline nGoline force-pushed the dns-announce-macos-fix branch from 89d3d46 to b7b271c Compare May 18, 2026 20:50
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.

pytest: **BROKEN** Error in test test_announce_and_connect_via_dns

1 participant