Skip to content

TestBindPairLeavesReservedBlock fails on Windows with reserved TCP port ranges #254

Closed

Description

@TMHSDigital

Summary

TestBindPairLeavesReservedBlock fails on Windows hosts that have reserved TCP port ranges (Hyper-V or WinNAT). It failed in 5 of 6 runs on one such host. The product code is fine. The test helper picks its "random" ports in a way that the #204 fix deliberately avoids.

Where

  • internal/dnsserver/bindpair_test.go:39-48: the pick helper takes OS-assigned ephemeral UDP ports, which are sequential (for example 49709, 50206)
  • internal/dnsserver/bindpair_test.go:54-56: asserts exactly 4 binds

Details

On the affected host, netsh int ipv4 show excludedportrange protocol=tcp shows 49672-50384 reserved, and the test's ports fall inside it. When the real 4th TCP bind is refused, the test fails with either no free UDP+TCP port pair or UDP binds [...9 entries], want 4. Product code uses randomPort (20000-59999).

Impact

go test ./... fails locally for Windows contributors who have Hyper-V or WSL port reservations.

Steps to reproduce

On such a host: go test ./internal/dnsserver/ -run TestBindPair -count=5

Suggested fix

Have pick draw ports from randomPort, retrying until the UDP port is free. Relax the assertion to: the first attempt is :0, the next attempts are explicit ports, and the final UDP and TCP pair share one port.

Acceptance criteria

  • The test passes on a host with reserved TCP ranges in the ephemeral block.

Getting started

  • Relevant files: internal/dnsserver/bindpair_test.go
  • How to run tests: go test -count=20 -run TestBindPair ./internal/dnsserver/
  • Related docs: docs/DEVELOPER_GUIDE.md

Related: #204


Filed by repo-audit/full-audit at 3f671b2. Severity: low. Effort: S. audit-key: testing|internal/dnsserver/bindpair_test.go|pick

Activity

  1. added
    good first issue
    testing
    severity: low
    on Nov 14, 2026
  2. TMHSDigital commented on Nov 14, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in 2ff3029: the test's pick draws from randomPort and keeps a port free for both UDP and TCP; the bind-count assertion is now 'at least 4'. Verified with go test -run TestBindPair -count=20 ./internal/dnsserver/ on the same Windows host that failed 5/6 before: 20/20 pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueseverity: lowtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions