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
22 changes: 11 additions & 11 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25661,6 +25661,17 @@ 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: 'Search query following log syntax used to filter flaky tests,
Expand Down Expand Up @@ -25716,17 +25727,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.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
13 changes: 12 additions & 1 deletion src/datadog_api_client/v2/model/flaky_tests_search_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,26 @@ class FlakyTestsSearchFilter(ModelNormal):
@cached_property
def openapi_types(_):
return {
"include_history": (bool,),
"query": (str,),
}

attribute_map = {
"include_history": "include_history",
"query": "query",
}

def __init__(self_, query: Union[str, UnsetType] = unset, **kwargs):
def __init__(
self_, include_history: Union[bool, UnsetType] = unset, query: Union[str, UnsetType] = unset, **kwargs
):
"""
Search filter settings.

:param include_history: 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.
:type include_history: bool, optional

:param query: Search query following log syntax used to filter flaky tests, same as on Flaky Tests Management UI. The supported search keys are:

* ``flaky_test_state``
Expand All @@ -42,6 +51,8 @@ def __init__(self_, query: Union[str, UnsetType] = unset, **kwargs):
* ``env``
:type query: str, optional
"""
if include_history is not unset:
kwargs["include_history"] = include_history
if query is not unset:
kwargs["query"] = query
super().__init__(kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,19 @@ def openapi_types(_):

return {
"filter": (FlakyTestsSearchFilter,),
"include_history": (bool,),
"page": (FlakyTestsSearchPageOptions,),
"sort": (FlakyTestsSearchSort,),
}

attribute_map = {
"filter": "filter",
"include_history": "include_history",
"page": "page",
"sort": "sort",
}

def __init__(
self_,
filter: Union[FlakyTestsSearchFilter, UnsetType] = unset,
include_history: Union[bool, UnsetType] = unset,
page: Union[FlakyTestsSearchPageOptions, UnsetType] = unset,
sort: Union[FlakyTestsSearchSort, UnsetType] = unset,
**kwargs,
Expand All @@ -54,11 +51,6 @@ def __init__(
:param filter: Search filter settings.
:type filter: FlakyTestsSearchFilter, optional

:param include_history: 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.
:type include_history: bool, optional

:param page: Pagination attributes for listing flaky tests.
:type page: FlakyTestsSearchPageOptions, optional

Expand All @@ -67,8 +59,6 @@ def __init__(
"""
if filter is not unset:
kwargs["filter"] = filter
if include_history is not unset:
kwargs["include_history"] = include_history
if page is not unset:
kwargs["page"] = page
if sort is not unset:
Expand Down
8 changes: 4 additions & 4 deletions tests/v2/features/test_optimization.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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 @@ -29,7 +29,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 @@ -45,7 +45,7 @@ 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"
Expand All @@ -57,7 +57,7 @@ Feature: Test Optimization
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
Loading