Agent test environments
Give your agent, your tests and your pull requests their own live copy of your app, with data and logins ready.
One command gives you a running copy of your app, called a sandbox or test environment, with data and logins ready. You, a test or a coding agent can use it, break it and throw it away without touching anything else.
Each sandbox is a full virtual machine, so your database and background services run in it. Outside services like email and sign-in are replaced by stand-ins. You describe the sandbox once in cofactor.sandbox.yaml. If your application has none yet, build one from GitHub or from a pushed image.
Claim a sandbox
-
Find your application.
bashcofactor application list
-
Claim a copy.
Open Test environments in the app, find your application and select Claim on an environment.
The claim prints a URL for each public port, a login for each role (with its password), and what the seeds created. If your agent keeps a log, have it report only the URLs and emails.
The Test environments page. An application lists its environments with a Claim button, and the live sandboxes table shows the build, status and expiry. -
Use it. Open the URL and sign in with a printed login. You can also run a test on it.
bashcofactor workflow run <workflow id> --sandbox <sandbox id> --stream
-
Put your changes in it. See Test locally.
bashcofactor sandbox sync <sandbox id>
-
Destroy it.
bashcofactor sandbox destroy <sandbox id>
Check it worked
cofactor sandbox claims cofactor sandbox show <sandbox id>
The status reads ready. The URL serves your app over https and each login signs in with its role. After destroy, claims no longer lists it.
Go deeper
- Build from GitHub and build from a pushed image
- Preview environments
- Emulators
- Seed data and logins
- Test locally
- Reference:
cofactor.sandbox.yaml, Sandbox CLI
How claims work, flavors, lifetimes and errors.
How a claim works. Cofactor builds and seeds your app once per version and environment, and saves the result as a ready snapshot. Each claim restores its own copy. Only the first claim of a new version waits for the build.
Flavors. An environment is the same sandbox with different data or settings, such as default or free-plan. --environment <name> picks one. Each shows up as an environment of your application.
Versions. --at <version> claims a commit SHA for GitHub, or a push id or tag for an image. --from-local starts from your uncommitted files.
Lifetimes. A claimed sandbox lasts 2 hours. Each sync adds 2 hours, up to 8 hours after the claim. A PR preview expires 24 hours after the last push to the pull request, and never lives past two weeks.
Fit. A sandbox is one Linux amd64 machine with no Docker inside. Run cofactor sandbox guide feasibility to check each dependency before you build.
Limits.
| Limit | Value |
|---|---|
| Ports per sandbox | 8, including the ports Cofactor adds for sync, emulators and object storage |
vCPUs (resources.vcpus) | 1 to 32 |
Memory (resources.memory_mib) | 1,024 to 65,536 MiB |
| Definition file size | 256 KB |
| Action timeout | 1 to 1,800 seconds, 60 by default |
| Time for services to turn healthy | 5 minutes |
| Layer size in a pushed image | 5 GB |
| Tags per push | 10 |
| Claimed sandbox lease | 2 hours |
Statuses. A sandbox is claiming, ready, failed or destroyed. A pushed image is uploading, importing, ready or failed, and becomes upgraded when a newer push replaces it after a platform upgrade.
Errors. A failed build, prepare or seed fails every claim waiting on it. Fix it and commit or push again.