Skip to content

Commit ba91769

Browse files
committed
Run datastore tests against multiple schemas
We want to prove in tests that some Janus version can run safely on multiple schema versions to make database schema migrations safer. In this commit: - `aggregator_core::test_util::EphemeralDatastore` can now be constructed with a `max_schema_version` argument to control which migration scripts are applied during tests - `datastore::SUPPORTED_SCHEMA_VERSIONS` is now emitted by the `supported_schema_versions` macro, which also constructs a template for stamping out tests. - We adopt [`rstest`][1] to inject an `EphemeralDatastore` instance into tests in `aggregator_core::datastore::Datatore::tests`. Using [`rstest_reuse`][2], we can automatically stamp out versions of existing tests that run using multiple schema versions. We only use this dependency injection technique in the `datastore` module, because that should be the only module that's tightly coupled to the database schema. We could run all tests that use a datastore this way, at the cost of increasing overall test runtime. [1]: https://docs.rs/rstest [2]: https://docs.rs/rstest_reuse
1 parent efbc6ee commit ba91769

File tree

6 files changed

+374
-83
lines changed

6 files changed

+374
-83
lines changed

Cargo.lock

+221
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aggregator_core/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ uuid = { version = "1.3.1", features = ["v4"] }
6262

6363
[dev-dependencies]
6464
assert_matches = "1"
65+
async-std = { version = "1.12.0", features = ["attributes"] }
6566
hyper = "0.14.26"
6667
janus_aggregator_core = { path = ".", features = ["test-util"] }
6768
janus_core = { workspace = true, features = ["test-util"] }
69+
rstest = "0.17.0"
70+
rstest_reuse = "0.5.0"
6871
serde_test = "1.0.160"
6972
tempfile = "3.5.0"
7073
tokio = { version = "1", features = ["test-util"] } # ensure this remains compatible with the non-dev dependency

0 commit comments

Comments
 (0)