Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Testing

This page shows how to run Chassis’s tests, what each suite checks, and what CI runs, so you know which tests cover a change and where a new one belongs. Verification has what the tests show, and what none of them covers yet.

Running

# Every Rust test in the workspace
cargo test --workspace --all-features

# One suite
cargo test -p chassisdb --test crash_tests

# The random-history test with many more histories (12 by default)
CHASSIS_MODEL_SEEDS=2000 cargo test -p chassisdb --release --test model_tests

Run the slower suites (crash_tests, model_tests, batch_tests) in release when you run them often: a debug build computes distances many times slower.

The Python package, the MCP server and the LangChain integration test against the C library in target/release. The Python package’s tests need its dev extras, which include pytest-cov:

cargo build --release -p chassis-ffi
pip install -e "./chassisdb[dev]"

(cd chassisdb && CHASSIS_LIB_PATH=../target/release PYTHONPATH=. pytest)
(cd chassisdb-mcp && pip install -e ../chassisdb -e . && python -m pytest tests)
(cd integrations/langchain-chassisdb && pip install -e ../../chassisdb -e . && python -m pytest tests)

Suites

The Rust suites are in chassis-core/tests; each file says at its top what it checks.

SuiteWhat it checks
index_integrationVectorIndex end to end: open, add, delete, search, flush, reopen
storage_testsThe file: the lock, growth, commits and reopening
graph_io_tests, link_testsNeighbor lists on disk, and linking with the diversity heuristic
search_testsSearch: results, ordering, edge cases
batch_testsadd_batch on every core builds a graph as good as one built a vector at a time
filter_testsFiltered search returns only allowed ids, and the nearest of them
metric_testsCosine ranking and distances match brute force; the metric is the file’s
half_precision_testsHalf precision finds what brute force over the rounded vectors finds
compaction_testscompact() keeps every vector under its id and drops the deleted ones
migration_testsOpening a format 1 or 2 file migrates it to format 3
compat_testsFiles written by earlier releases (tests/compat) open, search as they did, and take writes
duplicate_testsMany exact copies of a vector leave every other vector reachable
reader_testsReaders in other processes, while a writer changes the file
crash_testsA writer killed at random points: every reopen shows exactly the last flush
model_testsRandom sequences of every write, checked against a model of what the index should hold
error_testsEach mistake gets its error kind, its values and a help: line
warm_tests, huge_pages_tests, fork_testswarm, huge pages, and a forked child dropping an index its parent was reading in
compile_failCode that would let a vector outlive its borrow doesn’t compile (tests/ui)

Unit tests sit next to the code they test. Among them, power_loss.rs stands in for a power loss at every fsync of every operation. It builds the files a power loss could leave, with each 512-byte sector as last synced, as last written, or torn between the two, and checks that each one reopens to the last flush or the one in progress.

The Python tests are in chassisdb/tests: the bindings, every error, and the code agents copy, which they run: the agent skill’s Python blocks and the examples.

CI

WorkflowWhat it runs
CIcargo test --all-features on Linux x86-64 and ARM64, macOS and Windows, with stable Rust and 1.89; the in-memory tests under Miri; the AVX-512 kernel’s and search loop’s under Intel SDE; the Python tests on Python 3.11 with numpy 1.26 and on 3.14; the MCP and LangChain tests; cargo fmt, cargo clippy -D warnings, cargo doc; ruff, black and mypy
MSRVcargo check and cargo test on Rust 1.89
Coveragecargo llvm-cov on Linux
FuzzDamaged files and any bytes, opened and changed: a minute per target on each pull request, half an hour each night
FilesystemsThe core’s tests with their files on tmpfs, XFS, Btrfs, exFAT and NFS on Linux, exFAT on macOS, and an SMB share, exFAT and ReFS on Windows
BuildThe C library and the Python wheels for Linux x86-64 and ARM64, macOS and Windows
BenchmarkEach pull request against main, on Linux x86-64 and ARM64 (Benchmarking)

compile_fail runs only on stable: it compares rustc’s error text, which changes between releases.

Writing tests

  • Put each index in a temporary directory (tempfile::tempdir()), never a fixed path.
  • Make random data deterministic: seed it, as model_tests.rs does with its own xorshift.
  • To test a crash, run the writer in a child process and kill it, as crash_tests.rs does.
  • When a test checks recall, which varies with thread timing, check it over many queries with a margin, not one query exactly.