Cover the engine, config.Size and metrics; fix the five bugs they found
internal/engine, internal/config and internal/metrics had no test file at all, and writing them turned up five real bugs. internal/engine (23 tests, new harness_test.go): a wired engine over a fake upstream on loopback, a local zone, a blocklist, a cache, a query log and an injectable clock. It pins the pipeline order end to end -- ACL deny before the local zone, local zone before blocklist, blocklist before cache, drop sends nothing, the concurrency and rate-limit refusals, serve-stale served with TTL 1 and refreshed once per key, truncation against a 512-byte client, and exactly one metrics record and one query-log entry per query. Five fixes: - config.ParseSize ignored the unit multiplier, so 512MiB parsed as 512 bytes and the whole memory envelope was inert for anyone who wrote a unit. - finalize (EDNS0 and the UDP size) ran only on the cache-hit path, so a large uncached answer left oversized for a 512-byte client. It now runs on the upstream, local-zone and blocklist paths too. - The upstream UDP client read buffer was hard-coded to 1232 while we advertise dns.max_udp_size, so with a larger buffer configured every answer above 1232 bytes was read truncated and became SERVFAIL. The pool takes the size now. - LRU.prefetchGate was a 64-slot global cap, not the single flight its comment promised: a burst of stale hits launched up to 64 duplicate refreshes of one name. It is a per-key latch now; distinct names still refresh in parallel. - metrics.RecordMiss and RecordStaleHit moved only the Prometheus collector, so the Cache page's misses and stale hits read 0 for the life of the process. AGENTS.md gains the trap that cost the most time: this version of miekg/dns reports a character-string over 255 bytes as zero length, so such a message silently fails to pack, and the write failure looks like a client timeout.
This commit is contained in:
1 parent
48d37db15b
commit
4f49033f1b
12 files changed
+1837
-37
No files matched your search
@@ -144,6 +144,13 @@ partial result described as done is not.
|
||||
of the published ones" is a real property and cannot flake.
|
||||
- Spin up `dns.Server` fakes on `127.0.0.1:0`: `net.Listen`/`net.ListenPacket` to
|
||||
find the port, `ActivateAndServe` in a goroutine, stop in `t.Cleanup`.
|
||||
- A `dns.Msg` carrying a character-string over 255 bytes **does not pack** in
|
||||
miekg/dns v1.1.73: `TXT.len()` reports such a string as zero length and
|
||||
`EDNS0_NSID.len()` is likewise wrong, so `Pack` fails with "dns: overflow
|
||||
packing opt". On a fake upstream's write path that failure is silent and
|
||||
presents as a client timeout or a SERVFAIL several layers away. Build a
|
||||
multi-kilobyte answer out of many strings under 255 bytes, and assert the
|
||||
fake's write error before blaming the client.
|
||||
- `internal/app/integration_test.go` already builds a fully wired app. Reuse its
|
||||
harness rather than rebuilding one.
|
||||
- `tsc -b` replays **cached diagnostics** from `node_modules/.tmp/*.tsbuildinfo`.
|
||||
|
||||
Reference in new issue
Block a user