The DNS transport and Web test projects start their servers on port 0 and read the bound port #413

Merged
claude merged 8 commits from feature/362-port-zero-dns-tests into develop 2026-11-13 03:36:47 -05:00
Owner

The DNS transport and Web test projects start their servers on port 0 and read the bound port, or retry a bounded number of times where one port number must be shared. This is the second half of #362 (the DHCP test projects are pull request #411) and finishes the dedicated pass of #233.

  • Product change (one): DnsOverHttpsHostedService.BoundPort reports the port the standalone DNS-over-HTTPS service bound, and 0 when it is not running. Its "listening on port" log line prints that port. DoT, DoQ and DNSCrypt already had the member.
  • DoH tests: all four call sites use port 0 and BoundPort; the three reserve-and-release helpers are deleted.
  • DNSCrypt, DoT and DoQ listen-address tests: several sockets and listen addresses must share one number, which port 0 cannot give, so they keep a reservation with a bounded retry of five attempts and a comment. An attempt is accepted only when exactly the expected address (the unassigned 192.0.2.1) failed to bind.
  • DoT and DoQ test helpers: the wait for a listener also ends when the listener's task completes, so a listener that bound nothing no longer costs the 10-second timeout.
  • Web tests:
    • TransportSettingsHotReloadTests uses a test-owned silent socket and port 0.
    • DhcpServiceControlControllerTests starts DHCPv6 on port 0 and reads Dhcpv6UdpListener.BoundPort.
    • StartupRefusalProcessTests and NinlilDnsWebApplicationFactory keep their environment-variable ports, because the host or child process reads them before it starts.
  • Left as justified, with comments: PlainListenAddressTests, ListenSocketSetTests, DnsCryptProviderNameTests.

Verified

  • With the reserved port stolen between reserve and bind, the old form of one test per project fails 3 of 3 and the new form passes 3 of 3.
  • DoH 33, DNSCrypt 54, DoT 48 and DoQ 21 tests pass 10 runs in a row; Ninlil.Web.Tests 2353 of 2353; build 0 warnings, 0 errors; csharpier clean.
  • Verifier: fix needed on the first round (the DHCPv6 test kept a reservation it did not need), accepted on the second. It confirmed from the code that a DHCPv6 server port of 0 never leads to a bind or send on 547 or 546.
  • Weaker than before, knowingly: after stop the DHCPv6 test asserts that the listener reports port 0 and that the service is not running; it no longer probes that the socket is released, because a probe on a freed number cannot tell a released socket from one another process took.

Closes #362
Closes #233

🤖 Generated with Claude Code

https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK

