Repository navigation
Description
Summary
Several end-to-end tests fail intermittently when the whole suite runs on a busy machine. Two consecutive full runs of go test ./... -count=1 on Windows failed, each time with different tests, and every failure was a lookup against an in-process DNS server that timed out. CI on main is green, so this is CPU contention, not a logic error, but it gives contributors red runs that their change did not cause.
Where
main_e2e_test.go:560-578(TestE2EDiff,-timeout 200, one attempt)main_e2e_test.go:228,main_e2e_test.go:420(-timeout 100)main_lab_test.go:101-122(TestE2ELabVerdicts, lab3 and lab5 cases)main_ct_test.go:56,main_resume_test.go:307,main_e2e_test.go:814,main_e2e_test.go:919internal/dns/transport_test.go:149(TestDoTDiscardsClosedConnections)pkg/subenum/subenum_test.go:521(TestNoAbortScanSucceedsDespiteFailingLookups)
Details
Run 1 failed TestE2ECertificateTransparency, TestE2EResume, TestE2EResumeReplaysSourceNames, TestE2EInternalAddresses, TestE2ELabVerdicts (two lab3 subtests), TestDoTDiscardsClosedConnections and TestNoAbortScanSucceedsDespiteFailingLookups. Run 2 failed only TestE2EDiff. Typical messages:
main_e2e_test.go:578: exit 1, want 4 (changes)
main_e2e_test.go:919: interrupted run: exit 0, want 130
"reason": "2 of 4 lookups failed (timeout 2, refused 0, other 0)"
subenum_test.go:521: ... failed preflight for lab.example: timeout after 1 attempt(s)
transport_test.go:149: lookup www.example.com. on tls://127.0.0.1:1458: i/o timeout
The affected tests look names up on a local server with a short timeout and a single attempt (-timeout 100 or -timeout 200), so one slow scheduling slice turns a preflight or a real answer into a timeout. 57 tests in the root package call t.Parallel() (since #266), and go test ./... also runs packages in parallel, which is when the timeouts appear. The lab tests already have a robust setting for this, labTimingArgs = -timeout 5000 -attempts 3 (main_lab_test.go:18), but not every case uses it.
Impact
Contributors on a slow or loaded machine, Windows in particular, see failures unrelated to their change, and a rerun fails a different test. A real regression in timeout handling would be easy to dismiss as the same noise.
Steps to reproduce
- On Windows, start a CPU-heavy job (a second
go test ./...or a build). - Run
go test ./... -count=1. - Some root-package end-to-end tests fail with lookup timeouts; a rerun fails different ones.
Suggested fix
Give every test that is not about timeouts a generous lookup timeout and more than one attempt, as labTimingArgs does. Keep short timeouts only where a TIMEOUT record is the subject of the test, and either keep those few tests serial or assert only on the outcome of the timed-out name rather than on the whole scan finishing cleanly within 100 to 200 ms.
Acceptance criteria
- No end-to-end test that expects real answers uses a lookup timeout under one second with a single attempt
- Tests that need a short timeout assert only on the name that is meant to time out
-
go test ./... -count=1passes five times in a row on Windows while a second copy of the suite runs alongside it
Getting started
- Relevant files:
main_e2e_test.go,main_lab_test.go,main_ct_test.go,main_resume_test.go,internal/dns/transport_test.go,pkg/subenum/subenum_test.go - How to run tests:
go test ./... -count=1(ormake test) - Related: Timing-sensitive tests fail under load (pool spread, lab 2 wildcard, SARIF) #167 (an earlier set of timing-sensitive tests, fixed), Interrupt tests rely on wall-clock sleeps #260, package main uses mutable globals as test seams, blocking t.Parallel #266
Filed by repo-audit/full-audit at d0c56f0. Severity: medium. Effort: M. audit-key: testing|main_e2e_test.go|parallel-short-dns-timeouts
Activity
Give end-to-end tests load-tolerant DNS timeouts (#289)
TMHSDigital commentedon Nov 15, 2026
Partly done in 5c582b9; leaving this open for what remains.
Done: the end-to-end tests named here no longer use short, single-attempt DNS timeouts against the in-process server. Runs that expect real answers use the lab timing (5 s, 3 attempts); zones with records that never answer use 2 s and 2 attempts; single-attempt 2 s timeouts against servers that answer at once are 10 s; and the interrupted run in
TestE2EResumeuses one worker. No assertion was changed or removed.Evidence: before the change,
go test ./internal/cli ./internal/dns ./pkg/subenum -count=3 -cpu 1,4run beside two other full suites (one with-race) failed once, inTestE2EDiff. After it,go test ./internal/cli -count=5 -cpu 1,4beside the same two suites passed, and so did both background suites. TheTestE2EResumechange was not reproduced; it rests on reading the rate limiter.Still open:
TestDoTDiscardsClosedConnectionsdepends on a 5 ms sleep (internal/dns/transport_test.go) and failed once on an idle run (counted 11 queries, want 10), then passed 30 times in a row. A deterministic fix needs the test DNS server to signal that it closed the stream.internal/scan,internal/tuiandinternal/mcpwere not checked for the same pattern.Make the DoT closed-connection test deterministic (#289)
TMHSDigital commentedon Nov 15, 2026
Another part done in 80cf0d3.
Done:
TestDoTDiscardsClosedConnectionsno longer depends on a 5 ms sleep. Waiting for the server to close its side was not enough: a 200-run loop still failed once (counted 11 queries, want 10), because the client'saliveprobe reads for only 1 ms and can miss a close that is already sent. The test now takes each pooled DoT connection, reads until it sees the server's close, and puts it back, so the next lookup's probe always finds it closed and the discard path is still what is tested. Verified: 500 runs in a row pass;go test ./internal/dns,go vetand golangci-lint v2.15.0 pass.Still open:
TestE2ELabVerdictsstill needs the client to send more than 40 queries within one second. Making it deterministic needs a change to how the lab server rate-limits (for example a query-count window instead of a wall-clock one), which changes the lab scenario.internal/scan,internal/tuiandinternal/mcphave not been checked for the same short-timeout pattern.TMHSDigital commentedon Nov 15, 2026
The rest is done in 300979e.
go test ./... -count=1passed five times in a row on Windows with a second copy of the suite running alongside (that copy passed too).runner_testcases expect an error either way, so a slow answer cannot flip them.TestPoolBenchesDeadResolverkeeps 250 ms on purpose: benching needs 20 timed-out lookups on the dead member, and TestPoolBenchesDeadResolver is flaky (about 7% failure rate) #253 already raised it from 50 ms. Nothing else in those packages uses a short single-attempt timeout against a server that should answer.Test: give lab 3's unreliable case a burst a slow run keeps (TMHSDigi…