Skip to content
Open
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
419 changes: 419 additions & 0 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions examples/v2/test-optimization/SearchFlakyTests.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Search flaky tests returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.unstable_operations["v2.search_flaky_tests".to_sym] = true
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({
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)
27 changes: 27 additions & 0 deletions examples/v2/test-optimization/SearchFlakyTests_1224086727.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Search flaky tests returns "OK" response with pagination

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.unstable_operations["v2.search_flaky_tests".to_sym] = true
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({
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,
}
api_instance.search_flaky_tests_with_pagination(opts) { |item| puts item }
26 changes: 26 additions & 0 deletions examples/v2/test-optimization/SearchFlakyTests_2665223746.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Search flaky tests returns "OK" response with filtered query

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.unstable_operations["v2.search_flaky_tests".to_sym] = true
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({
query: 'flaky_test_state:active @git.repository.id_v2:"github.com/datadog/cart-tracking"',
}),
page: DatadogAPIClient::V2::FlakyTestsSearchPageOptions.new({
limit: 10,
}),
sort: DatadogAPIClient::V2::FlakyTestsSearchSort::LAST_FLAKED_DESCENDING,
}),
type: DatadogAPIClient::V2::FlakyTestsSearchRequestDataType::SEARCH_FLAKY_TESTS_REQUEST,
}),
})
opts = {
body: body,
}
api_instance.search_flaky_tests_with_pagination(opts) { |item| puts item }
3 changes: 3 additions & 0 deletions features/scenarios_model_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2974,6 +2974,9 @@
"team_id" => "String",
"body" => "IncidentTeamUpdateRequest",
},
"v2.SearchFlakyTests" => {
"body" => "FlakyTestsSearchRequest",
},
"v2.SendInvitations" => {
"body" => "UserInvitationsRequest",
},
Expand Down
42 changes: 42 additions & 0 deletions features/v2/test_optimization.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@endpoint(test-optimization) @endpoint(test-optimization-v2)
Feature: Test Optimization
Search and manage flaky tests through Test Optimization. See the [Test
Optimization page](https://docs.datadoghq.com/tests/) for more
information.

Background:
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"}}
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"}}
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"}}
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"}}
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"}}
When the request with pagination 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 @@ -3966,6 +3966,12 @@
"type": "idempotent"
}
},
"SearchFlakyTests": {
"tag": "Test Optimization",
"undo": {
"type": "safe"
}
},
"GetUsageApplicationSecurityMonitoring": {
"tag": "Usage Metering",
"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 @@ -294,6 +294,7 @@ def initialize
"v2.get_incident_team": false,
"v2.list_incident_teams": false,
"v2.update_incident_team": false,
"v2.search_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
18 changes: 18 additions & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2033,6 +2033,23 @@ def overrides
"v2.finding_status" => "FindingStatus",
"v2.finding_type" => "FindingType",
"v2.finding_vulnerability_type" => "FindingVulnerabilityType",
"v2.flaky_test" => "FlakyTest",
"v2.flaky_test_attributes" => "FlakyTestAttributes",
"v2.flaky_test_attributes_flaky_state" => "FlakyTestAttributesFlakyState",
"v2.flaky_test_pipeline_stats" => "FlakyTestPipelineStats",
"v2.flaky_test_run_metadata" => "FlakyTestRunMetadata",
"v2.flaky_tests_pagination" => "FlakyTestsPagination",
"v2.flaky_tests_search_filter" => "FlakyTestsSearchFilter",
"v2.flaky_tests_search_page_options" => "FlakyTestsSearchPageOptions",
"v2.flaky_tests_search_request" => "FlakyTestsSearchRequest",
"v2.flaky_tests_search_request_attributes" => "FlakyTestsSearchRequestAttributes",
"v2.flaky_tests_search_request_data" => "FlakyTestsSearchRequestData",
"v2.flaky_tests_search_request_data_type" => "FlakyTestsSearchRequestDataType",
"v2.flaky_tests_search_response" => "FlakyTestsSearchResponse",
"v2.flaky_tests_search_response_meta" => "FlakyTestsSearchResponseMeta",
"v2.flaky_tests_search_sort" => "FlakyTestsSearchSort",
"v2.flaky_test_stats" => "FlakyTestStats",
"v2.flaky_test_type" => "FlakyTestType",
"v2.formula_limit" => "FormulaLimit",
"v2.framework_handle_and_version_response_data" => "FrameworkHandleAndVersionResponseData",
"v2.freshservice_api_key" => "FreshserviceAPIKey",
Expand Down Expand Up @@ -4205,6 +4222,7 @@ def overrides
"v2.spans_metrics_api" => "SpansMetricsAPI",
"v2.synthetics_api" => "SyntheticsAPI",
"v2.teams_api" => "TeamsAPI",
"v2.test_optimization_api" => "TestOptimizationAPI",
"v2.usage_metering_api" => "UsageMeteringAPI",
"v2.users_api" => "UsersAPI",
"v2.workflow_automation_api" => "WorkflowAutomationAPI"
Expand Down
116 changes: 116 additions & 0 deletions lib/datadog_api_client/v2/api/test_optimization_api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
=begin
#Datadog API V2 Collection

#Collection of all Datadog Public endpoints.

The version of the OpenAPI document: 1.0
Contact: [email protected]
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator

Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
This product includes software developed at Datadog (https://www.datadoghq.com/).
Copyright 2020-Present Datadog, Inc.

=end

require 'cgi'

module DatadogAPIClient::V2
class TestOptimizationAPI
attr_accessor :api_client

def initialize(api_client = DatadogAPIClient::APIClient.default)
@api_client = api_client
end

# Search flaky tests.
#
# @see #search_flaky_tests_with_http_info
def search_flaky_tests(opts = {})
data, _status_code, _headers = search_flaky_tests_with_http_info(opts)
data
end

# Search flaky tests.
#
# List endpoint returning flaky tests from Flaky Test Management. Results are paginated.
#
# @param opts [Hash] the optional parameters
# @option opts [FlakyTestsSearchRequest] :body
# @return [Array<(FlakyTestsSearchResponse, Integer, Hash)>] FlakyTestsSearchResponse data, response status code and response headers
def search_flaky_tests_with_http_info(opts = {})
unstable_enabled = @api_client.config.unstable_operations["v2.search_flaky_tests".to_sym]
if unstable_enabled
@api_client.config.logger.warn format("Using unstable operation '%s'", "v2.search_flaky_tests")
else
raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.search_flaky_tests"))
end

if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: TestOptimizationAPI.search_flaky_tests ...'
end
# resource path
local_var_path = '/api/v2/test/flaky-test-management/tests'

# query parameters
query_params = opts[:query_params] || {}

# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

# form parameters
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'body'])

