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

Integration Tests

The integration test suite validates cross-engine functionality, data flow, and system behavior. All tests use a shared TensorStore to verify that relational, graph, and vector engines work correctly together.

Test Count: 267+ tests across 22 files

Running Tests

# Run all integration tests
cargo test --package integration_tests

# Run specific test file
cargo test --package integration_tests --test persistence

# Run single test
cargo test --package integration_tests test_snapshot_preserves_all_data

# Run with output
cargo test --package integration_tests -- --nocapture

Test Categories

CategoryTestsDescription
Persistence9Snapshot/restore across all engines
Concurrency10Multi-threaded and async operations
Cross-Engine10Data flow between engines
Error Handling10Proper error messages
Delete Operations7Cleanup and consistency
Cache Invalidation7Cache behavior on writes
FIND Command7Unified query syntax
Blob Lifecycle7GC, repair, streaming
Cache Advanced6TTL, semantic, eviction
Vault Advanced8Grants, audit, namespacing
Edge Cases10Boundary conditions
Tensor Compress10Quantization, delta, RLE encoding
Join Operations10Hash-based relational JOINs
HNSW Index13Approximate nearest neighbor search
Vault Versioning17Secret history and rollback
Index Operations18Hash and B-tree indexes
Columnar Storage20Columnar scans, batch insert, projection
Entity Graph API18String-keyed entity edge operations
Sparse Vectors22Sparse vector creation and similarity
Store Instrumentation15Access pattern tracking
Tiered Storage16Hot/cold data migration
Distance Metrics17COSINE, EUCLIDEAN, DOT_PRODUCT similarity

Test Helpers

Available in integration_tests/src/lib.rs:

Helper FunctionPurpose
create_shared_router()Creates QueryRouter with shared TensorStore
create_router_with_vault(master_key)Router with vault initialized
create_router_with_cache()Router with cache initialized
create_router_with_blob()Router with blob store initialized
create_router_with_all_features(master_key)Router with vault, cache, and blob
sample_embeddings(count, dim)Generates deterministic test embeddings using sin()
get_store_from_router(router)Extracts TensorStore from router
create_shared_engines()Creates (store, relational, graph, vector) tuple
create_shared_engines_arc()Same as above but wrapped in Arc for concurrency

Key Test Suites

Persistence Tests

Tests snapshot/restore functionality across all engines.

TestWhat It Tests
test_snapshot_preserves_all_dataAll engine data survives snapshot/restore
test_snapshot_during_writesConcurrent writes don’t corrupt snapshot
test_restore_to_fresh_storeSnapshot loads into new TensorStore
test_compressed_snapshot_roundtripCompression works for vector data
test_snapshot_includes_vault_secretsVault secrets persist in snapshot

Lessons Learned

  • Cache is intentionally ephemeral (internal DashMaps)
  • Vault secrets ARE persisted (encrypted in TensorStore)
  • Bloom filter must be re-initialized with same parameters on restore

Concurrency Tests

Tests multi-threaded and async access patterns.

TestWhat It Tests
test_concurrent_writes_all_engines6 threads write to relational/graph/vector simultaneously
test_shared_store_contention4 threads write same key 1000 times each
test_reader_writer_isolationReads during heavy writes
test_blob_parallel_uploads10 concurrent blob uploads with barrier sync

Lessons Learned

  • DashMap provides excellent concurrent write performance
  • Node IDs are NOT guaranteed sequential - must capture actual IDs
  • Blob operations require tokio::sync::Mutex for shared access
  • HNSW search is thread-safe during concurrent writes

Cross-Engine Tests

Tests data flow and operations across multiple engines.

TestWhat It Tests
test_unified_entity_across_enginesSingle entity with data in all 3 engines
test_graph_nodes_with_embeddingsGraph nodes linked to vector embeddings
test_insert_embed_search_cycleINSERT -> EMBED -> SIMILAR workflow
test_query_router_cross_engine_operationsRouter executes across all engines

Lessons Learned

  • execute() uses col:type syntax; execute_parsed() uses SQL syntax
  • NEIGHBORS command returns QueryResult::Ids, not QueryResult::Nodes
  • Node IDs must be captured and reused, not assumed to be 0, 1, 2…

Sparse Vector Tests (22 tests)

Tests sparse vector creation, storage, and similarity operations.

Key APIs

  • TensorValue::from_embedding(dense, value_threshold, sparsity_threshold)
  • TensorValue::from_embedding_auto(dense) - Auto thresholds (0.01 value, 0.7 sparsity)
  • TensorValue::dot(other) - Dot product (sparse-sparse, sparse-dense, dense-dense)
  • TensorValue::cosine_similarity(other) - Cosine similarity
  • TensorValue::to_dense() - Convert back to dense
  • TensorValue::dimension() - Get vector dimension

Distance Metrics Tests (17 tests)

Tests SIMILAR queries with different distance metrics.

Key Syntax

-- Metric goes AFTER LIMIT clause
SIMILAR 'key' LIMIT 10 EUCLIDEAN
SIMILAR [0.1, 0.2] LIMIT 5 DOT_PRODUCT

Known Issues

  • Metric keyword must be AFTER LIMIT (not METRIC EUCLIDEAN)
  • COSINE/DOT_PRODUCT return empty for zero-magnitude queries
  • EUCLIDEAN correctly handles zero vectors

Coverage Summary

CategoryFilesTestsKey Validations
Storage450+Persistence, tiering, instrumentation
Engines560+Relational, graph, vector operations
Security225+Vault, access control, versioning
Caching213Exact, semantic, invalidation
Advanced680+Compression, joins, indexes, sparse
Total17267+