Ce produit n'est pas pris en charge par le site Datadog que vous avez sélectionné. ().
Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
Join the Preview!
Test Parallelization is in Preview. Complete the form to request access.
For Ruby: use the datadog-ci gem version 1.31.0 or later.
For Python: use the ddtrace package version 4.11.0 or later and pytest.
For JavaScript: use the dd-trace package version 5.111.0 or later for v5 or v6.0.0 or later for v6, Node.js, and Jest.
Enable Test Impact Analysis for the test service when you want Test Parallelization to split only the tests affected by a code change.
Concepts
Runner
A program that runs tests. ddtest can run tests directly or write file lists for another runner.
CI node
One CI execution environment, such as a GitHub Actions job, CircleCI parallel container, Kubernetes pod, VM, or local machine.
Worker
A process started by ddtest to execute tests. One CI node can run one worker or multiple workers.
Plan
The generated .testoptimization/ directory. It contains the runnable test files, the selected parallelism, and per-node file lists used by ddtest run or another runner.
Selected parallelism
The CI node count or local worker count that ddtest chooses after estimating test file durations.
Install ddtest
Install the ddtest CLI in your CI job. Datadog publishes precompiled binaries in GitHub Releases.
If you run your tests on a single CI node, run ddtest run:
bin/ddtest run --platform ruby --framework rspec
bin/ddtest run --platform python --framework pytest
bin/ddtest run --platform javascript --framework jest
By default, ddtest can start one worker for each physical CPU core available on the node.
Run across multiple CI nodes
For multiple CI nodes, run ddtest plan once, share the .testoptimization/ directory with every CI node, and pass each node its zero-indexed CI node number:
bin/ddtest plan \
--platform javascript \
--framework jest \
--min-parallelism 1\
--max-parallelism 8bin/ddtest run \
--platform javascript \
--framework jest \
--ci-node <CI_NODE_INDEX>
In CI-node mode, ddtest uses one local worker by default. To start multiple workers in each CI node, set --ci-node-workers to a positive integer or ncpu.
For a list of available environment variables, defaults, and examples, see Configuration.
CI examples
Use the following examples as starting points for GitHub Actions and CircleCI.
Ruby
The plan job chooses the CI node count and emits a matrix. The test job downloads the .testoptimization/ artifact and runs only the files assigned to its matrix node.
name:CI with Test Parallelizationon:[push]env:DD_TEST_OPTIMIZATION_RUNNER_PLATFORM:rubyDD_TEST_OPTIMIZATION_RUNNER_FRAMEWORK:rspecDD_TEST_OPTIMIZATION_RUNNER_MIN_PARALLELISM:1DD_TEST_OPTIMIZATION_RUNNER_MAX_PARALLELISM:8jobs:dd_plan:runs-on:ubuntu-latestoutputs:matrix:${{ steps.dd_plan.outputs.matrix }}steps:- uses:actions/checkout@v4- name:Download ddtest binaryrun:| mkdir -p bin
gh release download --repo DataDog/ddtest --pattern "ddtest-linux-amd64" --dir bin
mv bin/ddtest-linux-amd64 bin/ddtest
chmod +x bin/ddtestenv:GH_TOKEN:${{ github.token }}- name:Setup Rubyuses:ruby/setup-ruby@v1with:bundler-cache:true- name:Configure Datadog Test Optimizationuses:datadog/test-visibility-github-action@v2with:languages:rubyapi_key:${{ secrets.DD_API_KEY }}site:datadoghq.com- id:dd_planname:Plan test executionrun:bin/ddtest plan- uses:actions/upload-artifact@v4with:name:dd-artifactspath:.testoptimizationinclude-hidden-files:truedd_test:runs-on:ubuntu-latestneeds:[dd_plan]strategy:fail-fast:falsematrix:${{ fromJson(needs.dd_plan.outputs.matrix) }}steps:- uses:actions/checkout@v4- name:Download ddtest binaryrun:| mkdir -p bin
gh release download --repo DataDog/ddtest --pattern "ddtest-linux-amd64" --dir bin
mv bin/ddtest-linux-amd64 bin/ddtest
chmod +x bin/ddtestenv:GH_TOKEN:${{ github.token }}- uses:actions/download-artifact@v4with:name:dd-artifactspath:.testoptimization- name:Setup Rubyuses:ruby/setup-ruby@v1with:bundler-cache:true- name:Configure Datadog Test Optimizationuses:datadog/test-visibility-github-action@v2with:languages:rubyapi_key:${{ secrets.DD_API_KEY }}site:datadoghq.com- name:Run testsrun:bin/ddtest run --ci-node ${{ matrix.ci_node_index }}
The setup workflow runs ddtest plan, stores .testoptimization/, and continues into a test workflow with the selected CI node count.
The plan job chooses the CI node count and emits a matrix. The test job downloads the .testoptimization/ artifact and runs only the files assigned to its matrix node.
Replace each language setup step with Node.js dependency installation:
- name:Setup Node.jsuses:actions/setup-node@v4with:node-version:"22"cache:npm- name:Install JavaScript dependenciesrun:npm ci
Configure Datadog Test Optimization for JavaScript:
- name:Configure Datadog Test Optimizationuses:datadog/test-visibility-github-action@v2with:languages:jsapi_key:${{ secrets.DD_API_KEY }}site:datadoghq.com
The ddtest plan and ddtest run --ci-node ${{ matrix.ci_node_index }} commands remain unchanged when the platform and framework are provided through the environment.
Use a Node.js image and set the runner environment in the plan job:
Keep the ddtest download, plan, cache, and continuation steps from the CircleCI workflow. In the test job, install dependencies, autoinstrument JavaScript, and pass the CircleCI node index to ddtest:
- run:name:Install JavaScript dependenciescommand:npm ci- test-optimization-circleci-orb/autoinstrument:languages:jssite:datadoghq.com- run:name:Run testscommand:| NODE_INDEX=${CIRCLE_NODE_INDEX:-0}
bin/ddtest run --platform javascript --framework jest --ci-node "${NODE_INDEX}"
`ddtest` prepends `NODE_OPTIONS=-r dd-trace/ci/init` for Jest worker processes, so the project dependencies installed before `ddtest plan` must include `dd-trace`.
Use third-party test runners
Use ddtest plan files when you want ddtest to choose which files should run, but another runner should execute them.
To learn about the full contents of the plan directory, see Plan artifacts.
File
Use
.testoptimization/runner/test-files.txt
All runnable test files after Test Impact Analysis skips are applied.
.testoptimization/runner/tests-split/runner-N
Files assigned to CI node or worker N.
For example, use .testoptimization/runner/test-files.txt with Knapsack Pro: