|
| 1 | +# Testing Guide for NexumDB |
| 2 | + |
| 3 | +This document describes all testing and quality assurance processes for NexumDB. |
| 4 | + |
| 5 | +## Local Testing |
| 6 | + |
| 7 | +### Rust Tests |
| 8 | +```bash |
| 9 | +# Set PyO3 compatibility for Python 3.14 |
| 10 | +export PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 |
| 11 | + |
| 12 | +# Format check |
| 13 | +cargo fmt --all -- --check |
| 14 | + |
| 15 | +# Linting |
| 16 | +cargo clippy --workspace --all-targets -- -D warnings |
| 17 | + |
| 18 | +# Run tests (single-threaded for consistent results) |
| 19 | +cargo test --workspace -- --test-threads=1 |
| 20 | + |
| 21 | +# Security audit |
| 22 | +cargo audit |
| 23 | + |
| 24 | +# Generate documentation |
| 25 | +cargo doc --no-deps --workspace |
| 26 | +``` |
| 27 | + |
| 28 | +### Python Tests |
| 29 | +```bash |
| 30 | +cd nexum_ai |
| 31 | + |
| 32 | +# Lint with ruff |
| 33 | +ruff check . |
| 34 | + |
| 35 | +# Syntax check |
| 36 | +python3 -m compileall *.py |
| 37 | + |
| 38 | +# Run tests with coverage |
| 39 | +pytest --cov=. --cov-report=xml --cov-report=html |
| 40 | +``` |
| 41 | + |
| 42 | +## CI/CD Workflows |
| 43 | + |
| 44 | +### Continuous Integration (.github/workflows/ci.yml) |
| 45 | +Runs on: Every push and PR |
| 46 | +- **Rust checks**: |
| 47 | + - Format check with `cargo fmt` |
| 48 | + - Linting with `cargo clippy` |
| 49 | + - Unit and integration tests |
| 50 | + - Security audit with `cargo audit` |
| 51 | + - Documentation build |
| 52 | + - Code coverage with `cargo-llvm-cov` → Codecov |
| 53 | + |
| 54 | +- **Python checks**: |
| 55 | + - Linting with `ruff` |
| 56 | + - Syntax check with `compileall` |
| 57 | + - Tests with `pytest` |
| 58 | + - Coverage with `pytest-cov` → Codecov |
| 59 | + |
| 60 | +- **Benchmarks** (PR only): |
| 61 | + - Criterion-based performance tests |
| 62 | + - Comparison with main branch |
| 63 | + |
| 64 | +### Security Workflows |
| 65 | + |
| 66 | +#### CodeQL Analysis (.github/workflows/codeql.yml) |
| 67 | +Runs on: Push to main, PRs, weekly schedule |
| 68 | +- Static security analysis for Python code |
| 69 | +- Identifies potential vulnerabilities |
| 70 | + |
| 71 | +#### Dependency Review (.github/workflows/dependency-review.yml) |
| 72 | +Runs on: Pull requests |
| 73 | +- Reviews dependency changes |
| 74 | +- Fails on moderate+ severity vulnerabilities |
| 75 | +- Comments summary in PR |
| 76 | + |
| 77 | +#### SBOM Generation (.github/workflows/sbom.yml) |
| 78 | +Runs on: Release tags |
| 79 | +- Generates Software Bill of Materials |
| 80 | +- Tracks all dependencies |
| 81 | + |
| 82 | +### Code Quality |
| 83 | + |
| 84 | +#### DCO Check (.github/workflows/dco.yml) |
| 85 | +Runs on: Pull requests |
| 86 | +- Verifies Developer Certificate of Origin |
| 87 | +- Ensures proper commit sign-off |
| 88 | + |
| 89 | +#### Stale Issues (.github/workflows/stale.yml) |
| 90 | +Runs on: Schedule (daily) |
| 91 | +- Marks inactive issues/PRs as stale |
| 92 | +- Auto-closes after inactivity period |
| 93 | + |
| 94 | +### Release & Distribution |
| 95 | + |
| 96 | +#### Release Please (.github/workflows/release-please.yml) |
| 97 | +Runs on: Push to main |
| 98 | +- Automated release PR generation |
| 99 | +- Version bumping based on conventional commits |
| 100 | +- Changelog generation |
| 101 | +- **Current Status**: Requires repository settings update (see RELEASE_PLEASE_FIX.md) |
| 102 | + |
| 103 | +#### Docker Release (.github/workflows/docker-release.yml) |
| 104 | +Runs on: Release tags |
| 105 | +- Builds and publishes Docker images |
| 106 | +- Multi-platform support |
| 107 | + |
| 108 | +## Known Issues |
| 109 | + |
| 110 | +### Unmaintained Dependencies |
| 111 | +The following dependencies are flagged as unmaintained by `cargo audit`: |
| 112 | +- `fxhash 0.2.1` - Used by sled (indirect) |
| 113 | +- `instant 0.1.13` - Used by sled (indirect) |
| 114 | + |
| 115 | +These are **warnings only**, not security vulnerabilities. They come from the `sled` database dependency. Monitor for: |
| 116 | +- Updates to `sled` that might replace these |
| 117 | +- Alternative database backends if needed |
| 118 | +- Security advisories (none currently) |
| 119 | + |
| 120 | +### Release Please Permissions |
| 121 | +The Release Please workflow requires repository settings update. See `/tmp/release-please-fix.md` for instructions. |
| 122 | + |
| 123 | +## Coverage Requirements |
| 124 | + |
| 125 | +- **Target**: Maintain >80% code coverage |
| 126 | +- **Tracking**: Codecov integration for both Rust and Python |
| 127 | +- **Reports**: |
| 128 | + - Rust: `lcov.info` generated by `cargo-llvm-cov` |
| 129 | + - Python: `coverage.xml` generated by `pytest-cov` |
| 130 | + |
| 131 | +## Pre-commit Checklist |
| 132 | + |
| 133 | +Before pushing changes: |
| 134 | +1. ✅ Run `cargo fmt --all` |
| 135 | +2. ✅ Run `cargo clippy --workspace --all-targets` |
| 136 | +3. ✅ Run `cargo test --workspace` |
| 137 | +4. ✅ Run `ruff check nexum_ai/` (if Python changes) |
| 138 | +5. ✅ Run `pytest` in nexum_ai/ (if Python changes) |
| 139 | +6. ✅ Ensure all tests pass locally |
| 140 | +7. ✅ Sign commits with DCO (`git commit -s`) |
| 141 | + |
| 142 | +## Continuous Improvement |
| 143 | + |
| 144 | +Consider adding: |
| 145 | +- [ ] Mutation testing for test quality assessment |
| 146 | +- [ ] Performance regression detection |
| 147 | +- [ ] Fuzzing for SQL parser |
| 148 | +- [ ] Integration tests with real workloads |
| 149 | +- [ ] Load testing scenarios |
0 commit comments