Resolver tests hit real DNS, causing slow/flaky/racy test suite #32
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The resolver tests in
internal/resolver/resolver_test.gouseNewFromLoggerwhich creates real UDP/TCP DNS clients. All tests run in parallel hitting real nameservers, which causes:-raceflag due to concurrent real DNS queriesSolution
Replace real DNS calls with a mock
DNSClientusing the existingNewFromLoggerWithClient(log, client DNSClient)constructor. All test behaviors (NS lookup, A/AAAA/MX/TXT records, NXDOMAIN, sorting, dedup, context cancellation, trailing dots, etc.) should be preserved but use deterministic canned responses instead of real network calls.