Skip to content

Testing

Zentri has four layers of tests. Go unit tests run with no database. Integration tests run the coordinator’s SQL on a real Postgres. End-to-end scripts drive the real binaries in Docker Compose. The web packages have their own unit, accessibility, Lighthouse and link checks.

Suite Command Needs
Go unit make test-go Go
Go integration make test-integration Docker, or a Postgres you name
End-to-end make e2e make build, Docker, git, curl, jq, openssl, python3, Node
OpenShell make e2e-openshell Docker with BuildKit, Go, git, curl, jq, openssl
Helm chart make lint-helm, make test-helm Go, and network the first time
Helm on kind make e2e-helm Docker, Go, git, curl, jq, openssl
Slack bot make test-slack-bot Node, pnpm
Web make test-web Node, pnpm, Google Chrome
Lighthouse make lighthouse Node, pnpm, Google Chrome

make test runs the Go unit, Slack bot and web suites, the installer tests and make test-helm. make lint includes make lint-helm.

Terminal window
make test-go

This runs go test -race ./... and the terminal kit’s smoke test, integrations/terminal/test.sh. The Makefile adds the tree-sitter build tags to every go command through GOFLAGS, so the tests build the same parser zentri ships.

Unit tests take their outside world as arguments. The CLI’s commands take stdio, the environment, the clock and the launcher from a Deps value. The coordinator reads time only from server/internal/clock, so a test moves a fake clock instead of sleeping.

Tests that need Postgres carry the integration build tag. Run them with:

Terminal window
make test-integration

scripts/test-integration.sh picks the database:

  • With ZENTRI_TEST_DATABASE_URL set, it uses that server. The role in the URL must be able to CREATE DATABASE and CREATE ROLE.
  • Without it, it starts a throwaway pgvector/pgvector:pg16 container on a random 127.0.0.1 port with a random password, and removes it at the end.

Each test gets a fresh, migrated database from server/internal/testdb. To run one package against your own database:

Terminal window
ZENTRI_TEST_DATABASE_URL=postgres://zentri:<password>@127.0.0.1:5432/zentri?sslmode=disable \
go test -race -tags=integration -count=1 ./server/internal/claims/

A go command given its own -tags drops the tree-sitter tags make sets in GO_TAGS. The script adds them back. A command you run by hand, as above, builds every grammar, which is slower.

Terminal window
make build
make e2e

make e2e runs one script per milestone. Each starts its own Compose project on its own ports with random passwords, and removes it at the end, so it never touches the make dev volumes. None needs a model, an agent or tmux. They use the offline hash embedder and fake programs where they need them.

Script What it drives
scripts/e2e-m0.sh The binaries, the Compose stack, /readyz, pgvector and the server image
scripts/e2e-m1.sh The coordinator over HTTP: Compose hardening, the bootstrap token, invites, sessions and claims
scripts/e2e-m2.sh Intent dedup through zt, for two engineers
scripts/e2e-m3.sh Two agent sessions on one file, through the real MCP shim and hooks
scripts/e2e-m4.sh The collision scenario and the merge check against a fake GitHub API
scripts/e2e-m5.sh Questions, decisions and approvals
scripts/e2e-m5b.sh The Slack bot against a fake Slack, and the model router

make e2e-openshell runs the stub agent in a real OpenShell sandbox. It is not part of make e2e. It downloads the OpenShell CLI and gateway and checks them against pinned hashes.

make e2e-helm installs the Helm chart on a throwaway kind cluster, zentri-e2e-helm. It is not part of make e2e. It builds the coordinator image from the checkout and loads it into kind, so it pulls nothing from GHCR. It installs with the evaluation Postgres and NetworkPolicies on, logs in with zt, checks the role the coordinator serves as and the Postgres policy, upgrades the release, and deletes the cluster. It took 80 to 90 seconds on a laptop with the images cached.

make lint-helm and make test-helm check the chart without a cluster. make lint-helm runs helm lint --strict, and kubeconform on each file in deploy/helm/zentri/ci/ for Kubernetes 1.35, 1.36 and 1.37. make test-helm renders values the chart must refuse and checks the security settings on every pod. helm, kubeconform and kind are built with go install at the versions the Makefile pins, into bin/tools.

make demo runs the M4 collision scenario on its own.

The site in web/site and the docs in web/docs each run these checks. make test-web builds both first.

Check Tool Rule
Unit Vitest Docs: every page has a title and a description, and no em dash. Site: no em dash or stray placeholder, the analytics setting, security.txt, the changelog loader, the terminal demo against the README, and that Lighthouse lists every page.
Accessibility Playwright with @axe-core/playwright, on the built output No WCAG 2.2 AA violation on any page, in light and dark mode, and no request to another host. Docs also checks each page at phone width, and that search finds a page.
Lighthouse Lighthouse CI, on the built output 95 or more in performance, accessibility, best practices and SEO
Links starlight-links-validator at build time, then linkinator over dist/ Every internal link and anchor resolves. External links are skipped.
Lint ESLint, astro check, Prettier No errors

The Playwright and Lighthouse runs use your installed Google Chrome, so nothing is downloaded. A small Node server serves dist/ on 127.0.0.1, port 4401 for the site and 4402 for the docs. Set E2E_PORT to move it, for example when two checkouts run at once:

Terminal window
cd web/docs
pnpm build
E2E_PORT=4490 pnpm test:e2e

The accessibility tests cover every page each package builds. The site’s list comes from its page registry and blog posts. The docs’ list is every index.html in dist/, so each new page, including each HTTP API operation, is checked without anyone adding it. Lighthouse covers every site page, and eight key docs pages listed in web/docs/lighthouserc.json.

ADR-0012, decision 3, makes the reference pages for the CLI, the server CLI, the MCP tools, the configuration, the environment and the metrics come from the code. A golden-file test in the package that owns each surface compares the page on disk with what the code produces:

  • make docs-gen sets ZENTRI_UPDATE_REFERENCE=1 and runs the tests named TestReferenceDocs, which rewrite their pages.
  • Without that variable, the test fails when the page is stale, and names the command to run.

make test and CI already run go test ./..., so a stale page fails CI with no extra job. Commit the rewritten pages with the code change that caused them. A test also fails when the code gains something its page would miss, such as a new metric or config field, and names what to add.

ADR-0012 renders the HTTP API reference from server/internal/api/openapi.yaml when the docs build. A Go test already fails when openapi.yaml and the route table drift.

Workflow When Runs
ci.yml Every pull request and push to main make test-go build-go, make lint-go lint-workflows, make test-integration on a Postgres service, make test-install, make lint-helm test-helm, shellcheck, the license-header check, the sign-off check, the Slack bot’s lint, test and build, and per web package: lint, test, build, test:e2e and Lighthouse
e2e.yml Every pull request and push to main make build e2e, and make e2e-helm in its own job
openshell.yml Pull requests and pushes to main that touch the Go code, the sandbox or Compose make e2e-openshell
codeql.yml Pushes to main and weekly CodeQL, skipped while the repository is private

The Go jobs use the Go version in go.mod, so the floor stays tested.

No tool checks coverage. Neither make nor CI runs with -cover, and no job fails on low coverage.

Unit tests alone show low numbers for packages whose logic is mostly SQL, such as claims, because their tests are integration tests. Measure such a package with both kinds:

Terminal window
go test -cover ./server/internal/overlap/
ZENTRI_TEST_DATABASE_URL=postgres://zentri:<password>@127.0.0.1:5432/zentri?sslmode=disable \
go test -cover -tags=integration -count=1 ./server/internal/claims/
  • Coverage is not measured or enforced.
  • Lighthouse covers eight key docs pages, not every page. Each run takes seconds, and the accessibility test already covers every page.
  • No vendor agent runs in any end-to-end test. They use fake agents or the stub agent.
  • The Slack bot has run only against a fake Slack.