Files
turso/testing/antithesis/README.md
Pekka Enberg 31d8686632 Local Antithesis test suite runner
Add `thesis`, a local runner for the Antithesis Test Composer templates
in testing/antithesis/, replacing stress-composer/shuffle-run.sh.

thesis runs a template as a single seeded timeline: first_ commands,
randomly chosen driver steps, then finally_ and eventually_ commands.
It seeds Python's global RNG in every command it launches, which the
Antithesis SDK's get_random() and random_choice() fall back to outside
Antithesis, so the same seed replays the same commands with the same
random choices. It also evaluates SDK assertions, which do not raise on
their own: a false always() or a reached unreachable() fails the run,
and a failure prints the command that reproduces it.

Run it from the repository root with:

  uv run --group antithesis thesis run testing/antithesis/stress-composer --seed 42

The antithesis dependency group builds pyturso from the checkout, so
runs exercise local changes.
2026-09-27 10:33:01 +03:00

4.8 KiB

Antithesis Test Suite

Each directory here is an Antithesis test template: executables whose filename prefix (first_, parallel_driver_, singleton_driver_, anytime_, eventually_, finally_, ...) tells Test Composer when to run them. Dockerfile.antithesis copies them to /opt/antithesis/test/v1/.

Running a Template Locally

Use thesis to run a template on your machine as a single seeded timeline. From the repository root:

uv run --group antithesis thesis run testing/antithesis/stress-composer --seed 42 --steps 500 --timeout 2m

The antithesis dependency group builds pyturso from your checkout, so the run tests your local changes (the first run takes a few minutes to compile). thesis seeds the SDK's get_random() and random_choice(), so the same seed replays the same commands with the same random choices. It also evaluates SDK assertions: a failing always() or a reached unreachable() fails the run, as does a command exiting non-zero. On failure it prints a command to reproduce the run up to the failing step, e.g.:

thesis: reproduce with: thesis run .../testing/antithesis/stress-composer --seed 42 --steps 57

Commands run one at a time in a fresh temporary directory, which is kept on failure with each command's output. Other useful flags: --duration 10m or --forever instead of --steps, --strict to also fail on sometimes() and reachable() assertions that never fired, and -v to stream command output. See the thesis README for details and for what a seed does not make reproducible.

How to Dump Artifacts from a Test Run

To dump the stress tool's log and the database from an Antithesis test run, follow these steps. Note that they require access to the Turso tenant (currently only Turso employees and contractors).

First, start a multiverse debugging. In a test run's view, hover over the last timestamp in the log view, then click it to copy the "moment" details. Then, replace the session id, input hash and vtime with yours in the request below. The Authorization header contains a base64-encoded username:password. The values are in the AWS secret manager (link).

curl -X POST --location "https://turso.antithesis.com/api/v1/launch/debugging" \
    -H "Authorization: Basic XXX" \
    -H "Content-Type: application/json" \
    -d '{
          "params": {
            "antithesis.debugging.session_id": "0c5577383578e9291d87c77424671dd7-44-22",
            "antithesis.debugging.input_hash": "5148272061563518",
            "antithesis.debugging.vtime": "23.747334333136678",
            "antithesis.report.recipients": "you@turso.tech"
          }
        }'

After 5 minutes or so, you will receive an email with a link to your session. The left half of the screen is a JavaScript Jupyter-like notebook that you can use to run commands one at a time. on your test environment.

Paste these commands to print a download link to the log:

container = environment.containers.list({moment})[0].name
print(environment.extract_file({moment, path: "limbostress.log", container}))

To get the database, find the log line that looks like this:

db_file=/tmp/.tmpUN86Wk

Don't forget to get the WAL. If it exists, it will be named something like .tmpUN86Wk-wal.

I have the DB and log, now what?

Sometimes it's enough to feed the SQL to Turso to reproduce the issue. Remove the few lines at the start that are just numbers, add semicolonsto lines that don't already have one, and redirect the file to cargo run, using the same VFS as the test. Here's a Vim command for to add semicolons to lines that don't already have one:

:%s/\([^;]\)$/\1;/

If that doesn't do it, then it's going to take more work. You can try observing the state of the B-trees using sqlite-viz. SQLite (and possibly Turso) can mask corruption. sqlite-viz can also dump information about certain pages in a human-readable form (see the dump command and the -p flag for pages, or -t for trees), so that you can either reason better about them, or pass them to an LLM.

You might also try binary-searching for the time that the corruption occurred. The resolution of rewind() is only one millisecond, but that will at least give you an idea:

// play with this
before = moment.rewind(Time.milliseconds(1000))
// for every timestamp you check, download the DB and its WAL
print(environment.extract_file({moment: before, path: "/tmp/.tmp13REAK", container}))
print(environment.extract_file({moment: before, path: "/tmp/.tmp13REAK-wal", container}))