#!/bin/sh # script/test: run the test suite. # # -count=1 disables Go's test cache, and is load-bearing here. This # suite queries live DNS on every run by policy (TESTING.md); a cached # result is a replay of an earlier run's output with no query made at # all. On an unchanged tree the whole suite would return success in # under a second having resolved nothing, which makes the repeated-run # green that is used as evidence for flakiness fixes worthless. Do not # remove it. # # Conditional verbose rerun per REPO_POLICIES.md: run quiet first so # CI and docker build logs stay readable, and rerun with -v only on # failure. The rerun also carries -count=1 (a cached replay of the # failure would show nothing new), and the exit status is forced to 1 # no matter how the rerun ends: the first failure already proved the # suite broken, so a flaky test that passes the second time must not # turn the build green. # # -timeout 90s is a deliberate backstop above the 60s hard cap on # suite duration. Do not lower it. # # -p 1 runs one test package at a time, and is load-bearing. Live DNS # is a resource outside the process: the concurrency gates that keep # this suite from bursting at the root servers # (internal/resolver/livedns_test.go, internal/watcher/watcher_test.go) # are package-scoped, so each one only bounds its own test binary. Go # runs package binaries in parallel by default, so with both live-DNS # packages in flight at once their gates sum instead of holding, the # root and TLD servers rate-limit the excess, and the resolver # package's per-attempt deadlines expire. Serialising packages is what # makes each gate authoritative while its package runs. set -eu ROOT="$(cd "$(dirname "$0")/.." && pwd -P)" main() { cd "$ROOT" go test -count=1 -p 1 -race -timeout 90s -cover ./... || { echo "--- Rerunning with -v for details ---" >&2 go test -count=1 -p 1 -race -timeout 90s -v ./... || true exit 1 } } main "$@"