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
21 changes: 21 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11169,6 +11169,27 @@ datadog\_api\_client.v2.model.flaky\_test\_history module
:members:
:show-inheritance:

datadog\_api\_client.v2.model.flaky\_test\_history\_policy\_id module
---------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.flaky_test_history_policy_id
:members:
:show-inheritance:

datadog\_api\_client.v2.model.flaky\_test\_history\_policy\_meta module
-----------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.flaky_test_history_policy_meta
:members:
:show-inheritance:

datadog\_api\_client.v2.model.flaky\_test\_history\_policy\_meta\_config module
-------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.flaky_test_history_policy_meta_config
:members:
:show-inheritance:

datadog\_api\_client.v2.model.flaky\_test\_pipeline\_stats module
-----------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion examples/v2/test-optimization/SearchFlakyTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
data=FlakyTestsSearchRequestData(
attributes=FlakyTestsSearchRequestAttributes(
filter=FlakyTestsSearchFilter(
include_history=True,
query='flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"',
),
include_history=True,
page=FlakyTestsSearchPageOptions(
cursor="eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
limit=25,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
data=FlakyTestsSearchRequestData(
attributes=FlakyTestsSearchRequestAttributes(
filter=FlakyTestsSearchFilter(
include_history=True,
query='flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"',
),
include_history=True,
page=FlakyTestsSearchPageOptions(
cursor="eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
limit=25,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
attributes=FlakyTestsSearchRequestAttributes(
filter=FlakyTestsSearchFilter(
query='flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"',
include_history=True,
),
page=FlakyTestsSearchPageOptions(
limit=10,
),
sort=FlakyTestsSearchSort.FQN_ASCENDING,
include_history=True,
),
type=FlakyTestsSearchRequestDataType.SEARCH_FLAKY_TESTS_REQUEST,
),
Expand Down
35 changes: 34 additions & 1 deletion src/datadog_api_client/v2/model/flaky_test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,74 @@
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.flaky_test_history_policy_id import FlakyTestHistoryPolicyId
from datadog_api_client.v2.model.flaky_test_history_policy_meta import FlakyTestHistoryPolicyMeta


class FlakyTestHistory(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.flaky_test_history_policy_id import FlakyTestHistoryPolicyId
from datadog_api_client.v2.model.flaky_test_history_policy_meta import FlakyTestHistoryPolicyMeta

return {
"commit_sha": (str,),
"policy_id": (FlakyTestHistoryPolicyId,),
"policy_meta": (FlakyTestHistoryPolicyMeta,),
"status": (str,),
"timestamp": (int,),
}

attribute_map = {
"commit_sha": "commit_sha",
"policy_id": "policy_id",
"policy_meta": "policy_meta",
"status": "status",
"timestamp": "timestamp",
}

def __init__(self_, commit_sha: str, status: str, timestamp: int, **kwargs):
def __init__(
self_,
commit_sha: str,
status: str,
timestamp: int,
policy_id: Union[FlakyTestHistoryPolicyId, UnsetType] = unset,
policy_meta: Union[FlakyTestHistoryPolicyMeta, UnsetType] = unset,
**kwargs,
):
"""
A single history entry representing a status change for a flaky test.

:param commit_sha: The commit SHA associated with this status change. Will be an empty string if the commit SHA is not available.
:type commit_sha: str

:param policy_id: The policy that triggered this status change.
:type policy_id: FlakyTestHistoryPolicyId, optional

:param policy_meta: Metadata about the policy that triggered this status change.
:type policy_meta: FlakyTestHistoryPolicyMeta, optional

:param status: The test status at this point in history.
:type status: str

:param timestamp: Unix timestamp in milliseconds when this status change occurred.
:type timestamp: int
"""
if policy_id is not unset:
kwargs["policy_id"] = policy_id
if policy_meta is not unset:
kwargs["policy_meta"] = policy_meta
super().__init__(kwargs)

self_.commit_sha = commit_sha
Expand Down
59 changes: 59 additions & 0 deletions src/datadog_api_client/v2/model/flaky_test_history_policy_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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 2019-Present Datadog, Inc.
from __future__ import annotations


from datadog_api_client.model_utils import (
ModelSimple,
cached_property,
)

from typing import ClassVar


class FlakyTestHistoryPolicyId(ModelSimple):
"""
The policy that triggered this status change.

:param value: Must be one of ["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"].
:type value: str
"""

allowed_values = {
"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",
}
MANUAL: ClassVar["FlakyTestHistoryPolicyId"]
FIXED: ClassVar["FlakyTestHistoryPolicyId"]
DISABLE_FAILURE_RATE: ClassVar["FlakyTestHistoryPolicyId"]
DISABLE_BRANCH_FLAKE: ClassVar["FlakyTestHistoryPolicyId"]
DISABLE_DAYS_ACTIVE: ClassVar["FlakyTestHistoryPolicyId"]
QUARANTINE_FAILURE_RATE: ClassVar["FlakyTestHistoryPolicyId"]
QUARANTINE_BRANCH_FLAKE: ClassVar["FlakyTestHistoryPolicyId"]
QUARANTINE_DAYS_ACTIVE: ClassVar["FlakyTestHistoryPolicyId"]
UNKNOWN: ClassVar["FlakyTestHistoryPolicyId"]

@cached_property
def openapi_types(_):
return {
"value": (str,),
}


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