Comprehensive testing infrastructure for the VUDO Runtime local-first stack.
This directory contains the complete test suite for Phase 2 (MYCELIUM) of the VUDO Runtime project. The tests validate:
- ✅ State Engine: Automerge CRDT state management
- ✅ Storage: Platform-agnostic persistence
- ✅ P2P Networking: Iroh-based peer discovery and sync
- ✅ Offline-First: Complete offline workflows
- ✅ Convergence: CRDT merge correctness
- ✅ Browser Integration: WASM, IndexedDB, multi-tab sync
Rust-based integration tests validating the local-first stack:
cd tests/integration
cargo testTest Coverage:
- Airplane mode simulation (7 tests)
- Network partition/heal (7 tests)
- Concurrent multi-node edits (8 tests)
- Large document sync (8 tests)
- Schema evolution (9 tests)
Total: 39 integration tests
📚 See integration/README.md for details
Browser-based E2E tests using Playwright:
cd tests/e2e
npm install
npm testTest Coverage:
- Browser crash recovery
- Multi-tab synchronization
- Offline/online transitions
- IndexedDB persistence
- Service worker recovery
Browsers: Chrome, Firefox, Safari, Mobile Chrome, Mobile Safari
📚 See e2e/README.md for details
Per-crate unit tests:
# State engine
cd crates/vudo-state
cargo test
# P2P networking
cd crates/vudo-p2p
cargo test
# Storage
cd crates/vudo-storage
cargo test# Rust integration tests
cargo test --test integration
# Browser E2E tests
cd tests/e2e && npm test
# Unit tests (all crates)
cargo test --workspace# Airplane mode tests
cargo test --test integration airplane_mode
# Network partition tests
cargo test --test integration network_partition
# Browser crash recovery
cd tests/e2e && npm run test:crash
# Multi-tab sync
cd tests/e2e && npm run test:multi-tabTest Harness (integration/local-first/test_harness.rs):
TestNode: Simulated node with state engine + P2P- Network simulation: partition/heal
- Convergence verification: hash-based
- Performance measurement
Key Abstractions:
// Create test node
let node = TestNode::with_p2p("node_a").await;
// Create document
node.create_document("users", "alice", |doc| {
doc.put(ROOT, "name", "Alice")?;
Ok(())
}).await;
// Verify convergence
verify_full_convergence(&nodes, "users", "alice").await;Playwright Configuration (e2e/playwright.config.ts):
- Multi-browser support
- Mobile device emulation
- Video recording on failure
- Retry logic for CI
Test Utilities:
- Page object models
- Mock VUDO runtime
- IndexedDB inspection
- Network condition simulation
| Test Category | Target | Status |
|---|---|---|
| 10MB document sync | < 30s | ✅ |
| Convergence rate | 100% | ✅ |
| Data loss | 0% | ✅ |
| 1000 offline/online cycles | No loss | ✅ |
| Browser crash recovery | < 2s | ✅ |
| Cross-tab sync | < 500ms | ✅ |
Phase 2 (MYCELIUM) quality gate:
- 100% convergence after partition heal (verified by hash)
- No data loss across 1000 offline/online cycles
- Browser crash recovery restores last persisted state
- 10MB document syncs in < 30 seconds on broadband
- All 39+ integration tests pass
- All 15+ E2E tests pass
- Mixed schema versions sync correctly
Tests run in GitHub Actions:
# .github/workflows/ci.yml
jobs:
integration-tests:
runs-on: ubuntu-latest
steps:
- name: Run integration tests
run: cargo test --test integration --verbose
e2e-tests:
runs-on: ubuntu-latest
steps:
- name: Install Playwright
run: cd tests/e2e && npm install && npx playwright install
- name: Run E2E tests
run: cd tests/e2e && npm testCI Features:
- Parallel test execution
- Test result artifacts
- Coverage reporting
- Performance regression detection
tests/
├── README.md # This file
│
├── integration/ # Rust integration tests
│ ├── Cargo.toml
│ ├── README.md
│ ├── main.rs # Test runner
│ └── local-first/
│ ├── mod.rs
│ ├── test_harness.rs # Test infrastructure
│ ├── airplane_mode.rs # 7 tests
│ ├── network_partition.rs # 7 tests
│ ├── concurrent_edits.rs # 8 tests
│ ├── large_documents.rs # 8 tests
│ └── schema_evolution.rs # 9 tests
│
└── e2e/ # Browser E2E tests
├── package.json
├── playwright.config.ts
├── README.md
└── browser-sync/
├── crash_recovery.test.ts
├── multi_tab_sync.test.ts
└── offline_online.test.ts
- Add test to appropriate file in
integration/local-first/ - Use
TestNodefrom test harness - Verify convergence with hash comparison
- Document performance expectations
- Update test count in README
Example:
#[tokio::test]
async fn test_my_scenario() {
let nodes = create_mesh_network(3).await;
// Create documents
for node in &nodes {
node.create_document("test", "doc", |doc| {
doc.put(ROOT, "value", 42i64)?;
Ok(())
}).await;
}
// Verify convergence
verify_full_convergence(&nodes, "test", "doc").await;
}- Create test in
e2e/browser-sync/ - Use Playwright page objects
- Test across multiple browsers
- Document browser-specific behavior
Example:
test('should sync across tabs', async ({ browser }) => {
const context = await browser.newContext();
const tab1 = await context.newPage();
const tab2 = await context.newPage();
// Test implementation...
await context.close();
});# Enable logging
RUST_LOG=debug cargo test --test integration -- --nocapture
# Run single test
cargo test --test integration test_name -- --exact --nocapture
# Run serially (not in parallel)
cargo test --test integration -- --test-threads=1# Debug mode
cd tests/e2e && npm run test:debug
# Headed mode (see browser)
npm run test:headed
# UI mode (interactive)
npm run test:ui
# Show trace
npx playwright show-trace trace.zipGenerate coverage reports:
# Install tarpaulin
cargo install cargo-tarpaulin
# Generate coverage for integration tests
cargo tarpaulin --test integration --out Html
# View report
open tarpaulin-report.htmlRun benchmarks:
# State engine benchmarks
cd crates/vudo-state
cargo bench
# P2P benchmarks (when enabled)
cd crates/vudo-p2p
cargo bench- Integration Test README - Rust integration tests
- E2E Test README - Browser E2E tests
- VUDO State README - State engine
- VUDO P2P README - P2P networking
- VUDO Storage README - Storage layer
Tests run on:
- Every commit (push to any branch)
- Every pull request
- Nightly builds (extended test suite)
Test Matrix:
- OS: Ubuntu, macOS, Windows
- Rust: stable, beta, nightly
- Browsers: Chrome, Firefox, Safari
- Mobile: iOS Safari, Android Chrome
When contributing tests:
- Ensure all tests pass locally
- Add tests for new features
- Update documentation
- Follow existing patterns
- Use meaningful test names
- Document edge cases
Same as parent project: MIT OR Apache-2.0