Buscar flaky tests
https://api.datadoghq.com/api/v2/test/flaky-test-management/testshttps://api.us3.datadoghq.com/api/v2/test/flaky-test-management/testshttps://api.us5.datadoghq.com/api/v2/test/flaky-test-management/testshttps://api.datadoghq.eu/api/v2/test/flaky-test-management/testshttps://api.ap1.datadoghq.com/api/v2/test/flaky-test-management/testshttps://api.ap2.datadoghq.com/api/v2/test/flaky-test-management/testshttps://api.uk1.datadoghq.com/api/v2/test/flaky-test-management/testshttps://api.ddog-gov.com/api/v2/test/flaky-test-management/testshttps://api.us2.ddog-gov.com/api/v2/test/flaky-test-management/testsDescripción general
Enumerar el endpoint que devuelve flaky tests de Flaky Test Management. Los resultados están paginados.
OAuth apps require the test_optimization_read authorization scope to access this endpoint.
Solicitud
Body Data
dataLa solicitud de búsqueda de flaky tests.
attributesAttributes for the flaky tests search request.
filterSearch filter settings.
include_historyWhether to include the status change history for each flaky test in the response.
When set to true, each test will include a history array with chronological status changes.
Defaults to false.
falsequerySearch query following log syntax used to filter flaky tests, same as on Flaky Tests Management UI. The supported search keys are:
flaky_test_stateflaky_test_category@test.name@test.suite@test.module@test.service@git.repository.id_v2@git.branch@test.codeownersenvfingerprint_fqn
Use fingerprint_fqn to filter by a test's stable Fingerprint FQN (the same value as the test's id).
*pagePagination attributes for listing flaky tests.
cursorList following results with a cursor provided in the previous request.
limitMaximum number of flaky tests in the response.
10sortParameter for sorting flaky test results. The default sort is by ascending Fully Qualified Name (FQN). The FQN is the concatenation of the test module, suite, and name.
fqn, -fqn, first_flaked, -first_flaked, last_flaked, -last_flaked, failure_rate, -failure_rate, pipelines_failed, -pipelines_failedShow 2 more
pipelines_duration_lost, -pipelines_duration_losttypeThe definition of FlakyTestsSearchRequestDataType object.
search_flaky_tests_request{
"data": {
"attributes": {
"filter": {
"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/test-service\""
},
"page": {
"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
"limit": 25
},
"sort": "failure_rate"
},
"type": "search_flaky_tests_request"
}
}Respuesta
OK
Response object with flaky tests matching the search request.
dataArray of flaky tests matching the request.
attributesAttributes of a flaky test.
attempt_to_fix_idUnique identifier for the attempt to fix this flaky test. Use this ID in the Git commit message in order to trigger the attempt to fix workflow.
When the workflow is triggered the test is automatically retried by the tracer a certain number of configurable times. When all retries pass, the test is automatically marked as fixed in Flaky Test Management. Test runs are tagged with @test.test_management.attempt_to_fix_passed and @test.test_management.is_attempt_to_fix when the attempt to fix workflow is triggered.
codeownersThe name of the test's code owners as inferred from the repository configuration.
envsList of environments where this test has been flaky.
first_flaked_branchThe branch name where the test exhibited flakiness for the first time.
first_flaked_shaThe commit SHA where the test exhibited flakiness for the first time.
first_flaked_tsUnix timestamp when the test exhibited flakiness for the first time.
flaky_categoryThe category of a flaky test.
flaky_stateThe current state of the flaky test.
active, fixed, quarantined, disabledhistoryChronological history of status changes for this flaky test, ordered from most recent to oldest. Includes state transitions like new -> quarantined -> fixed, along with the associated commit SHA when available.
commit_sha [required]The commit SHA associated with this status change. Will be an empty string if the commit SHA is not available.
policy_idThe policy that triggered this status change.
ftm_policy.manual, ftm_policy.fixed, ftm_policy.disable.failure_rate, ftm_policy.disable.branch_flake, ftm_policy.disable.days_active, ftm_policy.quarantine.failure_rate, ftm_policy.quarantine.branch_flake, ftm_policy.quarantine.days_active, unknownpolicy_metaMetadata about the policy that triggered this status change.
branchesBranches where the test was flaky at the time of the status change.
configConfiguration parameters of the policy that triggered this status change.
branchesThe branches considered by the policy.
days_activeThe number of days a test must have been active for the policy to trigger.
failure_rateThe failure rate threshold for the policy to trigger.
forget_branchesBranches excluded from the policy evaluation.
required_runsThe minimum number of test runs required for the policy to trigger.
stateThe target state the policy transitions the test from.
test_servicesTest services excluded from the policy evaluation.
days_activeThe number of days the test has been active at the time of the status change.
days_without_flakeThe number of days since the test last exhibited flakiness.
failure_rateThe failure rate of the test at the time of the status change.
stateThe previous state of the test.
total_runsThe total number of test runs at the time of the status change.
status [required]The test status at this point in history.
timestamp [required]Unix timestamp in milliseconds when this status change occurred.
impact_levelThe impact level of the flaky test, derived from its impact score.
low, medium, highimpact_scoreA score from 0 to 1 indicating the impact of this flaky test, based on factors such as how often it fails and how many pipelines it affects.
last_flaked_branchThe branch name where the test exhibited flakiness for the last time.
last_flaked_shaThe commit SHA where the test exhibited flakiness for the last time.
last_flaked_tsUnix timestamp when the test exhibited flakiness for the last time.
moduleThe name of the test module. The definition of module changes slightly per language:
- In .NET, a test module groups every test that is run under the same unit test project.
- In Swift, a test module groups every test that is run for a given bundle.
- In JavaScript, the test modules map one-to-one to test sessions.
- In Java, a test module groups every test that is run by the same Maven Surefire/Failsafe or Gradle Test task execution.
- In Python, a test module groups every test that is run under the same
.pyfile as part of a test suite, which is typically managed by a framework likeunittestorpytest. - In Ruby, a test module groups every test that is run within the same test file, which is typically managed by a framework like
RSpecorMinitest.
nameThe test name. A concise name for a test case. Defined in the test itself.
pipeline_statsCI pipeline related statistics for the flaky test. This information is only available if test runs are associated with CI pipeline events from CI Visibility.
failed_pipelinesThe number of pipelines that failed due to this test for the past 7 days. This is computed as the sum of failed CI pipeline events associated with test runs where the flaky test failed.
total_lost_time_msThe total time lost by CI pipelines due to this flaky test in milliseconds. This is computed as the sum of the duration of failed CI pipeline events associated with test runs where the flaky test failed.
servicesList of test service names where this test has been flaky.
A test service is a group of tests associated with a project or repository. It contains all the individual tests for your code, optionally organized into test suites, which are like folders for your tests.
suiteThe name of the test suite. A group of tests exercising the same unit of code depending on your language and testing framework.
test_run_metadataMetadata about the latest failed test run of the flaky test.
duration_msThe duration of the test run in milliseconds.
error_messageThe error message from the test failure.
error_stackThe stack trace from the test failure.
source_endThe line number where the test ends in the source file.
source_fileThe source file where the test is defined.
source_startThe line number where the test starts in the source file.
test_statsTest statistics for the flaky test.
failure_rate_pctThe failure rate percentage of the test for the past 7 days. This is the number of failed test runs divided by the total number of test runs (excluding skipped test runs).
idTest's ID. This ID is the hash of the test's Fully Qualified Name and Git repository ID. It is the
value of the @test.fingerprint_fqn facet on test events, which you can search on in the Test
Optimization Explorer to locate a specific test. To filter search results by this ID, use the
fingerprint_fqn search key.
typeThe type of the flaky test from Flaky Test Management.
flaky_testmetaMetadata for the flaky tests search response.
paginationPagination metadata for flaky tests.
next_pageCursor for the next page of results.
{
"data": [
{
"attributes": {
"attempt_to_fix_id": "I42TEO",
"codeowners": [
"@foo",
"@bar"
],
"envs": "prod",
"first_flaked_branch": "main",
"first_flaked_sha": "0c6be03165b7f7ffe96e076ffb29afb2825616c3",
"first_flaked_ts": 1757688149,
"flaky_category": "Timeout",
"flaky_state": "active",
"history": [
{
"commit_sha": "abc123def456",
"policy_id": "ftm_policy.quarantine.failure_rate",
"policy_meta": {
"branches": [
"main",
"develop"
],
"config": {
"branches": [
"main"
],
"days_active": 30,
"failure_rate": 0.7,
"forget_branches": [
"release"
],
"required_runs": 100,
"state": "quarantined",
"test_services": [
"my-service"
]
},
"days_active": 15,
"days_without_flake": 30,
"failure_rate": 0.25,
"state": "quarantined",
"total_runs": 200
},
"status": "quarantined",
"timestamp": 1704067200000
}
],
"impact_level": "medium",
"impact_score": 0.78,
"last_flaked_branch": "main",
"last_flaked_sha": "0c6be03165b7f7ffe96e076ffb29afb2825616c3",
"last_flaked_ts": 1757688149,
"module": "TestModule",
"name": "TestName",
"pipeline_stats": {
"failed_pipelines": 319,
"total_lost_time_ms": 1527550000
},
"services": [
"foo",
"bar"
],
"suite": "TestSuite",
"test_run_metadata": {
"duration_ms": 27398,
"error_message": "Expecting actual not to be empty",
"error_stack": "Traceback (most recent call last):\n File \"test_foo.py\", line 10, in test_foo\n assert actual == expected\nAssertionError: Expecting actual not to be empty",
"source_end": 20,
"source_file": "test_foo.py",
"source_start": 10
},
"test_stats": {
"failure_rate_pct": 0.1
}
},
"id": "string",
"type": "string"
}
],
"meta": {
"pagination": {
"next_page": "string"
}
}
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Not Authorized
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Ejemplo de código
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/test/flaky-test-management/tests" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"filter": {
"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/test-service\""
},
"page": {
"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
"limit": 25
},
"sort": "failure_rate"
},
"type": "search_flaky_tests_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/test/flaky-test-management/tests" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"filter": {
"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/test-service\""
},
"page": {
"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
"limit": 25
},
"sort": "failure_rate"
},
"type": "search_flaky_tests_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/test/flaky-test-management/tests" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"filter": {
"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/test-service\""
},
"page": {
"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
"limit": 25
},
"sort": "failure_rate"
},
"type": "search_flaky_tests_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/test/flaky-test-management/tests" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"filter": {
"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/test-service\""
},
"page": {
"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
"limit": 25
},
"sort": "failure_rate"
},
"type": "search_flaky_tests_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/test/flaky-test-management/tests" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"filter": {
"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/test-service\""
},
"page": {
"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
"limit": 25
},
"sort": "failure_rate"
},
"type": "search_flaky_tests_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/test/flaky-test-management/tests" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"filter": {
"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/test-service\""
},
"page": {
"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
"limit": 25
},
"sort": "failure_rate"
},
"type": "search_flaky_tests_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/test/flaky-test-management/tests" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"filter": {
"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/test-service\""
},
"page": {
"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
"limit": 25
},
"sort": "failure_rate"
},
"type": "search_flaky_tests_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/test/flaky-test-management/tests" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"filter": {
"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/test-service\""
},
"page": {
"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
"limit": 25
},
"sort": "failure_rate"
},
"type": "search_flaky_tests_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/test/flaky-test-management/tests" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"filter": {
"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/test-service\""
},
"page": {
"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
"limit": 25
},
"sort": "failure_rate"
},
"type": "search_flaky_tests_request"
}
}
EOF// Search flaky tests returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.FlakyTestsSearchRequest{
Data: &datadogV2.FlakyTestsSearchRequestData{
Attributes: &datadogV2.FlakyTestsSearchRequestAttributes{
Filter: &datadogV2.FlakyTestsSearchFilter{
IncludeHistory: datadog.PtrBool(true),
Query: datadog.PtrString(`flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"`),
},
Page: &datadogV2.FlakyTestsSearchPageOptions{
Cursor: datadog.PtrString("eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ=="),
Limit: datadog.PtrInt64(25),
},
Sort: datadogV2.FLAKYTESTSSEARCHSORT_FAILURE_RATE_ASCENDING.Ptr(),
},
Type: datadogV2.FLAKYTESTSSEARCHREQUESTDATATYPE_SEARCH_FLAKY_TESTS_REQUEST.Ptr(),
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewTestOptimizationApi(apiClient)
resp, r, err := api.SearchFlakyTests(ctx, *datadogV2.NewSearchFlakyTestsOptionalParameters().WithBody(body))
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `TestOptimizationApi.SearchFlakyTests`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `TestOptimizationApi.SearchFlakyTests`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Search flaky tests returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.TestOptimizationApi;
import com.datadog.api.client.v2.api.TestOptimizationApi.SearchFlakyTestsOptionalParameters;
import com.datadog.api.client.v2.model.FlakyTestsSearchFilter;
import com.datadog.api.client.v2.model.FlakyTestsSearchPageOptions;
import com.datadog.api.client.v2.model.FlakyTestsSearchRequest;
import com.datadog.api.client.v2.model.FlakyTestsSearchRequestAttributes;
import com.datadog.api.client.v2.model.FlakyTestsSearchRequestData;
import com.datadog.api.client.v2.model.FlakyTestsSearchRequestDataType;
import com.datadog.api.client.v2.model.FlakyTestsSearchResponse;
import com.datadog.api.client.v2.model.FlakyTestsSearchSort;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
TestOptimizationApi apiInstance = new TestOptimizationApi(defaultClient);
FlakyTestsSearchRequest body =
new FlakyTestsSearchRequest()
.data(
new FlakyTestsSearchRequestData()
.attributes(
new FlakyTestsSearchRequestAttributes()
.filter(
new FlakyTestsSearchFilter()
.includeHistory(true)
.query(
"""
flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"
"""))
.page(
new FlakyTestsSearchPageOptions()
.cursor(
"eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==")
.limit(25L))
.sort(FlakyTestsSearchSort.FAILURE_RATE_ASCENDING))
.type(FlakyTestsSearchRequestDataType.SEARCH_FLAKY_TESTS_REQUEST));
try {
FlakyTestsSearchResponse result =
apiInstance.searchFlakyTests(new SearchFlakyTestsOptionalParameters().body(body));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling TestOptimizationApi#searchFlakyTests");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Search flaky tests returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.test_optimization_api import TestOptimizationApi
from datadog_api_client.v2.model.flaky_tests_search_filter import FlakyTestsSearchFilter
from datadog_api_client.v2.model.flaky_tests_search_page_options import FlakyTestsSearchPageOptions
from datadog_api_client.v2.model.flaky_tests_search_request import FlakyTestsSearchRequest
from datadog_api_client.v2.model.flaky_tests_search_request_attributes import FlakyTestsSearchRequestAttributes
from datadog_api_client.v2.model.flaky_tests_search_request_data import FlakyTestsSearchRequestData
from datadog_api_client.v2.model.flaky_tests_search_request_data_type import FlakyTestsSearchRequestDataType
from datadog_api_client.v2.model.flaky_tests_search_sort import FlakyTestsSearchSort
body = FlakyTestsSearchRequest(
data=FlakyTestsSearchRequestData(
attributes=FlakyTestsSearchRequestAttributes(
filter=FlakyTestsSearchFilter(
include_history=True,
query='flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"',
),
page=FlakyTestsSearchPageOptions(
cursor="eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
limit=25,
),
sort=FlakyTestsSearchSort.FAILURE_RATE_ASCENDING,
),
type=FlakyTestsSearchRequestDataType.SEARCH_FLAKY_TESTS_REQUEST,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = TestOptimizationApi(api_client)
response = api_instance.search_flaky_tests(body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Search flaky tests returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::TestOptimizationAPI.new
body = DatadogAPIClient::V2::FlakyTestsSearchRequest.new({
data: DatadogAPIClient::V2::FlakyTestsSearchRequestData.new({
attributes: DatadogAPIClient::V2::FlakyTestsSearchRequestAttributes.new({
filter: DatadogAPIClient::V2::FlakyTestsSearchFilter.new({
include_history: true,
query: 'flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"',
}),
page: DatadogAPIClient::V2::FlakyTestsSearchPageOptions.new({
cursor: "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
limit: 25,
}),
sort: DatadogAPIClient::V2::FlakyTestsSearchSort::FAILURE_RATE_ASCENDING,
}),
type: DatadogAPIClient::V2::FlakyTestsSearchRequestDataType::SEARCH_FLAKY_TESTS_REQUEST,
}),
})
opts = {
body: body,
}
p api_instance.search_flaky_tests(opts)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Search flaky tests returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_test_optimization::SearchFlakyTestsOptionalParams;
use datadog_api_client::datadogV2::api_test_optimization::TestOptimizationAPI;
use datadog_api_client::datadogV2::model::FlakyTestsSearchFilter;
use datadog_api_client::datadogV2::model::FlakyTestsSearchPageOptions;
use datadog_api_client::datadogV2::model::FlakyTestsSearchRequest;
use datadog_api_client::datadogV2::model::FlakyTestsSearchRequestAttributes;
use datadog_api_client::datadogV2::model::FlakyTestsSearchRequestData;
use datadog_api_client::datadogV2::model::FlakyTestsSearchRequestDataType;
use datadog_api_client::datadogV2::model::FlakyTestsSearchSort;
#[tokio::main]
async fn main() {
let body =
FlakyTestsSearchRequest
::new().data(
FlakyTestsSearchRequestData::new()
.attributes(
FlakyTestsSearchRequestAttributes::new()
.filter(
FlakyTestsSearchFilter::new()
.include_history(true)
.query(
r#"flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist""#.to_string(),
),
)
.page(
FlakyTestsSearchPageOptions::new()
.cursor(
"eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==".to_string(),
)
.limit(25),
)
.sort(FlakyTestsSearchSort::FAILURE_RATE_ASCENDING),
)
.type_(FlakyTestsSearchRequestDataType::SEARCH_FLAKY_TESTS_REQUEST),
);
let configuration = datadog::Configuration::new();
let api = TestOptimizationAPI::with_config(configuration);
let resp = api
.search_flaky_tests(SearchFlakyTestsOptionalParams::default().body(body))
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Search flaky tests returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.TestOptimizationApi(configuration);
const params: v2.TestOptimizationApiSearchFlakyTestsRequest = {
body: {
data: {
attributes: {
filter: {
includeHistory: true,
query: `flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"`,
},
page: {
cursor:
"eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
limit: 25,
},
sort: "failure_rate",
},
type: "search_flaky_tests_request",
},
},
};
apiInstance
.searchFlakyTests(params)
.then((data: v2.FlakyTestsSearchResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"