Repository navigation
Description
Summary
TestCheckWildcardInconclusive/timeout failed once during a full go test -shuffle=on ./... run on Windows and passed on 5 reruns alone. With a 100 ms per-attempt timeout and a server that drops the query, a loaded machine can let an attempt time out before its packet is written, so the server counts one query instead of two.
Where
internal/dns/resolver_test.go:117(TestCheckWildcardInconclusive), thetimeoutcaseinternal/dns/resolver_test.go:127(timeout := 100 * time.Millisecond)internal/dns/resolver_test.go:138(if got := srv.Queries(); got < 2)
Details
Failure seen in a local full-suite run while working on #432 (before 7ea4e94):
--- FAIL: TestCheckWildcardInconclusive/timeout (0.26s)
resolver_test.go:139: queries = 1, want >= 2 (the probe retried)
The test checks that the probe was retried by counting packets the test server received. That count depends on the client getting each packet onto the wire within its 100 ms attempt. Under a full parallel suite on Windows, the second attempt's deadline can pass before the write happens. The probe was still retried, but the server never saw the second query.
Impact
An occasional red CI run or local gate that has nothing to do with the change under test. Low severity, but it costs a rerun and trust in the suite.
Steps to reproduce
- On a loaded machine, run
go test -shuffle=on ./...a few times. - Occasionally
TestCheckWildcardInconclusive/timeoutfails withqueries = 1. go test ./internal/dns -run TestCheckWildcardInconclusive -count=5alone passes.
Suggested fix
Count attempts on the client side instead of packets on the server, for example with a resolver hook or a dial counter that sees each attempt start. Alternatively, raise the per-attempt timeout for this case (the test only needs the probe to fail, not to fail fast), or wait for the server to report two queries before asserting.
Acceptance criteria
- The test asserts the retry without depending on packets reaching the server within 100 ms
-
go test -count=20 -run TestCheckWildcardInconclusive ./internal/dnspasses under-cpu 1with a parallel suite running
Getting started
- Relevant files:
internal/dns/resolver_test.go,internal/dns/resolver.go(CheckWildcard) - How to run tests:
go test ./internal/dns -run TestCheckWildcardInconclusive -count=20 - Related: Three tests still assert wall-clock upper bounds and can flake under load #206
Filed by repo-audit/fix-issues at e821702. Severity: low. Effort: S. audit-key: testing|internal/dns/resolver_test.go|TestCheckWildcardInconclusive
Activity