-
Notifications
You must be signed in to change notification settings - Fork 0
Testing Strategy en
中文 | English
Maintained version: v0.51.2 | Last updated: 2026-07-06
EnerOS employs a multi-layer testing strategy covering 7 levels: unit / integration / e2e / chaos / fuzz / proptest / protocol conformance. v0.51.2 test scale: 7700+ tests / 0 failed / 78 ignored / 0 clippy warnings / cargo deny green. This page is a strategy summary; for the full testing guide see the main repo docs/developer-guide.md §v0.51.0.
┌──────────┐
│ Fuzz │ 4 protocols × 24h
└──────────┘
┌───────────────────┐
│ Chaos │ 5 fault injections
└───────────────────┘
┌─────────────────────────────┐
│ e2e (tests/e2e) │ HTTP API full chain
└─────────────────────────────┘
┌─────────────────────────────────────┐
│ Integration tests (cross-crate) │
└─────────────────────────────────────┘
┌─────────────────────────────────────────────┐
│ Unit tests (within crate tests/) │ ~7000+
└─────────────────────────────────────────────┘
Each crate's src/ contains #[cfg(test)] mod tests + a tests/ directory.
cargo test --workspacev0.51.2 scale: 7700+ tests passed / 0 failed / 78 ignored.
Cross-crate integration tests live in the tests/ directory:
| Directory | Purpose |
|---|---|
tests/e2e/ |
HTTP API end-to-end |
tests/protocol_conformance/ |
Protocol conformance (7 protocols, 275 tests) |
tests/llm_verify/ |
LLM 100-scenario verification (v0.50.1+) |
tests/llm_verify_semantic_20/ |
LLM 20-round semantic verification (v0.50.2+) |
tests/chaos/ |
Chaos tests |
tests/integration/ |
Cross-crate module boundary tests |
tests/e2e/ uses a real eneros-api instance + HTTP client, covering:
- /health health check
- /api/v1/demo/* demo APIs
- /api/v1/devices/* device management
- /api/v1/timeseries/* timeseries queries
- /api/v1/analysis/* analysis computations
- /api/v1/ops/* ops endpoints
tests/chaos/ injects 5 fault types:
| Fault type | Injection | Verification |
|---|---|---|
| Network partition | iptables block | HA failover |
| Process crash | kill -9 | Daemon restart |
| Disk full | tmpfs fill | Graceful degradation |
| CPU saturation | stress-ng | Scheduling priority takes effect |
| Memory pressure | cgroups limit | OOM does not affect RT domain |
The fuzz/ directory provides 4 fuzz targets using the libFuzzer engine:
| Target | Protocol |
|---|---|
fuzz_iec104 |
IEC 104 |
fuzz_iec103 |
IEC 103 |
fuzz_dlt698 |
DL/T 698 |
fuzz_pmu_c37118 |
PMU C37.118 |
# Smoke test (60s)
cargo fuzz run fuzz_iec104 -- -max_total_time=60
# Long run (24h)
cargo fuzz run fuzz_iec104 -- -max_total_time=86400Windows has a libFuzzer linking issue (LNK1104); run in a Linux / WSL2 environment.
5 crates × 256 cases = 30720 verifications (v0.51.1 expanded to 1024 cases = 30720 verifications, 0 violations):
| Crate | Properties | Purpose |
|---|---|---|
| eneros-powerflow | 6 | Powerflow convergence + conservation laws |
| eneros-topology | 5 | Topology search invariants |
| eneros-linalg | 6 | Matrix operation properties |
| eneros-timeseries | 7 | Timeseries aggregation no-drop |
| eneros-constraint | 6 | Constraint check idempotency |
eneros.toml [quality].proptest_cases = 256 configures the number of cases per property.
tests/protocol_conformance/ provides 275 tests across 7 protocols; see the Protocol Support page.
The benches/ directory uses criterion:
cargo bench --workspacebenches/baseline.json stores the performance baseline; PRs must not cause critical-path regressions greater than 5%.
| Gate | Command | On failure |
|---|---|---|
| Formatting | cargo fmt --all -- --check |
Blocks |
| Lint | cargo clippy --workspace --all-targets -- -D warnings |
Blocks |
| Build | cargo build --workspace |
Blocks |
| Test | cargo test --workspace |
Blocks |
| Docs | cargo doc --workspace --no-deps |
Warning |
| Dependencies | cargo deny check |
Blocks |
| Coverage | llvm-cov | Threshold check |
- Fuzz 60s smoke and 24h long runs pending Linux/WSL2 environment verification
- proptest covers only 5 crates; expansion to all L0/L1 crates pending
- 67 unwrap/expect remaining in non-test code (88 removed in v0.51.0)
- WCET tests require
--test-threads=1(to avoid noise) -
test_wcet_over_budget_under_2x_audit_sink_recordsis a known flaky test (timing-based)
- Main repo docs/developer-guide.md §v0.51.0 — Testing strategy details
- Wiki Development Workflow — Quality gates and debugging
- Wiki Protocol Support — Protocol conformance test matrix
- Wiki SafetyGateway — WCET framework
- Main repo benches/ — Performance benchmarks
- Main repo fuzz/ — Fuzz targets
- Main repo tests/ — Integration tests
EnerOS Wiki | v0.51.2