Skip to content

Testing

HyperbyteDB has a multi-layered test strategy spanning unit tests, integration tests, compatibility suites, end-to-end cluster tests, and benchmarks.


Test Suite Inventory

Suite Location Scope Language
Unit tests src/**/*.rs (inline #[test]) Pure Rust logic, parsers, domain invariants Rust
Integration tests tests/integration.rs In-process Axum app with real RocksDB/chDB stack Rust
Raft integration tests/raft_integration.rs Multi-node cluster setup, membership, replication log Rust
Compatibility suite tests/compat/ InfluxDB v1 HTTP/DDL/query compatibility Rust
End-to-end tests/e2e/ Multi-node cluster, failover, rolling restart, replication Go
Load/query scripts tests/load.sh, tests/load.js, tests/query.js Ad-hoc load and performance testing Shell/JS
Benchmarks benches/ Ingestion throughput (line protocol + columnar) Rust (Criterion)
WalPort contract tests/wal_port_contract.rs MemoryWal (sim) vs. RocksDbWal observational equivalence under a seeded op stream Rust
HyperSim (DST / VOPR) ../hypersim/ 100 deterministic cluster simulations per PR; fault injection, invariants, replay Rust

Running Tests

Unit tests

cargo test --lib

Runs all inline #[test] functions in src/. Fast, no external dependencies.

Integration tests

cargo test --test integration
cargo test --test raft_integration

These tests start an in-process HyperbyteDB server with real RocksDB and chDB. They create temporary directories and clean up after themselves.

Compatibility tests

cargo test --test compat

The tests/compat/ directory contains a comprehensive InfluxDB v1 compatibility suite:

File Tests
write_tests.rs Line protocol writes, precision, gzip, error responses
query_tests.rs SELECT queries, aggregates, GROUP BY, fill modes
ddl_tests.rs CREATE/DROP DATABASE, retention policies
metadata_tests.rs SHOW commands
http_tests.rs HTTP behavior (headers, status codes, content types)
error_tests.rs Error response formatting
concurrent_tests.rs Concurrent read/write safety

All Rust tests

cargo test

Tests with features

cargo test --all-features

Run this when touching columnar-ingest or other feature-gated code paths.

End-to-end tests (Go)

cd tests/e2e
go test -v -timeout 5m

These tests require running HyperbyteDB instances. They test cluster scenarios: - cluster_test.go — Multi-node basic operations - drain_test.go — Graceful drain procedure - failover_test.go — Node failure and recovery - raft_test.go — Raft consensus behavior - replication_test.go — Write replication - rolling_restart_test.go — Rolling restart safety - sync_test.go — Data synchronization

Benchmarks

# Line protocol ingestion benchmarks
cargo bench --bench ingestion_line_protocol

# Columnar ingestion benchmarks (requires feature)
cargo bench --bench ingestion_columnar --features columnar-ingest

Criterion generates HTML reports in target/criterion/.

WalPort contract test

cargo test -p hyperbytedb --features sim --test wal_port_contract

This test runs an arbitrary, seeded sequence of WalPort operations against both MemoryWal (simulation-only, behind --features sim) and the real RocksDbWal, and asserts their outputs are byte-for-byte identical after every step. It is the semantic bridge between the HyperSim simulator and the production WAL adapter: any divergence caught here means a HyperSim finding might not transfer to production, or a production behavior is not being exercised under simulation. See hypersim/README.md § 8 for the rationale.

HyperSim (deterministic simulation)

# Full 100-run suite (release build, ~5m on 8 cores).
make hypersim-validate

# Fast developer loop (10 runs, debug build).
make hypersim-validate-dev

# Single run with a chosen seed.
cargo run --release -p hypersim --bin hypersim -- vopr-safety \
    --seed 0xDEADBEEF --virtual-hours 1

HyperSim is the TigerBeetle-style DST framework; see hypersim/README.md for architecture, fault model, invariants, and replay tooling. CI runs the 100-run suite on every PR.


Writing Tests

Unit tests

Add tests inline in the source file:

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_something() {
        let result = my_function("input");
        assert_eq!(result, expected_output);
    }
}

Integration tests

Integration tests use a shared test harness that starts an in-process server:

// tests/integration.rs
use hyperbytedb::bootstrap::build_services;

#[tokio::test]
async fn test_write_and_query() {
    let app = setup_test_app().await;
    // Write data via the HTTP handler
    // Query and verify results
}

Compatibility tests

Follow the patterns in tests/compat/. Each test module focuses on a specific feature area and verifies InfluxDB v1 behavioral compatibility.


Test Architecture

In-process testing

Integration and compat tests run an in-process Axum application. This avoids the overhead of starting a separate process and allows direct access to internal state for assertions.

The test harness: 1. Creates temporary directories for WAL, metadata, data, and chDB. 2. Builds services via build_services(). 3. Constructs the Axum router. 4. Sends HTTP requests directly to the router (no network I/O). 5. Cleans up temporary directories on drop.

Cluster testing

Cluster tests (Raft integration, Go e2e) require multiple server instances. The Go tests in tests/e2e/ manage the lifecycle of multiple HyperbyteDB processes, waiting for health checks before running scenarios.


CI Test Matrix

The CI pipeline (.github/workflows/ci.yml) runs:

Job Command Dependencies
Format cargo fmt --all --check Rust toolchain + rustfmt
Clippy cargo clippy --all-targets -- -D warnings Rust toolchain + clippy + libchdb
Unit tests cargo test --lib Rust toolchain + libchdb
Integration tests cargo test --test '*' Rust toolchain + libchdb
Release build cargo build --release Rust toolchain + libchdb
HyperSim hypersim validate --runs 100 --mode mixed Rust toolchain + libchdb
WalPort contract cargo test -p hyperbytedb --features sim --test wal_port_contract Rust toolchain + libchdb

All jobs install system dependencies (clang, llvm-dev, libclang-dev, pkg-config, libssl-dev) and libchdb via curl -sL https://lib.chdb.io | bash.


See Also