Files
SpacetimeDB/crates/testing/Cargo.toml
Kim Altintop e0b8e6f265 [teams 1/5] Reset database (#3611)
So far, the `--clear-database` option to `publish` has simply dropped
and then re-created the database (if it did exist).

This will no longer work when databases can have "children": because
dropping and re-creating is not atomic, children would either become
orphans, or be dropped as well.

To solve this, `reset_database` is introduced as a separate action that:

- shuts down all replicas
- if a `program_bytes` is supplied, replaces the database's initial
  program
- if a `host_type` is supplied, replaces the database's host type
- starts `num_replicas` or the previous number of replicas, which
  initialize themselves as normal

As this could be its own CLI command, the action is provided as its own
API endpoint (undocumented).

However, since `publish` has no way of knowing whether the database it
operates on actually exists, the `publish_database` handler will just
invoke the `reset_database` handler if `clear=true` and the database
exists, and return its result. This is to avoid starting the transfer of
the program in the request body, only to receive a redirect.

Some refactoring was necessary to dissect and understand the flow.


# API and ABI breaking changes

Introduces a new, undocumented API endpoint.
We may want to nest it under `/unstable`.

# Expected complexity level and risk

2

# Testing

From the outside, the observed behavior should be as before,
so smoketests should cover it.
2025-11-11 08:39:24 +00:00

37 lines
834 B
TOML

[package]
name = "spacetimedb-testing"
version.workspace = true
edition.workspace = true
license-file = "LICENSE"
publish = false
[dependencies]
spacetimedb-cli.workspace = true
spacetimedb-data-structures.workspace = true
spacetimedb-lib.workspace = true
spacetimedb-core.workspace = true
spacetimedb-standalone.workspace = true
spacetimedb-client-api.workspace = true
spacetimedb-paths.workspace = true
spacetimedb-schema.workspace = true
anyhow.workspace = true
bytes.workspace = true
env_logger.workspace = true
log.workspace = true
clap.workspace = true
serde_json.workspace = true
tokio.workspace = true
wasmbin.workspace = true
duct.workspace = true
lazy_static.workspace = true
rand.workspace = true
tempfile.workspace = true
serde.workspace = true
[dev-dependencies]
serial_test.workspace = true
[lints]
workspace = true