tests: remove the DNS stand-ins from the watcher and resolver tests (closes #159)
check / check (push) Successful in 1m17s
check / check (push) Successful in 1m17s
The watcher tests used a stand-in resolver and the resolver timeout test a stand-in DNS client, against the rule that DNS is never mocked. The watcher tests now run the real resolver against live DNS. A change is tested by saving values live DNS never returns (names under .invalid, 192.0.2.1) in the state a check starts from, or by marking a real nameserver failed. The timeout test queries 192.0.2.1, where nothing answers. The live-DNS retry and concurrency limit moved from the resolver tests to internal/livedns, so both packages share them. NewFromLoggerWithClient had no other use and is gone. TESTING.md and the DNSClient comment now state the README's rule. Model: opus-5-5
This commit is contained in:
+12
-4
@@ -2,8 +2,12 @@
|
||||
|
||||
## DNS Resolution Tests
|
||||
|
||||
All resolver tests **MUST** use live queries against real DNS servers.
|
||||
No mocking of the DNS client layer is permitted.
|
||||
DNS is never mocked in this project, not in tests and not anywhere
|
||||
else; see the README section "No DNS mocking. Ever." Every test that
|
||||
looks something up in DNS **MUST** query live DNS servers, never a
|
||||
stand-in. Logic that works on record data, such as comparing or
|
||||
formatting records, may be tested on that data directly with no
|
||||
lookup.
|
||||
|
||||
### Rationale
|
||||
|
||||
@@ -21,14 +25,18 @@ real servers ensures the resolver works correctly in production.
|
||||
- Query timeout is calibrated to 3× maximum antipodal RTT (~300ms)
|
||||
plus processing margin
|
||||
- Root server fan-out is limited to reduce parallel query load
|
||||
- Live lookups that expect an answer go through `internal/livedns`,
|
||||
which limits how many run at once in a test binary and retries a
|
||||
lookup that got none
|
||||
- Flaky failures from transient network issues are acceptable and
|
||||
should be investigated as potential resolver bugs, not papered over
|
||||
with mocks or skip flags
|
||||
|
||||
### What NOT to do
|
||||
|
||||
- **Do not mock `DNSClient`** for resolver tests (the mock constructor
|
||||
exists for unit-testing other packages that consume the resolver)
|
||||
- **Do not mock, fake or stub DNS** anywhere: no stand-in `DNSClient`,
|
||||
no stand-in for the watcher's `DNSResolver`, no fake DNS server, no
|
||||
canned responses
|
||||
- **Do not add `-short` flags** to skip slow tests
|
||||
- **Do not increase `-timeout`** to hide hanging queries
|
||||
- **Do not remove `-count=1` from `script/test`** — Go's test cache
|
||||
|
||||
Reference in New Issue
Block a user