Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 170 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61289,6 +61289,136 @@ components:
- name
- options
type: object
UpdateFlakyTestsRequest:
description: Request to update the state of multiple flaky tests.
properties:
data:
$ref: '#/components/schemas/UpdateFlakyTestsRequestData'
required:
- data
type: object
UpdateFlakyTestsRequestAttributes:
description: Attributes for updating flaky test states.
properties:
tests:
description: List of flaky tests to update.
items:
$ref: '#/components/schemas/UpdateFlakyTestsRequestTest'
type: array
required:
- tests
type: object
UpdateFlakyTestsRequestData:
description: The JSON:API data for updating flaky test states.
properties:
attributes:
$ref: '#/components/schemas/UpdateFlakyTestsRequestAttributes'
type:
$ref: '#/components/schemas/UpdateFlakyTestsRequestDataType'
required:
- type
- attributes
type: object
UpdateFlakyTestsRequestDataType:
description: The definition of `UpdateFlakyTestsRequestDataType` object.
enum:
- update_flaky_test_state_request
example: update_flaky_test_state_request
type: string
x-enum-varnames:
- UPDATE_FLAKY_TEST_STATE_REQUEST
UpdateFlakyTestsRequestTest:
description: Details of what tests to update and their new attributes.
properties:
id:
description: The ID of the flaky test. This is the same ID returned by the
Search flaky tests endpoint and corresponds to the test_fingerprint_fqn
field in test run events.
example: 4eb1887a8adb1847
type: string
new_state:
$ref: '#/components/schemas/UpdateFlakyTestsRequestTestNewState'
required:
- id
- new_state
type: object
UpdateFlakyTestsRequestTestNewState:
description: The new state to set for the flaky test.
enum:
- active
- quarantined
- disabled
- fixed
example: active
type: string
x-enum-varnames:
- ACTIVE
- QUARANTINED
- DISABLED
- FIXED
UpdateFlakyTestsResponse:
description: Response object for updating flaky test states.
properties:
data:
$ref: '#/components/schemas/UpdateFlakyTestsResponseData'
type: object
UpdateFlakyTestsResponseAttributes:
description: Attributes for the update flaky test state response.
properties:
has_errors:
description: '`True` if any errors occurred during the update operations.
`False` if all tests succeeded to be updated.'
example: true
type: boolean
results:
description: Results of the update operation for each test.
items:
$ref: '#/components/schemas/UpdateFlakyTestsResponseResult'
type: array
required:
- has_errors
- results
type: object
UpdateFlakyTestsResponseData:
description: Summary of the update operations. Tells whether a test succeeded
or failed to be updated.
properties:
attributes:
$ref: '#/components/schemas/UpdateFlakyTestsResponseAttributes'
id:
description: The ID of the response.
type: string
type:
$ref: '#/components/schemas/UpdateFlakyTestsResponseDataType'
type: object
UpdateFlakyTestsResponseDataType:
description: The definition of `UpdateFlakyTestsResponseDataType` object.
enum:
- update_flaky_test_state_response
type: string
x-enum-varnames:
- UPDATE_FLAKY_TEST_STATE_RESPONSE
UpdateFlakyTestsResponseResult:
description: Result of updating a single flaky test state.
properties:
error:
description: Error message if the update failed.
type: string
id:
description: The ID of the flaky test from the request. This is the same
ID returned by the Search flaky tests endpoint and corresponds to the
test_fingerprint_fqn field in test run events.
example: 4eb1887a8adb1847
type: string
success:
description: '`True` if the update was successful, `False` if there were
any errors.'
example: false
type: boolean
required:
- id
- success
type: object
UpdateOnCallNotificationRuleRequest:
description: A top-level wrapper for updating a notification rule for a user
example:
Expand Down Expand Up @@ -63638,6 +63768,8 @@ components:
teams_read: Read Teams data. A User with this permission can view Team
names, metadata, and which Users are on each Team.
test_optimization_read: View Test Optimization.
test_optimization_write: Update flaky tests from Flaky Tests Management
of Test Optimization.
timeseries_query: Query Timeseries data.
usage_read: View your organization's usage and usage attribution.
user_access_invite: Invite other users to your organization.
Expand Down Expand Up @@ -94850,6 +94982,44 @@ paths:
- incident_settings_write
x-unstable: '**Note**: This endpoint is deprecated. See the [Teams API endpoints](https://docs.datadoghq.com/api/latest/teams/).'
/api/v2/test/flaky-test-management/tests:
patch:
description: Update the state of multiple flaky tests in Flaky Test Management.
operationId: UpdateFlakyTests
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateFlakyTestsRequest'
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateFlakyTestsResponse'
description: OK
'400':
$ref: '#/components/responses/BadRequestResponse'
'403':
$ref: '#/components/responses/NotAuthorizedResponse'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- test_optimization_write
summary: Update flaky test states
tags:
- Test Optimization
x-codegen-request-body-name: body
x-permission:
operator: OR
permissions:
- test_optimization_write
x-unstable: '**Note**: This endpoint is in preview and may be subject to change.

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
post:
description: List endpoint returning flaky tests from Flaky Test Management.
Results are paginated.
Expand Down
22 changes: 22 additions & 0 deletions examples/v2/test-optimization/UpdateFlakyTests.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Update flaky test states returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.unstable_operations["v2.update_flaky_tests".to_sym] = true
end
api_instance = DatadogAPIClient::V2::TestOptimizationAPI.new

