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
16 changes: 8 additions & 8 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25864,6 +25864,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 @@ -25909,14 +25917,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
10 changes: 5 additions & 5 deletions examples/v2_test-optimization_SearchFlakyTests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ async fn main() {
.attributes(
FlakyTestsSearchRequestAttributes::new()
.filter(
FlakyTestsSearchFilter
::new().query(
r#"flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist""#.to_string(),
),
FlakyTestsSearchFilter::new()
.include_history(true)
.query(
r#"flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist""#.to_string(),
),
)
.include_history(true)
.page(
FlakyTestsSearchPageOptions::new()
.cursor(
Expand Down
10 changes: 5 additions & 5 deletions examples/v2_test-optimization_SearchFlakyTests_1224086727.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ async fn main() {
.attributes(
FlakyTestsSearchRequestAttributes::new()
.filter(
FlakyTestsSearchFilter
::new().query(
r#"flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist""#.to_string(),
),
FlakyTestsSearchFilter::new()
.include_history(true)
.query(
r#"flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist""#.to_string(),
),
)
.include_history(true)
.page(
FlakyTestsSearchPageOptions::new()
.cursor(
Expand Down
10 changes: 5 additions & 5 deletions examples/v2_test-optimization_SearchFlakyTests_209064879.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ async fn main() {
.attributes(
FlakyTestsSearchRequestAttributes::new()
.filter(
FlakyTestsSearchFilter
::new().query(
r#"flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist""#.to_string(),
),
FlakyTestsSearchFilter::new()
.include_history(true)
.query(
r#"flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist""#.to_string(),
),
)
.include_history(true)
.page(FlakyTestsSearchPageOptions::new().limit(10))
.sort(FlakyTestsSearchSort::FQN_ASCENDING),
)
Expand Down
20 changes: 20 additions & 0 deletions src/datadogV2/model/model_flaky_tests_search_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ use std::fmt::{self, Formatter};
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct FlakyTestsSearchFilter {
/// 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.
#[serde(rename = "include_history")]
pub include_history: Option<bool>,
/// 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`
/// - `flaky_test_category`
Expand All @@ -34,12 +39,18 @@ pub struct FlakyTestsSearchFilter {
impl FlakyTestsSearchFilter {
pub fn new() -> FlakyTestsSearchFilter {
FlakyTestsSearchFilter {
include_history: None,
query: None,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}

pub fn include_history(mut self, value: bool) -> Self {
self.include_history = Some(value);
self
}

pub fn query(mut self, value: String) -> Self {
self.query = Some(value);
self
Expand Down Expand Up @@ -77,6 +88,7 @@ impl<'de> Deserialize<'de> for FlakyTestsSearchFilter {
where
M: MapAccess<'a>,
{
let mut include_history: Option<bool> = None;
let mut query: Option<String> = None;
let mut additional_properties: std::collections::BTreeMap<
String,
Expand All @@ -86,6 +98,13 @@ impl<'de> Deserialize<'de> for FlakyTestsSearchFilter {

while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
match k.as_str() {
"include_history" => {
if v.is_null() {
continue;
}
include_history =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"query" => {
if v.is_null() {
continue;
Expand All @@ -101,6 +120,7 @@ impl<'de> Deserialize<'de> for FlakyTestsSearchFilter {
}

let content = FlakyTestsSearchFilter {
include_history,
query,
additional_properties,
_unparsed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ pub struct FlakyTestsSearchRequestAttributes {
/// Search filter settings.
#[serde(rename = "filter")]
pub filter: Option<crate::datadogV2::model::FlakyTestsSearchFilter>,
/// 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.
#[serde(rename = "include_history")]
pub include_history: Option<bool>,
/// Pagination attributes for listing flaky tests.
#[serde(rename = "page")]
pub page: Option<crate::datadogV2::model::FlakyTestsSearchPageOptions>,
Expand All @@ -36,7 +31,6 @@ impl FlakyTestsSearchRequestAttributes {
pub fn new() -> FlakyTestsSearchRequestAttributes {
FlakyTestsSearchRequestAttributes {
filter: None,
include_history: None,
page: None,
sort: None,
additional_properties: std::collections::BTreeMap::new(),
Expand All @@ -49,11 +43,6 @@ impl FlakyTestsSearchRequestAttributes {
self
}

pub fn include_history(mut self, value: bool) -> Self {
self.include_history = Some(value);
self
}

pub fn page(mut self, value: crate::datadogV2::model::FlakyTestsSearchPageOptions) -> Self {
self.page = Some(value);
self
Expand Down Expand Up @@ -97,7 +86,6 @@ impl<'de> Deserialize<'de> for FlakyTestsSearchRequestAttributes {
M: MapAccess<'a>,
{
let mut filter: Option<crate::datadogV2::model::FlakyTestsSearchFilter> = None;
let mut include_history: Option<bool> = None;
let mut page: Option<crate::datadogV2::model::FlakyTestsSearchPageOptions> = None;
let mut sort: Option<crate::datadogV2::model::FlakyTestsSearchSort> = None;
let mut additional_properties: std::collections::BTreeMap<
Expand All @@ -114,13 +102,6 @@ impl<'de> Deserialize<'de> for FlakyTestsSearchRequestAttributes {
}
filter = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"include_history" => {
if v.is_null() {
continue;
}
include_history =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"page" => {
if v.is_null() {
continue;
Expand Down Expand Up @@ -151,7 +132,6 @@ impl<'de> Deserialize<'de> for FlakyTestsSearchRequestAttributes {

let content = FlakyTestsSearchRequestAttributes {
filter,
include_history,
page,
sort,
additional_properties,
Expand Down
8 changes: 4 additions & 4 deletions tests/scenarios/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,7 +117,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 @@ -129,7 +129,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