The DNS transport and Web test projects start their servers on port 0 and read the bound port, or retry a bounded number of times where one port number must be shared. This is the second half of #362 (the DHCP test projects are pull request #411) and finishes the dedicated pass of #233. - **Product change (one):** `DnsOverHttpsHostedService.BoundPort` reports the port the standalone DNS-over-HTTPS service bound, and 0 when it is not running. Its "listening on port" log line prints that port. DoT, DoQ and DNSCrypt already had the member. - **DoH tests:** all four call sites use port 0 and `BoundPort`; the three reserve-and-release helpers are deleted. - **DNSCrypt, DoT and DoQ listen-address tests:** several sockets and listen addresses must share one number, which port 0 cannot give, so they keep a reservation with a bounded retry of five attempts and a comment. An attempt is accepted only when exactly the expected address (the unassigned 192.0.2.1) failed to bind. - **DoT and DoQ test helpers:** the wait for a listener also ends when the listener's task completes, so a listener that bound nothing no longer costs the 10-second timeout. - **Web tests:** - `TransportSettingsHotReloadTests` uses a test-owned silent socket and port 0. - `DhcpServiceControlControllerTests` starts DHCPv6 on port 0 and reads `Dhcpv6UdpListener.BoundPort`. - `StartupRefusalProcessTests` and `NinlilDnsWebApplicationFactory` keep their environment-variable ports, because the host or child process reads them before it starts. - **Left as justified, with comments:** `PlainListenAddressTests`, `ListenSocketSetTests`, `DnsCryptProviderNameTests`. **Verified** - With the reserved port stolen between reserve and bind, the old form of one test per project fails 3 of 3 and the new form passes 3 of 3. - DoH 33, DNSCrypt 54, DoT 48 and DoQ 21 tests pass 10 runs in a row; `Ninlil.Web.Tests` 2353 of 2353; build 0 warnings, 0 errors; csharpier clean. - Verifier: fix needed on the first round (the DHCPv6 test kept a reservation it did not need), accepted on the second. It confirmed from the code that a DHCPv6 server port of 0 never leads to a bind or send on 547 or 546. - Weaker than before, knowingly: after stop the DHCPv6 test asserts that the listener reports port 0 and that the service is not running; it no longer probes that the socket is released, because a probe on a freed number cannot tell a released socket from one another process took. Closes #362 Closes #233 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Refs #362

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Refs #362

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Refs #362

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Refs #362

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Refs #362

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Refs #362

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Refs #362

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
The DHCPv6 service control test starts its server on port 0 and reads the bound port
All checks were successful
Build / Pack and Push NuGet Packages (dhcp) (pull_request) Successful in -2m17s
Build / Pack and Push NuGet Packages (dns-core) (pull_request) Successful in -2m13s
Build / Stage Draft Release (push) Successful in -2m36s
Build / Pack and Push NuGet Packages (dns-server) (pull_request) Successful in -2m6s
Build / Pack and Push NuGet Packages (common) (push) Successful in -2m24s
Build / Pack and Push NuGet Packages (dhcp) (push) Successful in -2m6s
Build / Pack and Push NuGet Packages (dns-core) (push) Successful in -2m3s
Build / Pack and Push NuGet Packages (dns-server) (push) Successful in -1m58s
Build / Build Binary (linux-amd64) (pull_request) Successful in -1m6s
Build / Build Binary (linux-arm64) (pull_request) Successful in -46s
Build / Build Binary (macos-amd64) (pull_request) Successful in -55s
Build / Build Binary (macos-arm64) (pull_request) Successful in -1m5s
Build / Build Binary (windows-amd64) (pull_request) Successful in -1m6s
Build / Build Binary (linux-amd64) (push) Successful in -58s
Build / Smoke Test the Windows Binary (pull_request) Successful in 21s
Build / Build Binary (linux-arm64) (push) Successful in -48s
Build / Build Binary (macos-amd64) (push) Successful in -5s
Build / Build Binary (macos-arm64) (push) Successful in -28s
Build / Build Binary (windows-amd64) (push) Successful in -59s
Build / Smoke Test the Windows Binary (push) Successful in 15s
Build / Build Arch Linux Packages (pull_request) Successful in -2m23s
Build / Build and Test Deb and RPM Packages (pull_request) Successful in -2s
Build / Build and Push Image (pull_request) Successful in -1m57s
Build / Build Arch Linux Packages (push) Successful in -1m43s
Build / Build and Push Image (push) Successful in -1m55s
Build / Build and Test Deb and RPM Packages (push) Successful in -21s
Build / Publish Release (pull_request) Successful in -2m34s
Build / Pipeline (pull_request) Successful in 0s
Build / Publish Release (push) Successful in -2m34s
Build / Pipeline (push) Successful in 0s
073e5269a3
The retry helpers of the DNSCrypt, DNS-over-TLS and DNS-over-QUIC address tests also require that only the unassigned address failed.

Refs #362

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
claude merged commit bee1974114 into develop 2026-11-13 03:36:47 -05:00
claude deleted branch feature/362-port-zero-dns-tests 2026-11-13 03:36:47 -05:00
Sign in to join this conversation.
No reviewers
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lantea-one/ninlil!413
No description provided.