body = DatadogAPIClient::V2::UpdateFlakyTestsRequest.new({
data: DatadogAPIClient::V2::UpdateFlakyTestsRequestData.new({
attributes: DatadogAPIClient::V2::UpdateFlakyTestsRequestAttributes.new({
tests: [
DatadogAPIClient::V2::UpdateFlakyTestsRequestTest.new({
id: "4eb1887a8adb1847",
new_state: DatadogAPIClient::V2::UpdateFlakyTestsRequestTestNewState::ACTIVE,
}),
],
}),
type: DatadogAPIClient::V2::UpdateFlakyTestsRequestDataType::UPDATE_FLAKY_TEST_STATE_REQUEST,
}),
})
p api_instance.update_flaky_tests(body)
3 changes: 3 additions & 0 deletions features/scenarios_model_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3568,6 +3568,9 @@
"team_id" => "String",
"body" => "IncidentTeamUpdateRequest",
},
"v2.UpdateFlakyTests" => {
"body" => "UpdateFlakyTestsRequest",
},
"v2.SearchFlakyTests" => {
"body" => "FlakyTestsSearchRequest",
},
Expand Down
38 changes: 31 additions & 7 deletions features/v2/test_optimization.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,59 @@ Feature: Test Optimization
Given a valid "apiKeyAuth" key in the system
And a valid "appKeyAuth" key in the system
And an instance of "TestOptimization" API
And operation "SearchFlakyTests" enabled
And new "SearchFlakyTests" request

@generated @skip @team:DataDog/ci-app-backend
Scenario: Search flaky tests returns "Bad Request" response
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"}}
Given operation "SearchFlakyTests" enabled
And new "SearchFlakyTests" request
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"}}
When the request is sent
Then the response status is 400 Bad Request

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

@generated @skip @team:DataDog/ci-app-backend
Scenario: Search flaky tests returns "OK" response
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"}}
Given operation "SearchFlakyTests" enabled
And new "SearchFlakyTests" request
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"}}
When the request is sent
Then the response status is 200 OK

@replay-only @skip @skip-validation @team:DataDog/ci-app-backend @with-pagination
Scenario: Search flaky tests returns "OK" response with filtered query
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"}}
Given operation "SearchFlakyTests" enabled
And new "SearchFlakyTests" request
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"}}
When the request with pagination is sent
Then the response status is 200 OK

@generated @skip @team:DataDog/ci-app-backend @with-pagination
Scenario: Search flaky tests returns "OK" response with pagination
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"}}
Given operation "SearchFlakyTests" enabled
And new "SearchFlakyTests" request
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"}}
When the request with pagination is sent
Then the response status is 200 OK

@generated @skip @team:DataDog/ci-app-backend
Scenario: Update flaky test states returns "Bad Request" response
Given operation "UpdateFlakyTests" enabled
And new "UpdateFlakyTests" request
And body with value {"data": {"attributes": {"tests": [{"id": "4eb1887a8adb1847", "new_state": "active"}]}, "type": "update_flaky_test_state_request"}}
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:DataDog/ci-app-backend
Scenario: Update flaky test states returns "OK" response
Given operation "UpdateFlakyTests" enabled
And new "UpdateFlakyTests" request
And body with value {"data": {"attributes": {"tests": [{"id": "4eb1887a8adb1847", "new_state": "active"}]}, "type": "update_flaky_test_state_request"}}
When the request is sent
Then the response status is 200 OK
6 changes: 6 additions & 0 deletions features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -5149,6 +5149,12 @@
"type": "idempotent"
}
},
"UpdateFlakyTests": {
"tag": "Test Optimization",
"undo": {
"type": "unsafe"
}
},
"SearchFlakyTests": {
"tag": "Test Optimization",
"undo": {
Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ def initialize
"v2.list_incident_teams": false,
"v2.update_incident_team": false,
"v2.search_flaky_tests": false,
"v2.update_flaky_tests": false,
}
@server_variables[:site] = ENV['DD_SITE'] if ENV.key? 'DD_SITE'
@api_key['apiKeyAuth'] = ENV['DD_API_KEY'] if ENV.key? 'DD_API_KEY'
Expand Down
11 changes: 11 additions & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4809,6 +4809,17 @@ def overrides
"v2.update_deployment_rule_params" => "UpdateDeploymentRuleParams",
"v2.update_deployment_rule_params_data" => "UpdateDeploymentRuleParamsData",
"v2.update_deployment_rule_params_data_attributes" => "UpdateDeploymentRuleParamsDataAttributes",
"v2.update_flaky_tests_request" => "UpdateFlakyTestsRequest",
"v2.update_flaky_tests_request_attributes" => "UpdateFlakyTestsRequestAttributes",
"v2.update_flaky_tests_request_data" => "UpdateFlakyTestsRequestData",
"v2.update_flaky_tests_request_data_type" => "UpdateFlakyTestsRequestDataType",
"v2.update_flaky_tests_request_test" => "UpdateFlakyTestsRequestTest",
"v2.update_flaky_tests_request_test_new_state" => "UpdateFlakyTestsRequestTestNewState",
"v2.update_flaky_tests_response" => "UpdateFlakyTestsResponse",
"v2.update_flaky_tests_response_attributes" => "UpdateFlakyTestsResponseAttributes",
"v2.update_flaky_tests_response_data" => "UpdateFlakyTestsResponseData",
"v2.update_flaky_tests_response_data_type" => "UpdateFlakyTestsResponseDataType",
"v2.update_flaky_tests_response_result" => "UpdateFlakyTestsResponseResult",
"v2.update_on_call_notification_rule_request" => "UpdateOnCallNotificationRuleRequest",
"v2.update_on_call_notification_rule_request_attributes" => "UpdateOnCallNotificationRuleRequestAttributes",
"v2.update_on_call_notification_rule_request_data" => "UpdateOnCallNotificationRuleRequestData",
Expand Down
Loading
Loading