Skip to content

Development and Testing

Mohammad Rasoul Kazemi edited this page Nov 26, 2026 · 3 revisions

Development and Testing

No CI on GitHub Actions

KingresDB does not use GitHub Actions: Actions is off for the repository, and no workflow is published. Every check runs on a developer's machine, and the maintainers check pull requests locally. This is a decision of the project owner. The packaging README says the same for its artifact tests.

Rules

From testing.md:

  1. Every phase deliverable includes tests; a phase is not finished while its features have no tests.
  2. A bug fix starts with a test that fails without the fix.
  3. Tests do not depend on the developer's machine: no fixed ports, no fixed paths outside the test's temporary directory, no network except to servers the test starts.
  4. A flaky test is a bug. Fix it or remove it; do not retry until it passes. (A TAP file that fails is rerun alone before it is called a real failure, because the timing-dependent tests of kingres_shard can fail on a loaded machine; a failure that repeats is a defect.)

Test layers

The strategy behind the layers is on Testing Strategy.

Layer Tool Where
Extension, single server (SQL interface, error codes, GUCs, upgrade) pg_regress contrib/kingres_*/sql/ and expected/
Extension, processes and WAL (crash recovery, standbys, background workers) PostgreSQL TAP tests contrib/kingres_*/t/
Multi-node (routing, 2PC recovery, bucket moves, failover) TAP tests that start several clusters contrib/kingres_shard/t/
Ledger pg_regress and TAP; Go tests of the verifier extension and kingres/verifier/
Control plane, unit go test *_test.go next to the code
Control plane, integration go test against real instances, three-kingresd cluster tests kingres/control-plane/
API contract npm run check in kingres/api; contract tests on both sides kingres/api, kingres/control-plane, kingres/web
Web Vitest, a real-browser suite, an end-to-end run kingres/web
Packaging Debian package (test-deb.sh), image (test-image.sh), three-node compose cluster (test-compose.sh), the verifier package and the release script (test-verifier-package.sh, test-release.sh); the package and image tests run once per major kingres/packaging/test/

For C code run the tests on a build with assertions enabled; build.sh configures one. Every extension has a test that loads another module using the same hook, and an upgrade test from the oldest supported version.

Commands

Server and extensions

See Building from Source. In short:

kingres/dev/build.sh all                 # server: build, install, core regression suite
kingres/dev/build.sh sync build test-all # every suite, including TAP
kingres/dev/ext.sh kingres_shard all     # one extension against one installation
KINGRES_PG18=<install> KINGRES_PG19=<install> kingres/dev/ext-majors.sh kingres_shard

A change to an extension is complete only when ext-majors.sh passes on both majors, with warnings as errors.

Control plane (Go)

From kingres/control-plane:

go vet ./...
gofmt -l .                          # must print nothing
golangci-lint run ./...
go test ./...                       # unit tests; integration tests skip without a database
CGO_ENABLED=1 go test -race ./...   # needs a C compiler on PATH

Integration tests run against real PostgreSQL instances when KINGRES_PG_BIN is set. On Windows, scripts/run-integration.ps1 builds the test binaries for Linux, copies them into WSL2 and runs them there with scripts/run-wsl-tests.sh against a private installation. Its parameters include -Packages (one or several packages), -Run (a test name pattern), -Race, -Count (repeat the selected tests), -Install (an installation of another major, so the same suite runs on 18 and 19) and -Lane (runs of one lane queue behind each other; runs of different lanes run side by side, each with its own staging area and installation). KINGRES_TEST_KEEP=1 keeps the directories of a run for a post-mortem. After openapi.yaml changes, regenerate the operation table with go generate ./internal/contract; a test fails while it is stale.

Verifier

From kingres/verifier: go test ./... (needs no database; the fixtures are checked in). There are scripts for generating fixtures (scripts/gen-fixtures.sh), for fuzzing (scripts/fuzz.sh), for checking that two builds of the release files are byte for byte the same (scripts/repro-check.sh) and for making the signed release (scripts/release.sh, see Release Process).

API contract

From kingres/api: npm run check (the contract checks) and npm run lint.

Web console

From kingres/web:

npm run typecheck
npm run lint            # ESLint and prettier --check
npm test                # Vitest, also checks that generated API files and brand files are current
npm run test:browser    # layout, keyboard, axe and the CSP, in a real Chrome or Edge
npm run e2e             # needs Windows with WSL2, Go and Chrome or Edge; run it when the machine is free

C formatting

New C code is formatted with the tree's pgindent, using src/tools/pgindent/typedefs.list; the code should look like PostgreSQL C code. Every GUC carries the extension's prefix, and every error has a specific SQLSTATE and a test that asserts it. The rules per language are in coding-standards.md.

Definition of done

A change is done when: it has tests at the right layer and the relevant suites pass locally; the formatters and linters pass; the documentation is updated; any change to an upstream file has a row in the core-patches register; and a dated entry in the work log records what was done, how it was verified and what is still open.

Reviews, mutants, fuzzing

Independent reviews, one-line mutants, fuzzing of the verifier and comparison of generated statements with a single node are part of how the project is checked, not of a pipeline. They are described on Review Process and Testing Strategy; the reports are in kingres/docs/reviews. The state of the reviews is on Status and Roadmap and Limitations and Known Issues.

Shared machines and resources

  • The control plane's integration script takes a system-wide Windows mutex per lane, so runs of the same lane by several people on one machine queue behind each other (Testing Strategy); give each lane its own installation (-Install) when the extensions differ.
  • Each test run uses its own private copy of a PostgreSQL installation, because ext.sh installs extensions into the installation it is given.

Where to go next

Repository Layout (where code goes), Coding Standards, Branching and Synchronisation, Release Process, Contributing.

Sources

Clone this wiki locally