Skip to content

Commit de42e34

Browse files
authored
DST test for Engine. (#5424)
# Description of Changes Sets the layout for DST tests and adds a basic test for `spacetimedb-engine` via `engine` mod. ### Engine Test: - Generates random schemas with tables, indexes, unique constraints, primary keys, and sequence columns. - Drives randomized interactions: begin mutable tx, insert, delete, commit, and replay. - Uses an in-memory commitlog/durability implementation so replay can simulate shutdown/reopen without disk. - Define properties, check them while processing interactions. ### Upnext: 1. Fault-injection in commitlog. 2. Multi connection support (async api call-ing is not needed for `engine` test as we expect caller/module to also be single-threaded). 3. Increase API coverage of engine, especially schema migrations. 4. Add more properties like check for sequences. 5. simulated Snapshots. Further more integration tests like `standalone`, `replication` can be added by implementing [`traits.rs`](https://github.com/clockworklabs/SpacetimeDB/pull/5424/changes#diff-c9a6dc71550c7ccdd23b18de8ec8777aa6e2a34af2ddad0a5040537c8dffd1e6) similar to `engine`. looking to get general feedback on overall design for test effectiveness and maintainability. # API and ABI breaking changes NA # Expected complexity level and risk It's a test addition.
1 parent 500a870 commit de42e34

22 files changed

Lines changed: 2340 additions & 79 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,6 @@ jobs:
338338
339339
wasm-bindgen --version
340340
341-
- name: Check engine simulation build
342-
run: cargo check -p spacetimedb-engine --no-default-features --features simulation
343-
344341
# Source emsdk environment to make emcc (Emscripten compiler) available in PATH.
345342
- name: Run tests
346343
run: |

Cargo.lock

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ members = [
7777
"crates/bindings-typescript/test-app/server",
7878
"crates/bindings-typescript/test-react-router-app/server",
7979
"crates/bindings-typescript/test-solid-router/server",
80-
"crates/query-builder",
80+
"crates/query-builder", "crates/dst",
8181
]
8282
default-members = ["crates/cli", "crates/standalone", "crates/update"]
8383
# cargo feature graph resolver. v3 is default in edition2024 but workspace

crates/datastore/Cargo.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ rust-version.workspace = true
1010
spacetimedb-data-structures.workspace = true
1111
spacetimedb-lib = { workspace = true, features = ["serde", "metrics_impls"] }
1212
spacetimedb-commitlog.workspace = true
13-
spacetimedb-durability = { path = "../durability", default-features = false }
13+
spacetimedb-durability.workspace = true
1414
spacetimedb-metrics.workspace = true
1515
spacetimedb-primitives.workspace = true
1616
spacetimedb-paths.workspace = true
1717
spacetimedb-sats = { workspace = true, features = ["serde"] }
1818
spacetimedb-schema.workspace = true
1919
spacetimedb-table.workspace = true
20-
spacetimedb-snapshot = { path = "../snapshot", default-features = false }
20+
spacetimedb-snapshot.workspace = true
2121
spacetimedb-execution.workspace = true
2222

2323
anyhow = { workspace = true, features = ["backtrace"] }
@@ -39,9 +39,7 @@ thin-vec.workspace = true
3939
[features]
4040
# Print a warning when doing an unindexed `iter_by_col_range` on a large table.
4141
unindexed_iter_by_col_range_warn = []
42-
default = ["unindexed_iter_by_col_range_warn", "tokio"]
43-
tokio = ["spacetimedb-durability/tokio", "spacetimedb-snapshot/tokio"]
44-
simulation = ["spacetimedb-durability/simulation", "spacetimedb-snapshot/simulation"]
42+
default = ["unindexed_iter_by_col_range_warn"]
4543
# Enable test helpers and utils
4644
test = ["spacetimedb-commitlog/test", "spacetimedb-schema/test"]
4745

crates/dst/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "spacetimedb-dst"
3+
version.workspace = true
4+
edition.workspace = true
5+
rust-version.workspace = true
6+
7+
[dependencies]
8+
anyhow.workspace = true
9+
clap.workspace = true
10+
spacetimedb-datastore.workspace = true
11+
spacetimedb-commitlog.workspace = true
12+
spacetimedb-durability.workspace = true
13+
spacetimedb-engine.workspace = true
14+
spacetimedb-lib.workspace = true
15+
spacetimedb-primitives.workspace = true
16+
spacetimedb-runtime = { workspace = true, features = ["simulation"] }
17+
spacetimedb-sats.workspace = true
18+
spacetimedb-schema.workspace = true
19+
spacetimedb-table.workspace = true
20+
tracing.workspace = true
21+
tracing-subscriber.workspace = true
22+
23+
[lints]
24+
workspace = true

crates/dst/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SpacetimeDB DST
2+
3+
Deterministic Simulation Testing framework for SpacetimeDB.
4+
5+
## Test
6+
7+
```sh
8+
cargo test -p spacetimedb-dst
9+
```
10+
11+
## Run
12+
13+
```sh
14+
cargo run -p spacetimedb-dst -- run --seed 42 --max-interactions 1000
15+
```
16+
17+
Options:
18+
19+
- `--seed <u64>` — RNG seed (defaults to wall-clock nanos)
20+
- `--max-interactions <usize>` — interaction budget

0 commit comments

Comments
 (0)