-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add Bazel Test Optimization setup docs #37551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tonyredondo
wants to merge
2
commits into
master
Choose a base branch
from
feat/bazel-test-optimization-docs-signed
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| --- | ||
| title: Configure Test Optimization with Bazel | ||
| description: Configure Test Optimization for Bazel test targets with Datadog's official Bazel rules. | ||
| further_reading: | ||
| - link: "/tests/setup/" | ||
| tag: "Documentation" | ||
| text: "Configure Test Optimization" | ||
| - link: "/tests/explorer/" | ||
| tag: "Documentation" | ||
| text: "Explore Test Results and Performance" | ||
| - link: "/tests/troubleshooting/" | ||
| tag: "Documentation" | ||
| text: "Troubleshooting Test Optimization" | ||
| --- | ||
|
|
||
| <div class="alert alert-info">Bazel support for Test Optimization is in Preview.</div> | ||
|
|
||
| Datadog provides official Bazel rules for Test Optimization. Use these rules to configure Bazel test targets. The rules read Test Optimization metadata, write local payload files during test execution, and upload test results to Datadog after Bazel tests complete. | ||
|
|
||
| The Bazel integration keeps Datadog metadata fetches outside test execution. During module or repository resolution, Bazel fetches Test Optimization metadata from Datadog and exposes it through a generated repository. During test execution, language-specific macros pass the metadata location to the test process and configure payloads to be written under `TEST_UNDECLARED_OUTPUTS_DIR`. After tests finish, run the doctor and uploader targets with `bazel run`. | ||
|
|
||
| Test Impact Analysis is not supported for Bazel. | ||
|
|
||
| ## Language setup pages | ||
|
|
||
| Use the language-specific setup page for your Bazel test targets: | ||
|
|
||
| - [Java tests][1] | ||
| - [Python tests][2] | ||
| - [Go tests][3] | ||
|
|
||
| ## Compatibility | ||
|
|
||
| This section includes setup pages for the following language test targets: | ||
|
|
||
| | Language | Bazel macro | Notes | | ||
| |---|---|---| | ||
| | Java | `dd_topt_java_test` | Requires a `dd-java-agent` JAR label. | | ||
| | Python | `dd_topt_py_test` | Supports the managed `pytest` runner and repository-owned pytest wrappers. | | ||
| | Go | `dd_topt_go_test` | Use `test_optimization` mode for the faster standard-library `testing` path, or `general` mode for broader Orchestrion support. | | ||
|
|
||
| Use `datadog-rules-test-optimization` version `1.2.0` and the commit pin shown on each language setup page. | ||
|
|
||
| ## How the Bazel flow works | ||
|
|
||
| The Bazel setup has four parts: | ||
|
|
||
| 1. Add the `datadog-rules-test-optimization` module and the companion module for your language. | ||
| 1. Configure a sync repository with your Datadog service name, runtime name, and runtime version. | ||
| 1. Replace the language test rule with the Datadog Bazel macro for each instrumented test target. | ||
| 1. Run tests, validate local payloads with the doctor target, validate enrichment with the uploader dry run, and then upload payloads. | ||
|
|
||
| For remote execution, configure Bazel to download test outputs locally: | ||
|
|
||
| ```text | ||
| test:test-optimization --remote_download_outputs=all | ||
| ``` | ||
|
|
||
| Without local `test.outputs` directories, the doctor and uploader cannot inspect payload files after `bazel test`. | ||
|
|
||
| ## Upload payloads | ||
|
|
||
| Run the upload flow after your Bazel tests complete. Replace `//tools/test_optimization` with the package where you declared the doctor and uploader targets: | ||
|
|
||
| ```bash | ||
| bazel test --config=test-optimization //... | ||
| bazel run --config=test-optimization //tools/test_optimization:dd_test_optimization_doctor | ||
| bazel run --config=test-optimization //tools/test_optimization:dd_upload_payloads -- --dry-run --validate-enrichment | ||
| DD_API_KEY=<DATADOG_API_KEY> DD_SITE=<DATADOG_SITE> bazel run --config=test-optimization //tools/test_optimization:dd_upload_payloads | ||
|
tonyredondo marked this conversation as resolved.
|
||
| ``` | ||
|
|
||
| Do not pass `DD_API_KEY`, `DD_SITE`, `DD_GIT_*`, or upload endpoint variables through `--test_env`. Forward sync metadata with `--repo_env`, and pass upload credentials only to the uploader runtime. | ||
|
|
||
| ## Further reading | ||
|
|
||
| {{< partial name="whats-next/whats-next.html" >}} | ||
|
|
||
| [1]: /tests/setup/bazel/java/ | ||
| [2]: /tests/setup/bazel/python/ | ||
| [3]: /tests/setup/bazel/go/ | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we say it's in preview?
In Datadog lingo, that generally means customers need to request access for the feature first: https://datadoghq.atlassian.net/wiki/spaces/PM/pages/4371088276/How+to+See+Preview+Requests+and+Enablement+Status#What%E2%80%99s-a-Preview%3F