Parallel Test Shards

Install dependencies once, then fork into parallel sandboxes to shard work across them.

Intermediate~5 minforkPromise.all

Install dependencies once, then fork the sandbox into N independent copies that each run a shard of the test suite in parallel — cutting wall-clock time roughly by the number of shards, without repeating the install in every shard.

Setup

Start OpenSandbox in Docker (one-time setup):

bunx alineo-cli init

Run it

cookbooks/parallel-test-shards
$bun install
$bun start
Simulated preview — no sandbox is actually created here.Run it for real →

What it does

Creates one base sandbox, installs pytest, and writes three small test files to it.

Calls base.fork() three times — each fork branches off the base sandbox's state, so none of them repeat the pip install.

Runs a different test file in each fork with Promise.all, in parallel.

Aggregates each shard's exit code and a one-line summary into an overall pass/fail report.

Generalizing to a real repo

Install dependencies and discover shard boundaries once in the base sandbox, then fork once per shard (or per CPU core) instead of paying setup cost N times. See Forking Sandboxes for the underlying sb.fork() primitive.

Server proxy

All examples default to useServerProxy: true — traffic routes through the OpenSandbox server so Docker bridge IPs don't need to be reachable directly. Set USE_SERVER_PROXY=false to disable (e.g. when using uvx opensandbox-server on the host).