mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-07-27 20:42:12 -04:00
bot/sql-format-option
7 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b391d7333d |
Persist host type update and honor stored value after restart (#4549)
Fixes two issues that would prevent updating a database while also changing the host type: - We never actually updated the `ModuleKind` in `st_module` (hardcoded to wasm) - We never actually honored the value from `st_module` when instantiating a module To do so, the `Program` type from the datastore crate now carries the `ModuleKind`, forcing call sites to make a decision. Small adjustments to the smoketests / guard crate where made when writing the test for this. # Expected complexity level and risk 1 # Testing - [x] Added smoketest |
||
|
|
e3582131fe |
Migrate to Rust 2024 (#3802)
# Description of Changes It'd be best to review this commit-by-commit, and using [difftastic](https://difftastic.wilfred.me.uk) to easily tell when changes are minor in terms of syntax but a line based diff doesn't show that. # Expected complexity level and risk 3 - edition2024 does bring changes to drop order, which could cause issues with locks, but I looked through [all of the warnings that weren't fixed automatically](https://gistcdn.githack.com/coolreader18/80485ae5c5f82de1784229cce2febb26/raw/ba80f3fecda66ceb34f4f7ad73b98ea02d4893a2/warnings.html) and couldn't find any issues. # Testing n/a; internal code change |
||
|
|
3910b59f08 |
CI - Fix smoketests using wrong binary path (#4280)
# Description of Changes The smoketests try to infer whether to use the built `debug` or `release` binaries.. but the common invocation via `cargo ci smoketests` always pre-builds the release binaries. This was causing people to test the wrong binary locally. # API and ABI breaking changes None. # Expected complexity level and risk 1. # Testing - [x] CI passes Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com> |
||
|
|
2d656d49b6 |
Block procedures from requesting private ip ranges (#4243)
# Description of Changes Blocks procedures from requesting private ip ranges after dns resolution. Adds a new cargo feature to `spacetimedb-standalone` permitting loopback http requests in test environments only. # API and ABI breaking changes None # Expected complexity level and risk 2. I may have missed a range. # Testing - [x] Unit tests for IP address matching - [x] Smoketests for blocking a private IP address |
||
|
|
9686139dbc |
Translate smoketests from Python to Rust (#4102)
# Description of Changes
This PR translates all of our Python smoketests into Rust tests which
can be run from `cargo run`
## Motivation
The purpose of this fivefold:
1. All developers on the team are familiar with Rust
2. It simplifies our devops because we can drop Python as a dependency
to run the tests
3. You can now run all tests in the repo through the single `cargo test`
interface
4. Because we use the `SpacetimeDbGuard` and `cargo test`/`cargo
nextest` we can easily parallelize the smoke tests
5. The smoketests can now use machinery imported from SpacetimeDB crates
(e.g. `bsatn` etc.)
IMPORTANT NOTE!
There are several ways to implement the smoke tests in Rust (none are
great):
1. A separate xtask specifically for the smoke tests
- This doesn't solve the problem of the CLI tests which also use the
`guard` crate
- Idiosyncratic way to run the smoke tests as opposed to cargo test
- Does NOT resolve the cargo within cargo problem because we still have
to build the test modules with cargo
2. A `build.rs` script in `guard` which first builds the executables as
a compile step for compiling guard
- Deadlocks on a cargo lock file conflict (Outer cargo compiles guard →
runs build.rs, inner cargo tries to acquire the build directory lock,
outer cargo holds the directory lock, deadlock)
- If you fix the deadlock by using different target dirs, it still looks
stuck on building guard because it's actually compiling all of
spacetimedb-standalone and spacetimedb-cli.
- Still technically runs cargo inside of cargo.
3. Add `spacetimedb-cli` and `spacetimedb-standalone` as an artifact
dependency of the guard crate
- Has good and clear output but requires +nightly when running the
smoketests and CLI tests, otherwise won't do the right thing. See
https://github.com/rust-lang/cargo/issues/9096
4. Compile the executables at runtime during the tests themselves where
the first test takes a lock while the executables are building using
cargo within cargo
- Makes the tests look like they're taking a long time when they're just
waiting for the build to complete
- Requires relatively complex locking machinery across
binaries/tests/processes
5. A two step solution where the developer has to build the binaries
before calling the smoke tests
- Very error prone
None of these are good. `xtask` is not bad, but doesn't enable us to run
other integration tests in other crates (e.g. the CLI)
(3) is the correct solution and has the best user experience, but it
requires nightly and I don't want to introduce that for all of our
tests.
I have chosen to do a combination of (1) and (4). You will now run the
smoketests with `cargo smoketest`. If you run `cargo test --all` (or use
`guard`) without doing `cargo smoketest` it will fall back to (4) which
compiles the executables at runtime. Running `cargo build` is the **only
way** to ensure that the executables are not stale because of the
internal fingerprint checking. Everything else is fragile not robust.
NOTE! There is no way to avoid cargo within cargo and have the smoke
tests be run as cargo tests because the modules under test must be
compiled with cargo.
# API and ABI breaking changes
Note that this is a BREAKING CHANGE to `cargo test --all`. The
smoketests are now part of `cargo test --all` unless you specifically
exclude them.
# Expected complexity level and risk
3, this is partially AI translated. We need to carefully review to
ensure the semantics have not regressed.
# Testing
<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->
- [ ] <!-- maybe a test you want to do -->
- [ ] <!-- maybe a test you want a reviewer to do, so they can check it
off when they're satisfied. -->
---------
Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
|
||
|
|
a9892aae0e |
Fix logic for ipv6 connections in is_port_available (#4005)
# Description of Changes <!-- Please describe your change, mention any related tickets, and so on here. --> - Small fix for checking to see if a port is available on some given interface. updated: The original implementation here used `bind` to try to discover if a port is currently in use. This isn't reliable due to platform differences - especially on windows where it's apparently acceptable to have a service running on both `0.0.0.0:3000` and `127.0.0.1:3000`. This would cause bind to return successfully when we wanted it to fail. Also: binding on an ipv6 interface when a machine doesn't have ipv6 enabled caused random errors and it was too unreliable to be useful. This new implementation uses `get_socket_info` which returns info on all sockets in use on the system. We can then look through this list to find services which conflict with our requested port. updated 1/14: This PR now includes a fix for flaky CLI tests. Originally we were using `find_free_port` to pick a random free port, but that was causing a race condition which resulted in test flakes. This PR fixes this issue by using `127.0.0.1:0` as the listen addr so the kernel will automatically pick a free port for us. # API and ABI breaking changes <!-- If this is an API or ABI breaking change, please apply the corresponding GitHub label. --> None # Expected complexity level and risk <!-- How complicated do you think these changes are? Grade on a scale from 1 to 5, where 1 is a trivial change, and 5 is a deep-reaching and complex change. This complexity rating applies not only to the complexity apparent in the diff, but also to its interactions with existing and future code. If you answered more than a 2, explain what is complex about the PR, and what other components it interacts with in potentially concerning ways. --> 1 - this is a pretty isolated check, unlikely to introduce larger issues. # Testing <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! --> I tested on macos, windows and linux: ``` ALLOW docusaurus is already running on 127.0.0.1:3000 SpacetimeDB then tries to start on 192.168.1.10:3000 ALLOW docusaurus is already running on ::1:3000 SpacetimeDB then tries to start on 192.168.1.10:3000 DENY docusaurus is already running on ::1:3000 SpacetimeDB then tries to start on 127.0.0.1:3000 DENY docusaurus is already running on 0:0:0:0:0:0:0:0:3000 SpacetimeDB then tries to start on 0.0.0.0:3000 DENY docusaurus is already running on 0:0:0:0:0:0:0:0:3000 SpacetimeDB then tries to start on 127.0.0.1:3000 DENY docusaurus is already running on 0:0:0:0:0:0:0:0:3000 SpacetimeDB then tries to start on 192.168.1.10:3000 DENY docusaurus is already running on 127.0.0.1:3000 SpacetimeDB then tries to start on 0:0:0:0:0:0:0:0:3000 DENY docusaurus is already running on 192.168.1.10:3000 SpacetimeDB then tries to start on 0:0:0:0:0:0:0:0:3000 ``` |
||
|
|
b75bf6decf |
LLM Benchmarking (#3486)
# Description of Changes Introduce a new **LLM benchmarking app** and supporting code. * **CLI:** `llm` with subcommands `run`, `routes list`, `diff`, `ci-check`. * **Runner:** executes globally numbered tasks; filters by `--lang`, `--categories`, `--tasks`, `--providers`, `--models`. * **Providers/clients:** route layer (`provider:model`) with HTTP LLM Vendor clients; env-driven keys/base URLs. * **Evaluation:** deterministic scorers (hash/equality, JSON shape/count, light schema/reducer parity) with clear failure messages. * **Results:** stable JSON schema; single-file HTML viewer to inspect/filter/export CSV. * **Build & guards:** build script for compile-time setup; * **Docs:** `DEVELOP.md` includes `cargo llm …` usage. This PR is the initial addition of the app and its modules (runner, config, routes, prompt/segmentation, scorers, schema/types, defaults/constants/paths/hashing/combine, publishers, spacetime guard, HTML stats viewer). ### How it works 1. **Pick what to run** * Choose tasks (`--tasks 0,7,12`), or a language (`--lang rust|csharp`), or categories (`--categories basics,schema`). * Optionally limit vendors/models (`--providers …`, `--models …`). 2. **Resolve routes** * Read env (API keys + base URLs) and build the active set (e.g., `openai:gpt-5`). 3. **Build context** * Start Spacetime * Publish golden answer modules * Prepare prompts and send to LLM model * Attempt to publish LLM module 4. **Execute calls** * Run the selected tasks within each test against selected models and languages. 5. **Score outputs** * Apply deterministic scorers (hash/equality, JSON shape/count, simple schema/reducer checks). * Record the score and any short failure reason. 6. **Update results file** * Write/update the single results JSON with task/route outcomes, timings, and summaries. # API and ABI breaking changes None. New application and modules; no existing public APIs/ABIs altered. # Expected complexity level and risk **4/5.** New CLI, routing, evaluation, and artifact format. * External model APIs may rate-limit/timeout; concurrency tunable via `LLM_BENCH_CONCURRENCY` / `LLM_BENCH_ROUTE_CONCURRENCY`. # Testing I ran the full test matrix and generated results for every task against every vendor, model, and language (rust + C#). I also tested the CI check locally using [act](https://github.com/nektos/act). **Please verify** * [ ] `llm run --tasks 0,1,2` (explicit `run`) * [ ] `llm run --lang rust --categories basics` (filters) * [ ] `llm run --categories basics,schema` (multiple categories) * [ ] `llm run --lang csharp` (language switch) * [ ] `llm run --providers openai,anthropic --models "openai:gpt-5 anthropic:claude-sonnet-4-5"` (provider/model limits) * [ ] `llm run --hash-only` (dry integrity) * [ ] `llm run --goldens-only` (test goldens only) * [ ] `llm run --force` (skip hash check) * [ ] `llm ci-check` * [ ] Stats viewer loads the JSON; filtering and CSV export work * [ ] CI works as intended --------- Signed-off-by: bradleyshep <148254416+bradleyshep@users.noreply.github.com> Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com> Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com> Co-authored-by: spacetimedb-bot <spacetimedb-bot@users.noreply.github.com> Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com> |