The automated suite covers model validation, source ownership, cache concurrency, wire DNS, authenticated peers, mocked Kubernetes APIs, management endpoints and application lifecycle. It also checks the example Kubernetes manifest offline. Real cluster routing, production workload acceptance and long-duration recovery remain separate operational checks.
Regression coverage includes administration-namespace-only static CR reads/writes, generated sources across namespaces, optional ExternalIPBinding API installation after startup, multi-page binding lists, invalid/failed lists retaining last-good records and successful binding deletion. Offline RBAC checks verify that configuration permissions remain namespaced and generated source permissions remain read-only. Ingress tests cover multiple controllers, binding-backed targets, class opt-in, classless/legacy-class exclusions, ambiguous claims, wildcard and duplicate hosts, ignore cascading and live UDP/TCP CNAME resolution after address/annotation changes.
Run commands below from the repository root. The container runner requires Docker; the automated Go checks require Go 1.26 or newer. Go may need network access to download modules initially; tests use isolated loopback sockets and mocked Kubernetes/public DNS endpoints rather than a real cluster or public resolver service. Environments that prohibit loopback listeners must explicitly permit them for the integration tests.
Local container runner
With Docker available, use:
./test.sh
The script removes the existing named container with docker rm -f, builds the image
using the Dockerfile and runs it in the foreground. Ctrl+C stops it; --rm removes the
stopped container. It does not invoke Go or Node on the host. The image build compiles
the executable; run the automated checks below separately.
DNS UDP/TCP is available on 127.0.0.1:53, and the console/API on
http://127.0.0.1:80. The runner uses file mode, copies the sample configuration only
when config.json is absent, and preserves edits between runs. It mounts the
configuration directory writable, allowing atomic console saves, and runs as the
invoking user's UID/GID. The remaining root filesystem is read-only and all capabilities
are dropped. Container DNS uses port 53 under Docker’s container port policy; use
DNS_PORT/HTTP_PORT to choose alternate host ports.
| Variable | Default | Purpose |
|---|---|---|
NAME |
tak-os-dns |
Container to replace and run. |
IMAGE |
tak-os-dns:dev |
Image to build and run. |
CONFIG_DIR |
${TMPDIR:-/tmp}/${NAME}-config |
Host directory containing writable config.json plus its generated/reloadable TSIG file, seeded once. |
DNS_PORT |
53 |
Loopback host port for UDP and TCP DNS. |
HTTP_PORT |
80 |
Loopback host port for management HTTP. |
CLUSTER_ID |
dev |
Local cluster identity. |
DOMAIN |
example.com |
Required domain setting; file mode does not generate Kubernetes records. |
For example:
NAME=tak-os-dns-alt DNS_PORT=2053 HTTP_PORT=8081 ./test.sh
Choose a different NAME to avoid replacing an existing development container.
BUILD_IMAGE is no longer used: every run builds the image. Configuration in the
default temporary directory survives container replacement but may be removed by host
temporary-file cleanup; choose CONFIG_DIR for longer-lived data. For local Kubernetes
ingestion or a direct Go development process, see
running.
Standard checks
Run these separately with the Go toolchain and Node available:
go test -race ./...
go vet ./...
CGO_ENABLED=0 go build ./cmd/tak-os-dns
node --check internal/web/static/app.js
node scripts/ui-test.cjs
test -z "$(gofmt -l cmd internal)"
Race detection requires the supported platform toolchain and a C compiler; it is
distinct from the shipped CGO-disabled build. In Alpine CI the race job installs GCC and
musl development headers and uses CGO_ENABLED=1. The standalone build above writes
./tak-os-dns, which is gitignored; use -o /tmp/tak-os-dns when a temporary output is
preferable.
For a deliberately uncached suite or a focused regression:
go test -race -count=1 ./...
go test -race ./internal/peers -run 'TestServiceTransfer|TestMetadataAdvance|TestTransferBeyond' -v
go test -race ./internal/cache ./internal/dnsserver -v
go test ./deploy -v
go test -short ./... skips the bounded cache update soak but still includes network
integration tests. The prolonged listener soak is skipped unless its duration
environment variable is set, regardless of the ordinary suite.
Coverage by component
| Component | Exercised behaviour |
|---|---|
| Model | Nil/mismatched parser-result rejection, equivalent numeric/short DNS escape canonicalization, literal punctuation owners, idempotent normalization, canonical duplicates, allowed static/source types, wire-invalid RDATA rejection, optional SOA, standalone records, DNAME and address-compatible static CNAME definitions. |
| Cache | Shared addresses, contributor deduplication/removal, TTL retention, address masking/restoration, REFUSED unknown names, authoritative known-name NODATA with optional SOA, explicit-zone empty non-terminals versus unknown unzoned ancestors/bare apexes, wildcard synthesis, CNAME/DNAME chains, independent positives below parent delegation, parent-owned glue/referrals, parent/child isolation and caller-copy safety, lazy packet-budget response construction and bounded allocations for oversized direct/alias RRsets. |
| Cache concurrency | Coherent reads during source replacement, concurrent masking, watermark-only view reuse and coherent local publication stamps unaffected by imports. |
| DNS listeners | Actual UDP/TCP authoritative positives without zones, REFUSED unknown names even under SOA, authoritative NODATA for known missing types with/without SOA, standalone positives below delegation, RD-aware refusal versus iterative NS referral/glue, AXFR refusal, EDNS/BADVERS, complete-RRset truncation, compressed large answers, oversized TCP SERVFAIL and finite connection query counts. |
| Admission | Source-table LRU eviction without refusing every new client and preservation of active bucket state. |
| Peers | Signed full/delta exchange, pagination, retention/deletion, no re-export, identity/authentication, sticky ordered endpoints, stale-source rejection, unchanged-watermark advancement, selected forced-full transfers, NOTIFY, one-way credentials, live TSIG rotation, pending/self states and separate paginated topology. |
| Peer regressions | An L4 Service-style proxy selecting different backends/journals, one socket per transfer, metadata changes between pages, immutable token validation, prepared-delta survival after journal changes, cached no-rebuild continuations and transfers exceeding 100 pages, path-vector withdrawal/cycle suppression, stale topology from a different Service backend across receiver restart, peer-incarnation replacement, readiness after credential activation, quarantine persistence retries, optional-settings removal and metadata failure isolation from valid DNS imports. |
| Kubernetes | ExternalIP-only generation without mandatory zones, CR ownership/CRUD/status, bootstrap/discovery precedence, explicit/legacy rebootstrap recovery, semantic configuration identity despite changing list versions, persisted catalogue/route ordering, provenance paths and withdrawals, Secret create/update preservation, complete paginated lists, rotated token files, configured CA trust and rejected exec credentials. |
| Application | File/Kubernetes startup readiness, CR aggregate prevalidation, API reloads, three-site authenticated discovery, changing-read-watermark publication, invalid-record rejection/recovery, topology version propagation, UI/GitOps/ESO key reload/rotation, malformed-update retention, graceful shutdown and oversized-file preservation. |
| Web/telemetry | Resource/key/settings routes, conflict/security handling, private export, key-editor version capture across background polling, grouped mixed records, mocked public comparisons including DNAME, normalized TTL/order/domain-case comparisons, alias loops, bounded metric types and histogram buckets. |
These tests validate the implemented scenarios; the table is not a claim of complete RFC conformance or every possible network failure. The protocol and behaviour contracts are in DNS behaviour and peer protocol.
Offline Kubernetes manifest checks
deploy/manifest_test.go strictly parses the documents in deploy/kubernetes.yaml,
requires identifying fields and rejects duplicate kind/name resources. It verifies the
intended relationships and selected security/configuration properties:
- DNS Service TCP and UDP port 53, target-port names, nonempty external IPs and Cluster traffic policy (or its default) so nodes without DNS pods can forward.
- DaemonSet without host networking, matching Service/workload
selectors, required cluster identity/domain and matching
EXTIPS/Service IPs. - An internal management ClusterIP Service with the expected HTTP port.
- Referenced ServiceAccount, startup/liveness/readiness probe paths, read-only root filesystem, disabled privilege escalation and scrape annotation.
- Example DNSZone/DNSRecords objects and a settings-only ConfigMap rather than duplicated DNS config.json; no empty placeholder local TSIG Secret.
- CR lifecycle, status and Secret management RBAC, generated-source read-only permissions and ServiceAccount bindings.
- Three structural namespaced-resource CRDs in dns.tak-os.io/v1alpha1, including the PeerSite status subresource.
These checks do not call an API server, validate every Kubernetes schema field, exercise
the example Ingress, prove CNI/firewall routing or deploy the resources. Target-cluster
validation and every-node reachability remain in
capacity/acceptance and TODO.md.
Cache and listener benchmarks
go test -run '^$' -bench . -benchmem ./internal/cache
go test -run '^$' -bench BenchmarkBuildZones -benchtime=3s -benchmem ./internal/cache
go test -run '^$' -bench BenchmarkListener -benchtime=10s -benchmem ./internal/dnsserver
BenchmarkLookup measures parallel cached resolution. BenchmarkBuildZones measures
direct serving-view construction at 1,000 and 10,000 records, including zone-index
construction and streamed SOA fingerprints. It does not include network transfer or the
entire application refresh path.
BenchmarkListener has UDP and TCP sub-benchmarks that issue actual wire queries while
replacing the complete local source every five milliseconds. TCP sockets are reused for
80 requests before reconnecting. It reports queries/second, p50/p95/p99 latency and
source-update count; -benchmem adds Go allocation data. Each response must contain one
coherent eight-address RRset with valid authoritative flags, never a mixed or partial
generation.
The listener harness raises concurrency and query-rate/burst limits so ordinary admission does not determine the result. Its eight-record fixture is a repeatable regression workload, not production-sized data or an admission-policy stress test. Compare runs using the same machine, Go version, CPU allocation, record shape and update schedule; do not treat a local QPS number as a deployment SLA.
Opt-in listener soak
For a short smoke run:
TAK_DNS_SOAK_DURATION=3s go test ./internal/dnsserver -run TestListenerSoak -count=1 -v
TAK_DNS_SOAK_DURATION=3s go test -race ./internal/dnsserver -run TestListenerSoak -count=1 -v
For a prolonged run, choose a Go test timeout longer than the soak duration:
TAK_DNS_SOAK_DURATION=30m go test ./internal/dnsserver -run TestListenerSoak -timeout 35m -count=1 -v
The duration must parse as a Go duration of at least one second. The soak runs eight concurrent clients, alternating UDP and TCP, while replacing local snapshots every five milliseconds. It rejects malformed, mixed, duplicate or partial answers and reports QPS, latency percentiles, updates, goroutines and live heap before/after garbage collection. Latency storage is bounded to the latest 65,536 observations.
The built-in leak bounds allow at most 512 goroutines over baseline and 64 MiB of additional live heap after collection. They are deliberately generous regression bounds rather than deployment resource budgets. Expected socket deadline/cancellation at the requested end of the soak is not treated as a serving failure.
This harness does not simulate real Kubernetes API/change-detection outages, peer churn
or multi-node routing. The ordinary cache test TestSoakUpdates separately performs
1,000 coherent replacements and is skipped by -short; it is not a multi-hour soak. Use
the operational capacity guide for the broader acceptance
workload.
Container runtime smoke
For actual glibc and musl getaddrinfo behaviour against multiple configured
nameservers, run the separate resolver compatibility
harness. It exercises refusal/failure/negative responses,
competing answers, mixed address families and UDP-to-TCP fallback in an isolated Docker
network.
Build an image and run the opt-in harness:
docker build -t tak-os-dns:implementation-test .
IMAGE=tak-os-dns:implementation-test scripts/container-smoke.sh
The script requires Docker, curl and dig on the host. It starts a temporary container with a read-only root filesystem, all capabilities dropped, the sample configuration mounted read-only and file mode selected. A separate owner-scoped writable tmpfs hosts TSIG_FILE for automatic key creation while retaining the read-only root filesystem. Smoke keys are ephemeral. It uses container DNS port 1053 and random host ports bound only to loopback. It checks readiness, status, sample A answers over UDP/TCP, metrics and the console response, then removes the container through an exit trap.
The smoke verifies the scratch runtime with static file configuration. It does not exercise writes to that read-only file, Kubernetes API authentication/TLS, production port-53 privilege settings, Ingress authentication or external every-node routing. Those require their respective integration/operational checks.
CI and production acceptance
The implementation guide maps repository CI jobs to these commands. CI benchmarks use one-second runs; the long listener soak and container smoke are opt-in. The shared image/documentation release templates are separate from runtime acceptance.
Before production release, record deployment-specific QPS, p95/p99 latency, convergence
and memory targets. Exercise representative data/peer sizes, source changes, API/read
recovery, endpoint failure/recovery, replica restarts and external UDP/TCP queries
through every intended node. A multi-hour deployment soak must include those failure
modes and monitoring checks. Follow upgrades and retain
unexecuted acceptance work in TODO.md; automated local passes alone do not complete
it.
Console JavaScript contracts
node scripts/ui-test.cjs imports exported pure console helpers and asserts
resource-version/metadata preservation, path escaping, effective endpoint
precedence/self disabling, mixed-record array validation, TSIG private-bundle parsing
and weak-key descriptions. It also checks same-origin fetch configuration and avoidance
of dynamic innerHTML. CI runs this plus syntax checking in the node:22-alpine ui-check
job. These are helper/source contracts, not a real-browser DOM, accessibility, rendering
or end-to-end Kubernetes/Ingress test.
The production container smoke also checks the selected negative policy over UDP and TCP: a known A-only owner's AAAA query returns authoritative NOERROR with no answers, while a completely unknown name returns REFUSED without AA. Application integration covers creating a DNSRecords CR, observing known-name NODATA, then deleting that contribution and observing unknown-name REFUSED. These checks complement the libc harness; they do not imply target-cluster acceptance.
