Heroku CI Parallel Test Runs
Last updated July 15, 2022
Heroku CI supports distributing test runs across up to 32 dynos to substanially reduce execution time.
Quick Start
Specify test run parallelism in your app’s app.json
file, under the formation
key:
{
"environments": {
"test": {
"formation": {
"test": {
"quantity": 32
}
}
}
}
}
This configuration launches 32 test dynos per test run.
Parallelizing Your Test Suite
Heroku CI exposes the following environment variables to dynos that are part of a parallel test run:
CI_NODE_TOTAL
: The total number dynos in the test runCI_NODE_INDEX
: The index of this dyno in the test run (zero-indexed)
Use these values to specify to your parallel test runner which tests it should run on each dyno.
Test Runners
Test runners that support parallel execution include (but are not limited to):
Ruby
- ci_queue
- knapsack gem or the Knapsack Pro add-on
Javascript
Ember.js
Databases in Parallel Test Runs
Dynos in a parallel test run share the same instance of any databases (and other add-ons) provisioned for the test run. This means that a Heroku Postgres instance might be shared between up to 32 dynos.
Many testing frameworks expect to have exclusive access to databases. If this is the case for your testing framework, your test runs can provision special in-dyno
plans for Heroku Postgres and Heroku Data for Redis. Modify the plans for these add-ons in your app.json
file like so:
{
"addons": [
"heroku-postgresql:in-dyno",
"heroku-redis:in-dyno"
]
}
Postgres extensions are currently limited by the in-dyno
Heroku Postgres plan. See supported extensions