--- FAIL: TestLookupHostCancel (5.41s)
lookup_test.go:962: lookup www.google.com on 192.168.87.1:53: dial udp 192.168.87.1:53: socket: too many open files
FAIL net 25.064s
It's not clear to me whether this is a platform bug in the native resolver (CC @bsiegert), or if the parallel net tests are actually leaving too many file descriptors open when this test executes (compare #46279; CC @bradfitz@ianlancetaylor).
greplogs --dashboard -md -l -e 'lookup www\.google\.com .*: too many open files'
As far as I can tell from the code, the fact that the context is canceled before calling DefaultResolver.LookupHost should mean that it does not create any UDP sockets. The DNS lookup will eventually call sysDialer.dialSerial which checks the context in the loop. So the loop in the test shouldn't create any file descriptors. (Verified by running the test on Linux and counting the number of calls to the socket system call.) The error is happening for the single valid lookup, without a canceled context, that the test runs at the end.
If that is correct, then it's weird that the test takes 5 seconds to run.
And it means that the failure doesn't have much to do with TestLookupHostCancel as such.
But I may have made some mistake in this analysis.