tests: remove the singleton stress test; #[ignore] means disabled again
128 fast activate/revert cycles are not a realistic load. restarts_service covers the restart of a service after an upgrade. nix flake check runs the normal tests only.
This commit is contained in:
@@ -35,7 +35,7 @@ Keep it that way.
|
|||||||
## Checks
|
## Checks
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nix flake check -L # everything below, plus the stress tests; CI runs this on every push
|
nix flake check -L # all tests below; CI runs this on every push
|
||||||
nix develop -c cargo test --workspace # fast with a warm cache: run it during development
|
nix develop -c cargo test --workspace # fast with a warm cache: run it during development
|
||||||
nix develop -c cargo build --release -p agent --target wasm32-wasip2
|
nix develop -c cargo build --release -p agent --target wasm32-wasip2
|
||||||
nix develop -c cargo clippy --workspace
|
nix develop -c cargo clippy --workspace
|
||||||
@@ -44,8 +44,12 @@ nix develop -c cargo clippy --workspace
|
|||||||
`nix run -- init` and `nix run -- run` must keep working without other
|
`nix run -- init` and `nix run -- run` must keep working without other
|
||||||
setup.
|
setup.
|
||||||
|
|
||||||
Tests must stay fast. Only a few tests may wait for a timing (grace periods,
|
Tests must stay fast:
|
||||||
deadlines). Poll for a condition with a deadline, do not sleep. `#[ignore]` is
|
|
||||||
only for stress tests: `nix flake check` runs them with `--include-ignored`.
|
- Only a few tests may wait for a timing (grace periods, deadlines).
|
||||||
Tests that build plugins use the persistent cache in
|
- Poll for a condition with a deadline. Do not sleep.
|
||||||
|
- Do not test unrealistic load, such as many fast cycles.
|
||||||
|
- `#[ignore]` only disables a test for a short time, with the reason in the
|
||||||
|
attribute.
|
||||||
|
- Tests that build plugins use the persistent cache in
|
||||||
`env!("CARGO_TARGET_TMPDIR")`.
|
`env!("CARGO_TARGET_TMPDIR")`.
|
||||||
|
|||||||
@@ -367,38 +367,6 @@ async fn review_watcher_failure_is_nonfatal() {
|
|||||||
activate(&host, "notes").await.unwrap();
|
activate(&host, "notes").await.unwrap();
|
||||||
host.stop().await;
|
host.stop().await;
|
||||||
}
|
}
|
||||||
/// PROTOCOL 8 (L14): rapid service upgrades never overlap singleton instances.
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
|
||||||
async fn review_singleton_restart() {
|
|
||||||
singleton_restart_cycles(4).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// PROTOCOL 8 (L14): 128 upgrade/revert cycles stress the singleton restart race.
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
|
||||||
#[ignore = "stress: run by nix flake check"]
|
|
||||||
async fn singleton_restart_stress() {
|
|
||||||
singleton_restart_cycles(128).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Exercises service restarts without duplicating the normal and stress setup.
|
|
||||||
async fn singleton_restart_cycles(cycles: usize) {
|
|
||||||
let world = TestWorld::new();
|
|
||||||
world.plugin("notes", document("serve"), document("serve"));
|
|
||||||
std::fs::write(
|
|
||||||
world.0.join("config/boot.json"),
|
|
||||||
json!([{"method":"notes.serve","params":{}}]).to_string(),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
let host = world.start().await;
|
|
||||||
for _ in 0..cycles {
|
|
||||||
activate(&host, "notes").await.unwrap();
|
|
||||||
call(&host, "core.revert", json!({"plugin":"notes"})).await;
|
|
||||||
}
|
|
||||||
activate(&host, "notes").await.unwrap();
|
|
||||||
marker(world.0.join("state/notes/service"), "2").await;
|
|
||||||
host.stop().await;
|
|
||||||
assert!(!world.0.join("state/notes/duplicate-service").exists());
|
|
||||||
}
|
|
||||||
/// H2: a plugin read error belongs to that entry, not the entire graph.
|
/// H2: a plugin read error belongs to that entry, not the entire graph.
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn review_read_error_is_local() {
|
async fn review_read_error_is_local() {
|
||||||
|
|||||||
@@ -87,22 +87,9 @@ fn main() {
|
|||||||
"serve" | "hold" => {
|
"serve" | "hold" => {
|
||||||
send(json!({"jsonrpc":"2.0","id":request["id"],"result":{"version":version}}));
|
send(json!({"jsonrpc":"2.0","id":request["id"],"result":{"version":version}}));
|
||||||
if request["method"] == "serve" {
|
if request["method"] == "serve" {
|
||||||
let exclusive = format!("/run/{plugin}-service");
|
|
||||||
if std::fs::OpenOptions::new()
|
|
||||||
.write(true)
|
|
||||||
.create_new(true)
|
|
||||||
.open(&exclusive)
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
std::fs::write(format!("/state/{plugin}/duplicate-service"), "duplicate")
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
std::fs::write(format!("/state/{plugin}/service"), version).unwrap();
|
std::fs::write(format!("/state/{plugin}/service"), version).unwrap();
|
||||||
}
|
}
|
||||||
for _ in lines {}
|
for _ in lines {}
|
||||||
if request["method"] == "serve" {
|
|
||||||
let _ = std::fs::remove_file(format!("/run/{plugin}-service"));
|
|
||||||
}
|
|
||||||
std::fs::write(format!("/state/{plugin}/ended-{version}"), "ended").unwrap();
|
std::fs::write(format!("/state/{plugin}/ended-{version}"), "ended").unwrap();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,8 +98,6 @@
|
|||||||
checks.tests = craneLib.cargoTest (common // wasiCcEnv // {
|
checks.tests = craneLib.cargoTest (common // wasiCcEnv // {
|
||||||
inherit cargoArtifacts;
|
inherit cargoArtifacts;
|
||||||
cargoExtraArgs = "--locked ${testPackages}";
|
cargoExtraArgs = "--locked ${testPackages}";
|
||||||
# Stress tests are ignored in a normal `cargo test`. The check runs them.
|
|
||||||
cargoTestExtraArgs = "-- --include-ignored";
|
|
||||||
# Nothing builds on the test run's target folder: don't store it.
|
# Nothing builds on the test run's target folder: don't store it.
|
||||||
doInstallCargoArtifacts = false;
|
doInstallCargoArtifacts = false;
|
||||||
# The SDK tests run sample plugins with the wasmtime CLI.
|
# The SDK tests run sample plugins with the wasmtime CLI.
|
||||||
|
|||||||
Reference in New Issue
Block a user