Skip to content

Commit ca55a83

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add subtest for synthetics multistep tests (#2865)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 02b495c commit ca55a83

File tree

10 files changed

+528
-1
lines changed

10 files changed

+528
-1
lines changed

.generator/schemas/v1/openapi.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14766,6 +14766,61 @@ components:
1476614766
oneOf:
1476714767
- $ref: '#/components/schemas/SyntheticsAPITestStep'
1476814768
- $ref: '#/components/schemas/SyntheticsAPIWaitStep'
14769+
- $ref: '#/components/schemas/SyntheticsAPISubtestStep'
14770+
SyntheticsAPISubtestStep:
14771+
description: The subtest step used in a Synthetics multi-step API test.
14772+
properties:
14773+
allowFailure:
14774+
description: Determines whether or not to continue with test if this step
14775+
fails.
14776+
type: boolean
14777+
alwaysExecute:
14778+
description: A boolean set to always execute this step even if the previous
14779+
step failed or was skipped.
14780+
type: boolean
14781+
exitIfSucceed:
14782+
description: Determines whether or not to exit the test if the step succeeds.
14783+
type: boolean
14784+
extractedValuesFromScript:
14785+
description: Generate variables using JavaScript.
14786+
type: string
14787+
id:
14788+
description: ID of the step.
14789+
example: abc-def-123
14790+
readOnly: true
14791+
type: string
14792+
isCritical:
14793+
description: 'Determines whether or not to consider the entire test as failed
14794+
if this step fails.
14795+
14796+
Can be used only if `allowFailure` is `true`.'
14797+
type: boolean
14798+
name:
14799+
description: The name of the step.
14800+
example: Example step name
14801+
type: string
14802+
retry:
14803+
$ref: '#/components/schemas/SyntheticsTestOptionsRetry'
14804+
subtestPublicId:
14805+
description: Public ID of the test to be played as part of a `playSubTest`
14806+
step type.
14807+
example: ''
14808+
type: string
14809+
subtype:
14810+
$ref: '#/components/schemas/SyntheticsAPISubtestStepSubtype'
14811+
required:
14812+
- name
14813+
- subtype
14814+
- subtestPublicId
14815+
type: object
14816+
SyntheticsAPISubtestStepSubtype:
14817+
description: The subtype of the Synthetic multi-step API subtest step.
14818+
enum:
14819+
- playSubTest
14820+
example: playSubTest
14821+
type: string
14822+
x-enum-varnames:
14823+
- PLAY_SUB_TEST
1476914824
SyntheticsAPITest:
1477014825
description: Object containing details about a Synthetic API test.
1477114826
properties:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-12-26T15:22:45.114Z

cassettes/features/v1/synthetics/Create-a-multistep-test-with-subtest-returns-OK-response.yml

Lines changed: 111 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Create a multistep test with subtest returns "OK" response
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
5+
6+
# there is a valid "synthetics_api_test" in the system
7+
SYNTHETICS_API_TEST_PUBLIC_ID = ENV["SYNTHETICS_API_TEST_PUBLIC_ID"]
8+
9+
body = DatadogAPIClient::V1::SyntheticsAPITest.new({
10+
config: DatadogAPIClient::V1::SyntheticsAPITestConfig.new({
11+
steps: [
12+
DatadogAPIClient::V1::SyntheticsAPITestStep.new({
13+
assertions: [
14+
DatadogAPIClient::V1::SyntheticsAssertionTarget.new({
15+
operator: DatadogAPIClient::V1::SyntheticsAssertionOperator::IS,
16+
type: DatadogAPIClient::V1::SyntheticsAssertionType::STATUS_CODE,
17+
target: 200,
18+
}),
19+
],
20+
name: "request is sent",
21+
request: DatadogAPIClient::V1::SyntheticsTestRequest.new({
22+
url: "https://httpbin.org/status/200",
23+
method: "GET",
24+
basic_auth: DatadogAPIClient::V1::SyntheticsBasicAuthWeb.new({
25+
password: "password",
26+
username: "username",
27+
}),
28+
}),
29+
subtype: DatadogAPIClient::V1::SyntheticsAPITestStepSubtype::HTTP,
30+
}),
31+
DatadogAPIClient::V1::SyntheticsAPISubtestStep.new({
32+
subtype: DatadogAPIClient::V1::SyntheticsAPISubtestStepSubtype::PLAY_SUB_TEST,
33+
subtest_public_id: SYNTHETICS_API_TEST_PUBLIC_ID,
34+
name: "subtest step",
35+
}),
36+
],
37+
}),
38+
locations: [
39+
"aws:us-east-2",
40+
],
41+
message: "BDD test payload: synthetics_api_test_multi_step_with_subtest.json",
42+
name: "Example-Synthetic",
43+
options: DatadogAPIClient::V1::SyntheticsTestOptions.new({
44+
tick_every: 60,
45+
}),
46+
subtype: DatadogAPIClient::V1::SyntheticsTestDetailsSubType::MULTI,
47+
type: DatadogAPIClient::V1::SyntheticsAPITestType::API,
48+
})
49+
p api_instance.create_synthetics_api_test(body)

features/v1/synthetics.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ Feature: Synthetics
169169
And the response "config.steps[5].request.basicAuth.type" is equal to "oauth-client"
170170
And the response "config.steps[6].request.basicAuth.type" is equal to "oauth-rop"
171171

172+
@team:DataDog/synthetics-managing
173+
Scenario: Create a multistep test with subtest returns "OK" response
174+
Given there is a valid "synthetics_api_test" in the system
175+
And new "CreateSyntheticsAPITest" request
176+
And body from file "synthetics_api_test_multi_step_with_subtest.json"
177+
When the request is sent
178+
Then the response status is 200 OK
179+
172180
@replay-only @team:DataDog/synthetics-managing
173181
Scenario: Create a private location returns "OK" response
174182
Given there is a valid "role" in the system
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"config": {
3+
"steps": [
4+
{
5+
"assertions": [
6+
{
7+
"operator": "is",
8+
"type": "statusCode",
9+
"target": 200
10+
}
11+
],
12+
"name": "request is sent",
13+
"request": {
14+
"url": "https://httpbin.org/status/200",
15+
"method": "GET",
16+
"basicAuth": {
17+
"password": "password",
18+
"username": "username"
19+
}
20+
},
21+
"subtype": "http"
22+
},
23+
{
24+
"subtype": "playSubTest",
25+
"subtestPublicId": "{{ synthetics_api_test.public_id }}",
26+
"name": "subtest step"
27+
}
28+
]
29+
},
30+
"locations": ["aws:us-east-2"],
31+
"message": "BDD test payload: synthetics_api_test_multi_step_with_subtest.json",
32+
"name": "{{ unique }}",
33+
"options": {
34+
"tick_every": 60
35+
},
36+
"subtype": "multi",
37+
"type": "api"
38+
}

lib/datadog_api_client/inflector.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,8 @@ def overrides
587587
"v1.sunburst_widget_legend_table_type" => "SunburstWidgetLegendTableType",
588588
"v1.sunburst_widget_request" => "SunburstWidgetRequest",
589589
"v1.synthetics_api_step" => "SyntheticsAPIStep",
590+
"v1.synthetics_api_subtest_step" => "SyntheticsAPISubtestStep",
591+
"v1.synthetics_api_subtest_step_subtype" => "SyntheticsAPISubtestStepSubtype",
590592
"v1.synthetics_api_test" => "SyntheticsAPITest",
591593
"v1.synthetics_api_test_config" => "SyntheticsAPITestConfig",
592594
"v1.synthetics_api_test_failure_code" => "SyntheticsApiTestFailureCode",

lib/datadog_api_client/v1/models/synthetics_api_step.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class << self
2727
def openapi_one_of
2828
[
2929
:'SyntheticsAPITestStep',
30-
:'SyntheticsAPIWaitStep'
30+
:'SyntheticsAPIWaitStep',
31+
:'SyntheticsAPISubtestStep'
3132
]
3233
end
3334
# Builds the object

0 commit comments

Comments
 (0)