# return_type
return_type = opts[:debug_return_type] || 'FlakyTestsSearchResponse'

# auth_names
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

new_options = opts.merge(
:operation => :search_flaky_tests,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type,
:api_version => "V2"
)

data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: TestOptimizationAPI#search_flaky_tests\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

# Search flaky tests.
#
# Provide a paginated version of {#search_flaky_tests}, returning all items.
#
# To use it you need to use a block: search_flaky_tests_with_pagination { |item| p item }
#
# @yield [FlakyTest] Paginated items
def search_flaky_tests_with_pagination(opts = {})
api_version = "V2"
page_size = @api_client.get_attribute_from_path(opts, "body.data.attributes.page.limit", 10)
@api_client.set_attribute_from_path(api_version, opts, "body.data.attributes.page.limit", FlakyTestsSearchRequest, page_size)
while true do
response = search_flaky_tests(opts)
@api_client.get_attribute_from_path(response, "data").each { |item| yield(item) }
if @api_client.get_attribute_from_path(response, "data").length < page_size
break
end
@api_client.set_attribute_from_path(api_version, opts, "body.data.attributes.page.cursor", FlakyTestsSearchRequest, @api_client.get_attribute_from_path(response, "meta.pagination.next_page"))
end
end
end
end
Loading
Loading