diff options
| author | Brad Fitzpatrick <bradfitz@tailscale.com> | 2026-04-14 00:01:36 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <brad@danga.com> | 2026-04-13 17:20:43 -0700 |
| commit | a97850f7e22b96466ec2f432f9cc6c3b1e0f64f3 (patch) | |
| tree | 80d9260ed816e63635557040017e06807289d6be /control/controlhttp/controlhttpserver/controlhttpserver.go | |
| parent | 7dcb378875bff846904d4c5c3252debc88900683 (diff) | |
| download | tailscale-a97850f7e22b96466ec2f432f9cc6c3b1e0f64f3.tar.xz tailscale-a97850f7e22b96466ec2f432f9cc6c3b1e0f64f3.zip | |
cmd/derper: fix TestLookupMetric to pass when run alone
TestLookupMetric was added in e8d140654 (2023-08-17) without
initializing the dnsCache and dnsCacheBytes globals. When run in
isolation, handleBootstrapDNS writes a nil body (from the
uninitialized dnsCacheBytes), causing getBootstrapDNS to fail
decoding an empty response with EOF.
Add a setDNSCache test helper that stores the dnsEntryMap, marshals
dnsCacheBytes, and registers a t.Cleanup to nil both out, so tests
that forget to call it will hit the dnsCache-nil fatal in
getBootstrapDNS rather than silently depending on prior test state.
Also add AssertNotParallel and a dnsCache-nil fatal check to
getBootstrapDNS, the central helper all bootstrap DNS tests flow
through, to prevent future tests from running in parallel (they
all mutate package-level DNS caches and metrics) and to give a
clear error if a test forgets to initialize the DNS caches.
Fixes #19388
Change-Id: I8ad454ec6026c71f13ecfa14d25925df5478b908
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Co-authored-by: Avery Pennarun <apenwarr@tailscale.com>
Diffstat (limited to 'control/controlhttp/controlhttpserver/controlhttpserver.go')
0 files changed, 0 insertions, 0 deletions
