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
155 changes: 147 additions & 8 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26216,9 +26216,18 @@ components:
Includes state transitions like new -> quarantined -> fixed, along with the associated commit SHA when available.
example:
- commit_sha: abc123def456
policy_id: ftm_policy.quarantine.failure_rate
policy_meta:
config:
failure_rate: 0.1
required_runs: 100
failure_rate: 0.25
total_runs: 200
status: quarantined
timestamp: 1704067200000
- commit_sha: ""
policy_id: unknown
policy_meta:
status: new
timestamp: 1703980800000
items:
Expand Down Expand Up @@ -26288,6 +26297,11 @@ components:
description: The commit SHA associated with this status change. Will be an empty string if the commit SHA is not available.
example: abc123def456
type: string
policy_id:
$ref: "#/components/schemas/FlakyTestHistoryPolicyId"
policy_meta:
$ref: "#/components/schemas/FlakyTestHistoryPolicyMeta"
nullable: true
status:
description: The test status at this point in history.
example: quarantined
Expand All @@ -26302,6 +26316,131 @@ components:
- commit_sha
- timestamp
type: object
FlakyTestHistoryPolicyId:
description: The policy that triggered this status change.
enum:
- 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
- unknown
example: ftm_policy.quarantine.failure_rate
nullable: false
type: string
x-enum-varnames:
- MANUAL
- FIXED
- DISABLE_FAILURE_RATE
- DISABLE_BRANCH_FLAKE
- DISABLE_DAYS_ACTIVE
- QUARANTINE_FAILURE_RATE
- QUARANTINE_BRANCH_FLAKE
- QUARANTINE_DAYS_ACTIVE
- UNKNOWN
FlakyTestHistoryPolicyMeta:
description: Metadata about the policy that triggered this status change.
properties:
branches:
description: Branches where the test was flaky at the time of the status change.
example: ["main", "develop"]
items:
type: string
nullable: true
type: array
config:
$ref: "#/components/schemas/FlakyTestHistoryPolicyMetaConfig"
nullable: true
days_active:
description: The number of days the test has been active at the time of the status change.
example: 15
format: int32
maximum: 2147483647
nullable: true
type: integer
days_without_flake:
description: The number of days since the test last exhibited flakiness.
example: 30
format: int32
maximum: 2147483647
nullable: true
type: integer
failure_rate:
description: The failure rate of the test at the time of the status change.
example: 0.25
format: double
maximum: 1
minimum: 0
nullable: true
type: number
state:
description: The previous state of the test.
example: quarantined
nullable: true
type: string
total_runs:
description: The total number of test runs at the time of the status change.
example: 200
format: int32
maximum: 2147483647
nullable: true
type: integer
type: object
FlakyTestHistoryPolicyMetaConfig:
description: Configuration parameters of the policy that triggered this status change.
properties:
branches:
description: The branches considered by the policy.
example: ["main"]
items:
type: string
nullable: true
type: array
days_active:
description: The number of days a test must have been active for the policy to trigger.
example: 30
format: int32
maximum: 2147483647
nullable: true
type: integer
failure_rate:
description: The failure rate threshold for the policy to trigger.
example: 0.7
format: double
maximum: 1
minimum: 0
nullable: true
type: number
forget_branches:
description: Branches excluded from the policy evaluation.
example: ["release"]
items:
type: string
nullable: true
type: array
required_runs:
description: The minimum number of test runs required for the policy to trigger.
example: 100
format: int32
maximum: 2147483647
nullable: true
type: integer
state:
description: The target state the policy transitions the test from.
example: quarantined
nullable: true
type: string
test_services:
description: Test services excluded from the policy evaluation.
example: ["my-service"]
items:
type: string
nullable: true
type: array
type: object
FlakyTestPipelineStats:
description: CI pipeline related statistics for the flaky test. This information is only available if test runs are associated with CI pipeline events from CI Visibility.
properties:
Expand Down Expand Up @@ -26381,6 +26520,14 @@ components:
FlakyTestsSearchFilter:
description: Search filter settings.
properties:
include_history:
default: false
description: |-
Whether 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.
example: true
type: boolean
query:
default: "*"
description: |-
Expand Down Expand Up @@ -26426,14 +26573,6 @@ components:
properties:
filter:
$ref: "#/components/schemas/FlakyTestsSearchFilter"
include_history:
default: false
description: |-
Whether 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.
example: true
type: boolean
page:
$ref: "#/components/schemas/FlakyTestsSearchPageOptions"
sort:
Expand Down
2 changes: 1 addition & 1 deletion examples/v2/test-optimization/SearchFlakyTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
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"',
}),
include_history: true,
page: DatadogAPIClient::V2::FlakyTestsSearchPageOptions.new({
cursor: "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
limit: 25,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
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"',
}),
include_history: true,
page: DatadogAPIClient::V2::FlakyTestsSearchPageOptions.new({
cursor: "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
limit: 25,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
attributes: DatadogAPIClient::V2::FlakyTestsSearchRequestAttributes.new({
filter: DatadogAPIClient::V2::FlakyTestsSearchFilter.new({
query: 'flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"',
include_history: true,
}),
page: DatadogAPIClient::V2::FlakyTestsSearchPageOptions.new({
limit: 10,
}),
sort: DatadogAPIClient::V2::FlakyTestsSearchSort::FQN_ASCENDING,
include_history: true,
}),
type: DatadogAPIClient::V2::FlakyTestsSearchRequestDataType::SEARCH_FLAKY_TESTS_REQUEST,
}),
Expand Down
10 changes: 6 additions & 4 deletions features/v2/test_optimization.feature
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Feature: Test Optimization
Scenario: Search flaky tests returns "Bad Request" response
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\""}, "include_history": true, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}}
And body with value {"data": {"attributes": {"filter": {"include_history": 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"}}
When the request is sent
Then the response status is 400 Bad Request

Expand All @@ -101,7 +101,7 @@ Feature: Test Optimization
Scenario: Search flaky tests returns "OK" response
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\""}, "include_history": true, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}}
And body with value {"data": {"attributes": {"filter": {"include_history": 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"}}
When the request is sent
Then the response status is 200 OK

Expand All @@ -117,19 +117,21 @@ Feature: Test Optimization
Scenario: Search flaky tests returns "OK" response with history
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": {"limit": 10}, "sort": "fqn", "include_history": true}, "type": "search_flaky_tests_request"}}
And body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\"", "include_history": true}, "page": {"limit": 10}, "sort": "fqn"}, "type": "search_flaky_tests_request"}}
When the request is sent
Then the response status is 200 OK
And the response "data[0].attributes" has field "history"
And the response "data[0].attributes.history[0]" has field "status"
And the response "data[0].attributes.history[0]" has field "commit_sha"
And the response "data[0].attributes.history[0]" has field "timestamp"
And the response "data[0].attributes.history[0]" has field "policy_id"
And the response "data[0].attributes.history[0]" has field "policy_meta"

@generated @skip @team:DataDog/ci-app-backend @with-pagination
Scenario: Search flaky tests returns "OK" response with pagination
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\""}, "include_history": true, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}}
And body with value {"data": {"attributes": {"filter": {"include_history": 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"}}
When the request with pagination is sent
Then the response status is 200 OK

Expand Down
3 changes: 3 additions & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2621,6 +2621,9 @@ def overrides
"v2.flaky_test_attributes" => "FlakyTestAttributes",
"v2.flaky_test_attributes_flaky_state" => "FlakyTestAttributesFlakyState",
"v2.flaky_test_history" => "FlakyTestHistory",
"v2.flaky_test_history_policy_id" => "FlakyTestHistoryPolicyId",
"v2.flaky_test_history_policy_meta" => "FlakyTestHistoryPolicyMeta",
"v2.flaky_test_history_policy_meta_config" => "FlakyTestHistoryPolicyMetaConfig",
"v2.flaky_test_pipeline_stats" => "FlakyTestPipelineStats",
"v2.flaky_test_run_metadata" => "FlakyTestRunMetadata",
"v2.flaky_tests_pagination" => "FlakyTestsPagination",
Expand Down
22 changes: 21 additions & 1 deletion lib/datadog_api_client/v2/models/flaky_test_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ class FlakyTestHistory
# The commit SHA associated with this status change. Will be an empty string if the commit SHA is not available.
attr_reader :commit_sha

# The policy that triggered this status change.
attr_accessor :policy_id

# Metadata about the policy that triggered this status change.
attr_accessor :policy_meta

# The test status at this point in history.
attr_reader :status

Expand All @@ -37,6 +43,8 @@ class FlakyTestHistory
def self.attribute_map
{
:'commit_sha' => :'commit_sha',
:'policy_id' => :'policy_id',
:'policy_meta' => :'policy_meta',
:'status' => :'status',
:'timestamp' => :'timestamp'
}
Expand All @@ -47,6 +55,8 @@ def self.attribute_map
def self.openapi_types
{
:'commit_sha' => :'String',
:'policy_id' => :'FlakyTestHistoryPolicyId',
:'policy_meta' => :'FlakyTestHistoryPolicyMeta',
:'status' => :'String',
:'timestamp' => :'Integer'
}
Expand Down Expand Up @@ -74,6 +84,14 @@ def initialize(attributes = {})
self.commit_sha = attributes[:'commit_sha']
end

if attributes.key?(:'policy_id')
self.policy_id = attributes[:'policy_id']
end

if attributes.key?(:'policy_meta')
self.policy_meta = attributes[:'policy_meta']
end

if attributes.key?(:'status')
self.status = attributes[:'status']
end
Expand Down Expand Up @@ -150,6 +168,8 @@ def ==(o)
return true if self.equal?(o)
self.class == o.class &&
commit_sha == o.commit_sha &&
policy_id == o.policy_id &&
policy_meta == o.policy_meta &&
status == o.status &&
timestamp == o.timestamp &&
additional_properties == o.additional_properties
Expand All @@ -159,7 +179,7 @@ def ==(o)
# @return [Integer] Hash code
# @!visibility private
def hash
[commit_sha, status, timestamp, additional_properties].hash
[commit_sha, policy_id, policy_meta, status, timestamp, additional_properties].hash
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
=begin
#Datadog API V2 Collection

#Collection of all Datadog Public endpoints.

The version of the OpenAPI document: 1.0
Contact: support@datadoghq.com
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 'date'
require 'time'

module DatadogAPIClient::V2
# The policy that triggered this status change.
class FlakyTestHistoryPolicyId
include BaseEnumModel

MANUAL = "ftm_policy.manual".freeze
FIXED = "ftm_policy.fixed".freeze
DISABLE_FAILURE_RATE = "ftm_policy.disable.failure_rate".freeze
DISABLE_BRANCH_FLAKE = "ftm_policy.disable.branch_flake".freeze
DISABLE_DAYS_ACTIVE = "ftm_policy.disable.days_active".freeze
QUARANTINE_FAILURE_RATE = "ftm_policy.quarantine.failure_rate".freeze
QUARANTINE_BRANCH_FLAKE = "ftm_policy.quarantine.branch_flake".freeze
QUARANTINE_DAYS_ACTIVE = "ftm_policy.quarantine.days_active".freeze
UNKNOWN = "unknown".freeze
end
end
Loading
Loading