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.
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
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:
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.
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.