Quick Test Guide - Multi-Tenancy
Quick Test Guide - Multi-Tenancy
Quick reference for running multi-tenancy tests in HeliosDB Nano.
Quick Commands
# Run all multi-tenancy tests (fastest)cargo test --test multi_tenancy_tests
# Run REPL command testscargo test --test repl_tenant_commands
# Run unit tests in tenant modulecargo test --lib tenant::tests
# Run everything related to tenancycargo test tenant
# Run with outputcargo test --test multi_tenancy_tests -- --nocapture
# Run specific testcargo test test_rls_prevents_cross_tenant_select
# Run benchmarkscargo bench --bench multi_tenancy_benchTest Categories
🔒 Critical Security Tests (MUST PASS)
# These tests ensure no data leakage between tenantscargo test test_rls_prevents_cross_tenant_selectcargo test test_rls_prevents_cross_tenant_updatecargo test test_rls_prevents_cross_tenant_deletecargo test test_cdc_multi_tenant_isolation📊 Quota Enforcement Tests
cargo test test_connection_limit_enforcedcargo test test_storage_limit_enforcedcargo test test_qps_limit_enforcedcargo test test_quota_window_reset📝 CDC Tests
cargo test test_cdc_captures_insertcargo test test_cdc_captures_updatecargo test test_cdc_captures_delete🔄 Migration Tests
cargo test test_tenant_migration_lifecyclecargo test test_migration_consistency_verificationPerformance Benchmarks
# All benchmarkscargo bench --bench multi_tenancy_bench
# RLS performancecargo bench --bench multi_tenancy_bench -- rls
# Quota performancecargo bench --bench multi_tenancy_bench -- quota
# CDC performancecargo bench --bench multi_tenancy_bench -- cdc
# Save baseline for comparisoncargo bench --bench multi_tenancy_bench -- --save-baseline mainCoverage Report
# Install tarpaulin (first time only)cargo install cargo-tarpaulin
# Generate coveragecargo tarpaulin --out Html --output-dir coverage/ -- tenant
# Open coverage reportopen coverage/index.html # macOSxdg-open coverage/index.html # LinuxContinuous Integration
# CI-style test run (what GitHub Actions runs)cargo test --test multi_tenancy_tests --test repl_tenant_commands --lib tenant::testscargo bench --bench multi_tenancy_bench --no-runTest Statistics
- Total Integration Tests: 43
- Total Unit Tests: 35
- Total REPL Tests: 50+
- Total Benchmark Suites: 8
- Overall Coverage: ~100% for multi-tenancy features
Test Files
| File | Purpose | Test Count |
|---|---|---|
tests/multi_tenancy_tests.rs | Integration tests | 43 |
tests/repl_tenant_commands.rs | REPL command parsing | 50+ |
src/tenant/mod.rs (tests module) | Unit tests | 35 |
benches/multi_tenancy_bench.rs | Performance benchmarks | 8 groups |
Expected Test Duration
- Unit tests: ~0.5 seconds
- Integration tests: ~2-5 seconds
- REPL tests: ~1 second
- Benchmarks: ~5-10 minutes (all suites)
Common Issues
Tests Fail with “tenant_manager not found”
This usually means the EmbeddedDatabase hasn’t been updated to include the tenant_manager field. Check that src/lib.rs exports the tenant module.
Benchmarks Take Too Long
Run specific benchmark groups:
cargo bench --bench multi_tenancy_bench -- rls --quickCoverage Tool Errors
Ensure you’re using a compatible Rust toolchain:
rustup component add llvm-tools-previewNext Steps
After running tests:
- Check test output for failures
- Run benchmarks to establish baseline
- Generate coverage report
- Review coverage gaps
- Add tests for any uncovered scenarios
Pre-Commit Checklist
Before committing changes:
# Format codecargo fmt
# Run lintercargo clippy -- -D warnings
# Run testscargo test tenant
# Run benchmarks (no-run to save time)cargo bench --bench multi_tenancy_bench --no-runResources
- Full coverage report:
docs/testing/MULTI_TENANCY_TEST_COVERAGE.md - Test source:
tests/multi_tenancy_tests.rs - Benchmarks:
benches/multi_tenancy_bench.rs
Quick Tip: Use cargo test tenant -- --test-threads=1 to run tests serially if you encounter race conditions.