Skip to content

Commit d7c45a9

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add UpdateFlakyTestState endpoint to Flaky Test Management API (#3349)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent e8d45f6 commit d7c45a9

20 files changed

Lines changed: 975 additions & 8 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61408,6 +61408,136 @@ components:
6140861408
- name
6140961409
- options
6141061410
type: object
61411+
UpdateFlakyTestsRequest:
61412+
description: Request to update the state of multiple flaky tests.
61413+
properties:
61414+
data:
61415+
$ref: '#/components/schemas/UpdateFlakyTestsRequestData'
61416+
required:
61417+
- data
61418+
type: object
61419+
UpdateFlakyTestsRequestAttributes:
61420+
description: Attributes for updating flaky test states.
61421+
properties:
61422+
tests:
61423+
description: List of flaky tests to update.
61424+
items:
61425+
$ref: '#/components/schemas/UpdateFlakyTestsRequestTest'
61426+
type: array
61427+
required:
61428+
- tests
61429+
type: object
61430+
UpdateFlakyTestsRequestData:
61431+
description: The JSON:API data for updating flaky test states.
61432+
properties:
61433+
attributes:
61434+
$ref: '#/components/schemas/UpdateFlakyTestsRequestAttributes'
61435+
type:
61436+
$ref: '#/components/schemas/UpdateFlakyTestsRequestDataType'
61437+
required:
61438+
- type
61439+
- attributes
61440+
type: object
61441+
UpdateFlakyTestsRequestDataType:
61442+
description: The definition of `UpdateFlakyTestsRequestDataType` object.
61443+
enum:
61444+
- update_flaky_test_state_request
61445+
example: update_flaky_test_state_request
61446+
type: string
61447+
x-enum-varnames:
61448+
- UPDATE_FLAKY_TEST_STATE_REQUEST
61449+
UpdateFlakyTestsRequestTest:
61450+
description: Details of what tests to update and their new attributes.
61451+
properties:
61452+
id:
61453+
description: The ID of the flaky test. This is the same ID returned by the
61454+
Search flaky tests endpoint and corresponds to the test_fingerprint_fqn
61455+
field in test run events.
61456+
example: 4eb1887a8adb1847
61457+
type: string
61458+
new_state:
61459+
$ref: '#/components/schemas/UpdateFlakyTestsRequestTestNewState'
61460+
required:
61461+
- id
61462+
- new_state
61463+
type: object
61464+
UpdateFlakyTestsRequestTestNewState:
61465+
description: The new state to set for the flaky test.
61466+
enum:
61467+
- active
61468+
- quarantined
61469+
- disabled
61470+
- fixed
61471+
example: active
61472+
type: string
61473+
x-enum-varnames:
61474+
- ACTIVE
61475+
- QUARANTINED
61476+
- DISABLED
61477+
- FIXED
61478+
UpdateFlakyTestsResponse:
61479+
description: Response object for updating flaky test states.
61480+
properties:
61481+
data:
61482+
$ref: '#/components/schemas/UpdateFlakyTestsResponseData'
61483+
type: object
61484+
UpdateFlakyTestsResponseAttributes:
61485+
description: Attributes for the update flaky test state response.
61486+
properties:
61487+
has_errors:
61488+
description: '`True` if any errors occurred during the update operations.
61489+
`False` if all tests succeeded to be updated.'
61490+
example: true
61491+
type: boolean
61492+
results:
61493+
description: Results of the update operation for each test.
61494+
items:
61495+
$ref: '#/components/schemas/UpdateFlakyTestsResponseResult'
61496+
type: array
61497+
required:
61498+
- has_errors
61499+
- results
61500+
type: object
61501+
UpdateFlakyTestsResponseData:
61502+
description: Summary of the update operations. Tells whether a test succeeded
61503+
or failed to be updated.
61504+
properties:
61505+
attributes:
61506+
$ref: '#/components/schemas/UpdateFlakyTestsResponseAttributes'
61507+
id:
61508+
description: The ID of the response.
61509+
type: string
61510+
type:
61511+
$ref: '#/components/schemas/UpdateFlakyTestsResponseDataType'
61512+
type: object
61513+
UpdateFlakyTestsResponseDataType:
61514+
description: The definition of `UpdateFlakyTestsResponseDataType` object.
61515+
enum:
61516+
- update_flaky_test_state_response
61517+
type: string
61518+
x-enum-varnames:
61519+
- UPDATE_FLAKY_TEST_STATE_RESPONSE
61520+
UpdateFlakyTestsResponseResult:
61521+
description: Result of updating a single flaky test state.
61522+
properties:
61523+
error:
61524+
description: Error message if the update failed.
61525+
type: string
61526+
id:
61527+
description: The ID of the flaky test from the request. This is the same
61528+
ID returned by the Search flaky tests endpoint and corresponds to the
61529+
test_fingerprint_fqn field in test run events.
61530+
example: 4eb1887a8adb1847
61531+
type: string
61532+
success:
61533+
description: '`True` if the update was successful, `False` if there were
61534+
any errors.'
61535+
example: false
61536+
type: boolean
61537+
required:
61538+
- id
61539+
- success
61540+
type: object
6141161541
UpdateOnCallNotificationRuleRequest:
6141261542
description: A top-level wrapper for updating a notification rule for a user
6141361543
example:
@@ -63757,6 +63887,8 @@ components:
6375763887
teams_read: Read Teams data. A User with this permission can view Team
6375863888
names, metadata, and which Users are on each Team.
6375963889
test_optimization_read: View Test Optimization.
63890+
test_optimization_write: Update flaky tests from Flaky Tests Management
63891+
of Test Optimization.
6376063892
timeseries_query: Query Timeseries data.
6376163893
usage_read: View your organization's usage and usage attribution.
6376263894
user_access_invite: Invite other users to your organization.
@@ -94990,6 +95122,44 @@ paths:
9499095122
- incident_settings_write
9499195123
x-unstable: '**Note**: This endpoint is deprecated. See the [Teams API endpoints](https://docs.datadoghq.com/api/latest/teams/).'
9499295124
/api/v2/test/flaky-test-management/tests:
95125+
patch:
95126+
description: Update the state of multiple flaky tests in Flaky Test Management.
95127+
operationId: UpdateFlakyTests
95128+
requestBody:
95129+
content:
95130+
application/json:
95131+
schema:
95132+
$ref: '#/components/schemas/UpdateFlakyTestsRequest'
95133+
required: true
95134+
responses:
95135+
'200':
95136+
content:
95137+
application/json:
95138+
schema:
95139+
$ref: '#/components/schemas/UpdateFlakyTestsResponse'
95140+
description: OK
95141+
'400':
95142+
$ref: '#/components/responses/BadRequestResponse'
95143+
'403':
95144+
$ref: '#/components/responses/NotAuthorizedResponse'
95145+
'429':
95146+
$ref: '#/components/responses/TooManyRequestsResponse'
95147+
security:
95148+
- apiKeyAuth: []
95149+
appKeyAuth: []
95150+
- AuthZ:
95151+
- test_optimization_write
95152+
summary: Update flaky test states
95153+
tags:
95154+
- Test Optimization
95155+
x-codegen-request-body-name: body
95156+
x-permission:
95157+
operator: OR
95158+
permissions:
95159+
- test_optimization_write
95160+
x-unstable: '**Note**: This endpoint is in preview and may be subject to change.
95161+
95162+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
9499395163
post:
9499495164
description: List endpoint returning flaky tests from Flaky Test Management.
9499595165
Results are paginated.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Update flaky test states returns "OK" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
configuration.unstableOperations["v2.updateFlakyTests"] = true;
9+
const apiInstance = new v2.TestOptimizationApi(configuration);
10+
11+
const params: v2.TestOptimizationApiUpdateFlakyTestsRequest = {
12+
body: {
13+
data: {
14+
attributes: {
15+
tests: [
16+
{
17+
id: "4eb1887a8adb1847",
18+
newState: "active",
19+
},
20+
],
21+
},
22+
type: "update_flaky_test_state_request",
23+
},
24+
},
25+
};
26+
27+
apiInstance
28+
.updateFlakyTests(params)
29+
.then((data: v2.UpdateFlakyTestsResponse) => {
30+
console.log(
31+
"API called successfully. Returned data: " + JSON.stringify(data)
32+
);
33+
})
34+
.catch((error: any) => console.error(error));

features/support/scenarios_model_mapping.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10106,6 +10106,13 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
1010610106
},
1010710107
"operationResponseType": "FlakyTestsSearchResponse",
1010810108
},
10109+
"v2.UpdateFlakyTests": {
10110+
"body": {
10111+
"type": "UpdateFlakyTestsRequest",
10112+
"format": "",
10113+
},
10114+
"operationResponseType": "UpdateFlakyTestsResponse",
10115+
},
1010910116
"v2.SendInvitations": {
1011010117
"body": {
1011110118
"type": "UserInvitationsRequest",

features/v2/test_optimization.feature

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,59 @@ Feature: Test Optimization
88
Given a valid "apiKeyAuth" key in the system
99
And a valid "appKeyAuth" key in the system
1010
And an instance of "TestOptimization" API
11-
And operation "SearchFlakyTests" enabled
12-
And new "SearchFlakyTests" request
1311

1412
@generated @skip @team:DataDog/ci-app-backend
1513
Scenario: Search flaky tests returns "Bad Request" response
16-
Given body with value {"data": {"attributes": {"filter": {"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"}}
14+
Given operation "SearchFlakyTests" enabled
15+
And new "SearchFlakyTests" request
16+
And body with value {"data": {"attributes": {"filter": {"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"}}
1717
When the request is sent
1818
Then the response status is 400 Bad Request
1919

2020
@skip @team:DataDog/ci-app-backend
2121
Scenario: Search flaky tests returns "Bad Request" response with invalid limit
22-
Given body with value {"data": {"attributes": {"filter": {"query": "*"}, "page": {"limit": 2000}, "sort": "fqn"}, "type": "search_flaky_tests_request"}}
22+
Given operation "SearchFlakyTests" enabled
23+
And new "SearchFlakyTests" request
24+
And body with value {"data": {"attributes": {"filter": {"query": "*"}, "page": {"limit": 2000}, "sort": "fqn"}, "type": "search_flaky_tests_request"}}
2325
When the request is sent
2426
Then the response status is 400 Bad Request
2527

2628
@generated @skip @team:DataDog/ci-app-backend
2729
Scenario: Search flaky tests returns "OK" response
28-
Given body with value {"data": {"attributes": {"filter": {"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"}}
30+
Given operation "SearchFlakyTests" enabled
31+
And new "SearchFlakyTests" request
32+
And body with value {"data": {"attributes": {"filter": {"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"}}
2933
When the request is sent
3034
Then the response status is 200 OK
3135

3236
@replay-only @skip @skip-validation @team:DataDog/ci-app-backend @with-pagination
3337
Scenario: Search flaky tests returns "OK" response with filtered query
34-
Given body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/cart-tracking\""}, "page": {"limit": 10}, "sort": "-last_flaked"}, "type": "search_flaky_tests_request"}}
38+
Given operation "SearchFlakyTests" enabled
39+
And new "SearchFlakyTests" request
40+
And body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/cart-tracking\""}, "page": {"limit": 10}, "sort": "-last_flaked"}, "type": "search_flaky_tests_request"}}
3541
When the request with pagination is sent
3642
Then the response status is 200 OK
3743

3844
@generated @skip @team:DataDog/ci-app-backend @with-pagination
3945
Scenario: Search flaky tests returns "OK" response with pagination
40-
Given body with value {"data": {"attributes": {"filter": {"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"}}
46+
Given operation "SearchFlakyTests" enabled
47+
And new "SearchFlakyTests" request
48+
And body with value {"data": {"attributes": {"filter": {"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"}}
4149
When the request with pagination is sent
4250
Then the response status is 200 OK
51+
52+
@generated @skip @team:DataDog/ci-app-backend
53+
Scenario: Update flaky test states returns "Bad Request" response
54+
Given operation "UpdateFlakyTests" enabled
55+
And new "UpdateFlakyTests" request
56+
And body with value {"data": {"attributes": {"tests": [{"id": "4eb1887a8adb1847", "new_state": "active"}]}, "type": "update_flaky_test_state_request"}}
57+
When the request is sent
58+
Then the response status is 400 Bad Request
59+
60+
@generated @skip @team:DataDog/ci-app-backend
61+
Scenario: Update flaky test states returns "OK" response
62+
Given operation "UpdateFlakyTests" enabled
63+
And new "UpdateFlakyTests" request
64+
And body with value {"data": {"attributes": {"tests": [{"id": "4eb1887a8adb1847", "new_state": "active"}]}, "type": "update_flaky_test_state_request"}}
65+
When the request is sent
66+
Then the response status is 200 OK

features/v2/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5161,6 +5161,12 @@
51615161
"type": "idempotent"
51625162
}
51635163
},
5164+
"UpdateFlakyTests": {
5165+
"tag": "Test Optimization",
5166+
"undo": {
5167+
"type": "unsafe"
5168+
}
5169+
},
51645170
"SearchFlakyTests": {
51655171
"tag": "Test Optimization",
51665172
"undo": {

packages/datadog-api-client-common/configuration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ export function createConfiguration(
388388
"v2.listIncidentTeams": false,
389389
"v2.updateIncidentTeam": false,
390390
"v2.searchFlakyTests": false,
391+
"v2.updateFlakyTests": false,
391392
}
392393
);
393394
configuration.httpApi.zstdCompressorCallback = conf.zstdCompressorCallback;

0 commit comments

Comments
 (0)