The dual-stack client address tests move to another port when a second socket shares the one they picked #404

Merged
claude merged 3 commits from feature/397-dual-stack-test-windows into develop 2026-11-12 23:20:46 -05:00
Owner

The dual-stack client address tests move to another port when a second socket shares the one they picked. Test code only.

  • Failure: DualStackClientAddressTests failed now and then on the Windows runner.
  • Cause: on Windows a second socket may bind 127.0.0.1:P while the test's dual-stack [::]:P listener holds P, and IPv4 clients of 127.0.0.1 then reach that socket, not the listener. Linux refuses the second bind.
  • Fix: after both listeners are up, the test host reads the OS list of TCP and UDP listeners. The port is clean only when every entry on it is a wildcard address and none appears twice; otherwise the host stops both listeners and tries another port, inside the existing bounded loop.
  • New test: TcpClientOverIPv4_WhenAnotherSocketSharesThePort_UsesAnotherPort binds a plain 127.0.0.1 listener on the first port and expects the host to end on a different one. On Linux the intruder's bind is refused, so there the test only checks that the IPv4 client is seen as plain IPv4.
  • History of the branch: it first changed the product (exclusive port use on Windows) and then reverted that; the net diff is one test file. Whether listeners should claim their port exclusively on Windows is the open design question in #403.

Verified

  • Windows (lofnheim): the new test fails with the check disabled and passes with it; the class ran 30 times with 0 failures; Ninlil.Dns.Protocol.Plain.Tests 22 of 22.
  • Linux: build 0 warnings, 0 errors; Ninlil.Dns.Protocol.Plain.Tests 22 of 22; csharpier clean.
  • The CI failure itself was not reproduced; the mechanism is proven and the new test provokes it.
  • Verifier: accepted. One optional note (the port assertion has nothing to check on Linux) and one on the revert commit, which has no Refs #397 line.

Closes #397

🤖 Generated with Claude Code

https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK

The dual-stack client address tests move to another port when a second socket shares the one they picked. Test code only. - **Failure:** `DualStackClientAddressTests` failed now and then on the Windows runner. - **Cause:** on Windows a second socket may bind `127.0.0.1:P` while the test's dual-stack `[::]:P` listener holds P, and IPv4 clients of `127.0.0.1` then reach that socket, not the listener. Linux refuses the second bind. - **Fix:** after both listeners are up, the test host reads the OS list of TCP and UDP listeners. The port is clean only when every entry on it is a wildcard address and none appears twice; otherwise the host stops both listeners and tries another port, inside the existing bounded loop. - **New test:** `TcpClientOverIPv4_WhenAnotherSocketSharesThePort_UsesAnotherPort` binds a plain `127.0.0.1` listener on the first port and expects the host to end on a different one. On Linux the intruder's bind is refused, so there the test only checks that the IPv4 client is seen as plain IPv4. - **History of the branch:** it first changed the product (exclusive port use on Windows) and then reverted that; the net diff is one test file. Whether listeners should claim their port exclusively on Windows is the open design question in #403. **Verified** - Windows (lofnheim): the new test fails with the check disabled and passes with it; the class ran 30 times with 0 failures; `Ninlil.Dns.Protocol.Plain.Tests` 22 of 22. - Linux: build 0 warnings, 0 errors; `Ninlil.Dns.Protocol.Plain.Tests` 22 of 22; csharpier clean. - The CI failure itself was not reproduced; the mechanism is proven and the new test provokes it. - Verifier: accepted. One optional note (the port assertion has nothing to check on Linux) and one on the revert commit, which has no `Refs #397` line. Closes #397 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Windows lets a wildcard socket and a socket on one specific address bind the same port and
sends clients to the specific one. The listen sockets now bind exclusively on Windows, so such
a bind fails and is reported as a failed listen address.

Closes #397

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
This reverts commit 931be6f8bb.
The dual-stack client address tests move to another port when a second socket shares the one they picked
All checks were successful
Build / Pack and Push NuGet Packages (dns-core) (pull_request) Successful in -1m54s
Build / Stage Draft Release (push) Successful in -2m35s
Build / Pack and Push NuGet Packages (dhcp) (pull_request) Successful in -1m57s
Build / Pack and Push NuGet Packages (common) (push) Successful in -2m26s
Build / Pack and Push NuGet Packages (dns-server) (pull_request) Successful in -1m56s
Build / Pack and Push NuGet Packages (dhcp) (push) Successful in -2m13s
Build / Pack and Push NuGet Packages (dns-core) (push) Successful in -2m10s
Build / Pack and Push NuGet Packages (dns-server) (push) Successful in -2m3s
Build / Build Binary (linux-amd64) (pull_request) Successful in -8s
Build / Build Binary (linux-arm64) (pull_request) Successful in 18s
Build / Build Binary (macos-amd64) (pull_request) Successful in 25s
Build / Build Binary (macos-arm64) (pull_request) Successful in 39s
Build / Build Binary (windows-amd64) (pull_request) Successful in 21s
Build / Smoke Test the Windows Binary (pull_request) Successful in 15s
Build / Build Binary (linux-arm64) (push) Successful in 11s
Build / Build Binary (linux-amd64) (push) Successful in 17s
Build / Build Binary (macos-arm64) (push) Successful in -18s
Build / Build Binary (macos-amd64) (push) Successful in -18s
Build / Build Binary (windows-amd64) (push) Successful in -1m0s
Build / Smoke Test the Windows Binary (push) Successful in 15s
Build / Build Arch Linux Packages (pull_request) Successful in -2m4s
Build / Build and Test Deb and RPM Packages (pull_request) Successful in -22s
Build / Build and Push Image (pull_request) Successful in -2m31s
Build / Build Arch Linux Packages (push) Successful in -2m18s
Build / Build and Push Image (push) Successful in -2m6s
Build / Build and Test Deb and RPM Packages (push) Successful in 4s
Build / Publish Release (pull_request) Successful in -2m17s
Build / Pipeline (pull_request) Successful in 0s
Build / Publish Release (push) Successful in -2m34s
Build / Pipeline (push) Successful in 0s
84bac97fa3
Windows lets a socket on 127.0.0.1 share a port with the dual-stack listener and sends IPv4 clients to it. The test host now reads the operating system's socket list and starts over on a new port when anything but the listener's own wildcard entries holds the port.

Closes #397

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
claude merged commit 53ecb436c1 into develop 2026-11-12 23:20:46 -05:00
claude deleted branch feature/397-dual-stack-test-windows 2026-11-12 23:20:46 -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!404
No description provided.