Skip to content

End-to-end tests fail intermittently under load: short DNS timeouts in parallel tests #289

Closed

Description

@TMHSDigital

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:919
  • internal/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

  1. On Windows, start a CPU-heavy job (a second go test ./... or a build).
  2. Run go test ./... -count=1.
  3. 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=1 passes five times in a row on Windows while a second copy of the suite runs alongside it

Getting started


Filed by repo-audit/full-audit at d0c56f0. Severity: medium. Effort: M. audit-key: testing|main_e2e_test.go|parallel-short-dns-timeouts

Activity

  1. added
    help wanted
    testing
    severity: medium
    on Nov 14, 2026
  2. TMHSDigital commented on Nov 15, 2026

    @TMHSDigital
    OwnerAuthor

    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 TestE2EResume uses one worker. No assertion was changed or removed.

    Evidence: before the change, go test ./internal/cli ./internal/dns ./pkg/subenum -count=3 -cpu 1,4 run beside two other full suites (one with -race) failed once, in TestE2EDiff. After it, go test ./internal/cli -count=5 -cpu 1,4 beside the same two suites passed, and so did both background suites. The TestE2EResume change was not reproduced; it rests on reading the rate limiter.

    Still open:

    • TestDoTDiscardsClosedConnections depends 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.
    • The lab 3 "unreliable" case still needs the client to send more than 40 queries within one second.
    • The third acceptance criterion (five full runs in a row beside a second copy) was not run in that exact form.
    • internal/scan, internal/tui and internal/mcp were not checked for the same pattern.
  3. TMHSDigital commented on Nov 15, 2026

    @TMHSDigital
    OwnerAuthor

    Another part done in 80cf0d3.

    Done: TestDoTDiscardsClosedConnections no 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's alive probe 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 vet and golangci-lint v2.15.0 pass.

    Still open:

    • The lab 3 "unreliable" case in TestE2ELabVerdicts still 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.
    • The third acceptance criterion (five full runs in a row beside a second copy) has not been run in that exact form.
    • internal/scan, internal/tui and internal/mcp have not been checked for the same short-timeout pattern.
  4. TMHSDigital commented on Nov 15, 2026

    @TMHSDigital
    OwnerAuthor

    The rest is done in 300979e.

    • Lab 3 unreliable case: it now scans lab 3 with 150 names (about 300 queries) instead of the lab's 30 words, so more than a fifth are refused unless the run takes over 6 s, while staying under the reliability guard's 200 lookups. Passes 10 runs in a row.
    • Third acceptance criterion: go test ./... -count=1 passed five times in a row on Windows with a second copy of the suite running alongside (that copy passed too).
    • internal/scan, internal/tui, internal/mcp: checked. The short-timeout runner_test cases expect an error either way, so a slow answer cannot flip them. TestPoolBenchesDeadResolver keeps 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.
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

    help wantedseverity: mediumtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions