Skip to main content

Testing

The pyramid as it is on this branch: a pure domain under a mutation gate, use cases and adapters with unit and httptest tests, a godog suite over the real use cases, testcontainers integration tests against real Postgres and Kafka, architecture fitness tests, and spec linting. Counts come from grep '^func Test' per package and grep -c Scenario per feature file; many tests are table-driven, so the number of cases is larger. They were counted from the source, not from a test run.

LayerCount / thresholdCommand
Unit, domain85 top-level tests in 5 packages: node 53, servicearea 11, lane 11, region 6, shared 4make test
Unit, application50: usecases 39, views 11make test
Unit and httptest, adapters and cmd/*REST adapter 36, MCP 15, A2A 16, request log 4, Kafka encoder, writer, health and relay sink 18, kafka/cloudevents 6, outbox relay 11, Postgres adapter units 27, telemetry 11, memory 4, cmd/api 20, cmd/mcp 11, cmd/a2a 15, bootretry 5, ids and clock 2make test
Coverage gate90% over ./internal/domain/...,./internal/application/... (COVERAGE_PKGS in the Makefile)make coverage
BDD (godog / Gherkin)15 feature files in features/, 237 Scenario and Scenario Outline definitions, run as 363 scenarios (see below)make bdd
Integration (testcontainers)20 files with //go:build integration holding 56 top-level functions, including the TestMain bootstrapsmake integration
Architecture fitness35 top-level tests in 13 files of internal/architecturemake arch-test
Mutation (gremlins)efficacy 90, mutant coverage 90 (.gremlins.yaml), on every package under internal/domain/make mutation, make mutation-full
Spec linting (Spectral)apis/openapi.yaml and apis/asyncapi.yaml, --fail-severity=warnCI api-lint
Chart testscharts/node-topology/tests/render_test.sh and test_service_selectors.pyCI chart-tests
Console remoteweb/: lint, tsc -b, vitest, buildCI web
Contract (schemathesis)none: no schemathesis configuration and no CI jobnone
Evalsnone: EVALS.md is the harness template's note and measures nothing in this repositorynone

Make targets​

Every target mirrors a CI job. The Makefile is the only definition of the coverage scope and the mutation package list.

TargetRunsNotes
make helpprints the target listdefault target
make buildgo build ./...compiles the three binaries
make vetgo vet ./...
make fmt / make fmt-checkgofmt -w . / fail if gofmt -l . is non-empty
make lintgolangci-lint run --allow-parallel-runners ./...pinned v2.14.0, config .golangci.yml
make testgo test ./... -raceunit, httptest and the godog suite (a normal Test function); no Docker
make coveragego test ./... -race -coverprofile=coverage.out -coverpkg=./internal/domain/...,./internal/application/..., then the 90% gatethe CI test job runs exactly this
make arch-testgo test ./internal/architecture/... -v
make bddgo test ./... -run TestFeatures -vthe godog suite, features/features_test.go
make integrationgo test -tags=integration ./... -race -count=1needs only Docker; every test boots its own Postgres and Kafka; not part of check
make mutationgremlins unleash <pkg> for each ./internal/domain/*/the fast, blocking gate; the shell glob gates a new domain package the moment it exists
make mutation-fullgremlins unleash ./internal/domain --workers 1 --timeout-coefficient 30the exhaustive scheduled run
make vulngovulncheck ./...
make checkfmt-check vet build lint testthe pre-push hook runs this
make check-allcheck plus coverage arch-test bddrun before pushing
make check-fastfmt-check vet arch-test plus go test of the packages changed since HEADthe agent Stop hook
make guide-lint / make harness-testscripts/harness/guide_lint.py / scripts/harness/test_hook.pyagent-guide checks, not product tests

Run one package or one test:

go test ./internal/domain/lane -run TestAllowedPairsPinTheModel -v
go test ./internal/application/usecases -v

Unit tests​

  • Domain (node, lane, servicearea, region, shared): pure, standard library only. They pin the rows of the model tables (TestTypeRulesPinTheModel, TestAllowedPairsPinTheModel), the node state machine, the immutable profile revisions, the lane and service-area invariants and the raised events.
  • Use cases (internal/application/usecases): run against the in-memory adapters, which are test doubles only; the shipped binaries never import them (runtime_no_memory_fitness_test.go enforces it). register_metrics_test.go pins the topology.nodes.registered outcomes.
  • REST adapter: httptest over the real router; routes_test.go, middleware_test.go, idempotency_test.go, errors_test.go and telemetry_test.go.
  • MCP and A2A: tools_test.go pins the tool surface, governance_test.go fails the build on a write-verb tool name; skills_test.go and card_test.go cover the two skills and the Agent Card.
  • Outbox and Kafka: relay cap and ordering with a fake store (relay_test.go), the encoder and CloudEvents helpers.
  • cmd/*: environment parsing and boot configuration, shutdown order and telemetry set-up.

BDD (godog)​

features/ holds fifteen .feature files and the step definitions beside them; the repository root holds no Go file (TestNoGoFilesAtRepoRoot).

Feature fileScenario blocks
http_api.feature28
lanes.feature27
profile_rules.feature26
rest_contract_rules.feature21
node_registration.feature17
service_area_region_rules.feature17
service_areas.feature17
operational_profile.feature15
registration_rules.feature14
lane_rules.feature13
node_lifecycle_rules.feature13
inbound_limits.feature11
suspension.feature9
regions.feature7
http_idempotency.feature2

The runner wires the real use cases over the in-memory adapters, so the suite is fast and needs no Docker. The blocks are counted by git grep -c -E "^[[:space:]]*Scenario" -- features (237 in total); the runner executes them as 363 scenarios because the Examples rows of the outlines expand (the 363 scenarios (363 passed) line of go test ./features -run TestFeatures -count=1 -v, which is the one count on this page taken from a test run). The six *_rules.feature files (node_lifecycle_rules, profile_rules, registration_rules, lane_rules, service_area_region_rules, rest_contract_rules) pin the rules the context's documentation states; the others come from the OpenAPI and the ADRs.

Integration (testcontainers)​

All files carry //go:build integration and boot their own containers through internal/testing/pgtest and internal/testing/kafkatest. A missing Docker is a failure, never a skip; TestPostgresIntegrationTestsUseTestcontainers and TestKafkaIntegrationTestsUseTestcontainers fail the build if a test gates on DATABASE_URL or hard-codes a broker.

SuitePackageWhat it covers
Real wiringcmd/api (TestRealWiring)the real entry point on real Postgres and Kafka
MCP and A2A against Postgrescmd/mcp, cmd/a2aeach reads what the api wrote and never writes
Repositories and contractoutbound/postgresthe repository contract suite (internal/adapters/outbound/repocontract), unit-of-work rollback, concurrency, migrations apply and re-run, schema constraints on idempotency_keys and outbox_events, trace headers on outbox rows
Drainoutbound/postgres (drain_integration_test.go)publish in id order, batch limit, stop at first failure, the attempt cap, concurrent drains never send a row twice
Outbox relayoutbound/outboxthe exact CloudEvents published for the outbox rows
Idempotencyinbound/httpkeyed writes over real Postgres

make integration and the CI integration job run the same command, go test -tags=integration ./... -race -count=1.

Mutation testing​

.gremlins.yaml sets workers: 1, timeout-coefficient: 30 and the thresholds efficacy: 90 and mutant-coverage: 90. Gremlins fails when the measured value is less than or equal to the threshold, so a threshold must sit strictly below what the code achieves. Only the domain is mutated. mutation-fast loops over each package under internal/domain/ on every push and pull request; the scheduled mutation job runs ./internal/domain as a whole and the drift job runs scripts/coverage-quality.py to flag functions with high line coverage and a surviving mutant. A failing scheduled run opens or refreshes a harness:red issue. This page records no measured mutation score, because none was run for it.

Architecture fitness tests​

internal/architecture holds the dependency-direction rule (TestHexagonalArchitecture) and source-scanning sensors. Examples: TestMCPAdapterDependencyRule, TestA2AAdapterDependencyRule, TestA2ADepsHoldReadUseCasesOnly and TestNoOutboundA2AClient keep MCP and A2A read-only and inward-looking; TestNoAuthMiddlewareReintroduced keeps the surface unauthenticated; TestEventCatalogueMatchesContract ties the code's event types to the contract; TestCloudEventsOnly and TestNoEventEnvelopeToggleOrFlatEnvelope pin the envelope; TestOutboxRelaysPassAttemptCap, TestKafkaWritersSetRequiredAcks and TestKafkaWriterTopicNotSetTwice pin the producer; TestRuntimeBinaryHasNoInMemoryAdapters and TestRuntimeBinaryDoesNotImportTheRepositoryContract keep test doubles out of cmd/**. Sensors that scan source come with a test that proves they can fail (...SensorBites, ...SensorFailsOnBadFixtures).

make arch-test

CI jobs​

.github/workflows/ci.yml runs on push and pull request to main and develop, weekly (Monday 06:00 UTC) and on manual dispatch.

JobRunsWhen
lintgolangci-lint v2.14.0, --timeout=5malways
guide-lintscripts/harness/guide_lint.py and test_hook.py; advisory (continue-on-error)always
complexitygolangci-lint with only gocyclo,gocognit,cyclop,funlen,nestif, plus an informational gocyclo reportalways
testgo build, go vet, then make coverage (90% gate); uploads coverage.outalways
bddgo test ./... -run TestFeatures -valways
integrationgo test -tags=integration ./... -race -count=1always
mutation-fastgremlins v0.6.0 on each ./internal/domain/*/always; blocking
mutationgremlins unleash ./internal/domain --workers 1 --timeout-coefficient 30; harness:red issue on a scheduled failureschedule and dispatch
driftdeadcode, go mod tidy -diff, knip in web/, coverage-quality; advisoryschedule and dispatch
api-lintSpectral on both specs, --fail-severity=warnalways
vulngovulncheck ./...always
helm-lintct lint --charts charts/node-topology and test_service_selectors.pypull requests only
chart-testsevery charts/node-topology/tests/*.sh and test_*.py; a test that prints SKIP fails the jobalways
arch-testgo test ./internal/architecture/... -valways
webthe console remote: npm run lint, npx tsc -b, npm test, npm run buildalways
docker-publishbuild and push ghcr.io/iqvo/node-topology, cosign signature, SBOM; needs the jobs abovepush to main
releasetags the next patch version, retags the image, packages and pushes the Helm chart, creates the GitHub releasepush to main, after docker-publish

.github/workflows/docs.yml builds this site (npm ci, npm run build in docs/) on pull requests and deploys to GitHub Pages only on push to main. .github/workflows/ai-review.yml is an advisory review on pull requests. Jobs that show as skipped on a pull request (mutation, drift, docker-publish, release) are gated by their if: conditions; that is expected.

ci.yml has no job that regenerates the REST reference and fails on a diff: after any change to apis/openapi.yaml, run npm run clean-api-docs and npm run gen-api-docs in docs/ yourself.

Reproducing the docs build​

cd docs
npm ci
npx tsc --noEmit -p .
npm run build

The build fails on a broken link or anchor. Mermaid diagrams are checked with scripts/validate-mermaid.cjs of the warehouse-docs repository, because docusaurus build alone never catches a broken diagram.