Skip to content

Commit 835074c

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add subtest for synthetics multistep tests (#3197)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent daa54f1 commit 835074c

11 files changed

Lines changed: 549 additions & 1 deletion

File tree

.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"
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
{
2+
"log": {
3+
"_recordingName": "Synthetics/Create a multistep test with subtest returns \"OK\" response",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "adbf978a00beb492addf278c71d44fa0",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 2257,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
},
23+
{
24+
"_fromType": "array",
25+
"name": "content-type",
26+
"value": "application/json"
27+
}
28+
],
29+
"headersSize": 579,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"config\":{\"assertions\":[{\"operator\":\"is\",\"property\":\"{{ PROPERTY }}\",\"target\":\"text/html\",\"type\":\"header\"},{\"operator\":\"lessThan\",\"target\":2000,\"timingsScope\":\"withoutDNS\",\"type\":\"responseTime\"},{\"operator\":\"validatesJSONPath\",\"target\":{\"jsonPath\":\"topKey\",\"operator\":\"isNot\",\"targetValue\":\"0\"},\"type\":\"body\"},{\"operator\":\"validatesJSONPath\",\"target\":{\"elementsOperator\":\"atLeastOneElementMatches\",\"jsonPath\":\"topKey\",\"operator\":\"isNot\",\"targetValue\":\"0\"},\"type\":\"body\"},{\"operator\":\"validatesJSONSchema\",\"target\":{\"jsonSchema\":\"{\\\"type\\\": \\\"object\\\", \\\"properties\\\":{\\\"slideshow\\\":{\\\"type\\\":\\\"object\\\"}}}\",\"metaSchema\":\"draft-07\"},\"type\":\"body\"},{\"operator\":\"validatesXPath\",\"target\":{\"operator\":\"contains\",\"targetValue\":\"0\",\"xPath\":\"target-xpath\"},\"type\":\"body\"},{\"operator\":\"md5\",\"target\":\"a\",\"type\":\"bodyHash\"},{\"code\":\"const hello = 'world';\",\"type\":\"javascript\"}],\"configVariables\":[{\"example\":\"content-type\",\"name\":\"PROPERTY\",\"pattern\":\"content-type\",\"type\":\"text\"}],\"request\":{\"basicAuth\":{\"accessTokenUrl\":\"https://datadog-token.com\",\"audience\":\"audience\",\"clientId\":\"client-id\",\"clientSecret\":\"client-secret\",\"resource\":\"resource\",\"scope\":\"yoyo\",\"tokenApiAuthentication\":\"header\",\"type\":\"oauth-client\"},\"certificate\":{\"cert\":{\"content\":\"cert-content\",\"filename\":\"cert-filename\",\"updatedAt\":\"2020-10-16T09:23:24.857Z\"},\"key\":{\"content\":\"key-content\",\"filename\":\"key-filename\",\"updatedAt\":\"2020-10-16T09:23:24.857Z\"}},\"headers\":{\"unique\":\"testcreateamultisteptestwithsubtestreturnsokresponse1766762565\"},\"method\":\"GET\",\"persistCookies\":true,\"proxy\":{\"headers\":{},\"url\":\"https://datadoghq.com\"},\"timeout\":10,\"url\":\"https://datadoghq.com\"},\"variablesFromScript\":\"dd.variable.set(\\\"FOO\\\", \\\"foo\\\")\"},\"locations\":[\"aws:us-east-2\"],\"message\":\"BDD test payload: synthetics_api_http_test_payload.json\",\"name\":\"Test-Create_a_multistep_test_with_subtest_returns_OK_response-1766762565\",\"options\":{\"accept_self_signed\":false,\"allow_insecure\":true,\"follow_redirects\":true,\"httpVersion\":\"http2\",\"min_failure_duration\":10,\"min_location_failed\":1,\"monitor_name\":\"Test-Create_a_multistep_test_with_subtest_returns_OK_response-1766762565\",\"monitor_priority\":5,\"retry\":{\"count\":3,\"interval\":10},\"tick_every\":60},\"subtype\":\"http\",\"tags\":[\"testing:api\"],\"type\":\"api\"}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/synthetics/tests/api"
39+
},
40+
"response": {
41+
"bodySize": 2672,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 2672,
45+
"text": "{\"public_id\":\"f8v-zk3-x5h\",\"name\":\"Test-Create_a_multistep_test_with_subtest_returns_OK_response-1766762565\",\"status\":\"live\",\"type\":\"api\",\"subtype\":\"http\",\"tags\":[\"testing:api\"],\"created_at\":\"2025-12-26T15:22:45.449340+00:00\",\"modified_at\":\"2025-12-26T15:22:45.449340+00:00\",\"config\":{\"assertions\":[{\"operator\":\"is\",\"property\":\"{{ PROPERTY }}\",\"target\":\"text/html\",\"type\":\"header\"},{\"operator\":\"lessThan\",\"target\":2000,\"timingsScope\":\"withoutDNS\",\"type\":\"responseTime\"},{\"operator\":\"validatesJSONPath\",\"target\":{\"jsonPath\":\"topKey\",\"operator\":\"isNot\",\"targetValue\":\"0\"},\"type\":\"body\"},{\"operator\":\"validatesJSONPath\",\"target\":{\"elementsOperator\":\"atLeastOneElementMatches\",\"jsonPath\":\"topKey\",\"operator\":\"isNot\",\"targetValue\":\"0\"},\"type\":\"body\"},{\"operator\":\"validatesJSONSchema\",\"target\":{\"jsonSchema\":\"{\\\"type\\\": \\\"object\\\", \\\"properties\\\":{\\\"slideshow\\\":{\\\"type\\\":\\\"object\\\"}}}\",\"metaSchema\":\"draft-07\"},\"type\":\"body\"},{\"operator\":\"validatesXPath\",\"target\":{\"operator\":\"contains\",\"targetValue\":\"0\",\"xPath\":\"target-xpath\"},\"type\":\"body\"},{\"operator\":\"md5\",\"target\":\"a\",\"type\":\"bodyHash\"},{\"code\":\"const hello = 'world';\",\"type\":\"javascript\"}],\"configVariables\":[{\"example\":\"content-type\",\"name\":\"PROPERTY\",\"pattern\":\"content-type\",\"type\":\"text\"}],\"request\":{\"basicAuth\":{\"accessTokenUrl\":\"https://datadog-token.com\",\"audience\":\"audience\",\"clientId\":\"client-id\",\"clientSecret\":\"client-secret\",\"resource\":\"resource\",\"scope\":\"yoyo\",\"tokenApiAuthentication\":\"header\",\"type\":\"oauth-client\"},\"certificate\":{\"cert\":{\"filename\":\"cert-filename\",\"updatedAt\":\"2020-10-16T09:23:24.857Z\"},\"key\":{\"filename\":\"key-filename\",\"updatedAt\":\"2020-10-16T09:23:24.857Z\"}},\"headers\":{\"unique\":\"testcreateamultisteptestwithsubtestreturnsokresponse1766762565\"},\"method\":\"GET\",\"persistCookies\":true,\"proxy\":{\"headers\":{},\"url\":\"https://datadoghq.com\"},\"timeout\":10,\"url\":\"https://datadoghq.com\"},\"variablesFromScript\":\"dd.variable.set(\\\"FOO\\\", \\\"foo\\\")\"},\"message\":\"BDD test payload: synthetics_api_http_test_payload.json\",\"options\":{\"accept_self_signed\":false,\"allow_insecure\":true,\"follow_redirects\":true,\"httpVersion\":\"http2\",\"min_failure_duration\":10,\"min_location_failed\":1,\"monitor_name\":\"Test-Create_a_multistep_test_with_subtest_returns_OK_response-1766762565\",\"monitor_priority\":5,\"retry\":{\"count\":3,\"interval\":10},\"tick_every\":60},\"locations\":[\"aws:us-east-2\"],\"created_by\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\"},\"deleted_at\":null,\"monitor_id\":246774114,\"org_id\":321813,\"modified_by\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\"}}"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 694,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2025-12-26T15:22:45.124Z",
61+
"time": 408
62+
},
63+
{
64+
"_id": "123c3f3ada86427b2d826ff1554c902b",
65+
"_order": 0,
66+
"cache": {},
67+
"request": {
68+
"bodySize": 586,
69+
"cookies": [],
70+
"headers": [
71+
{
72+
"_fromType": "array",
73+
"name": "accept",
74+
"value": "application/json"
75+
},
76+
{
77+
"_fromType": "array",
78+
"name": "content-type",
79+
"value": "application/json"
80+
}
81+
],
82+
"headersSize": 578,
83+
"httpVersion": "HTTP/1.1",
84+
"method": "POST",
85+
"postData": {
86+
"mimeType": "application/json",
87+
"params": [],
88+
"text": "{\"config\":{\"steps\":[{\"assertions\":[{\"operator\":\"is\",\"target\":200,\"type\":\"statusCode\"}],\"name\":\"request is sent\",\"request\":{\"basicAuth\":{\"password\":\"password\",\"username\":\"username\"},\"method\":\"GET\",\"url\":\"https://httpbin.org/status/200\"},\"subtype\":\"http\"},{\"name\":\"subtest step\",\"subtestPublicId\":\"f8v-zk3-x5h\",\"subtype\":\"playSubTest\"}]},\"locations\":[\"aws:us-east-2\"],\"message\":\"BDD test payload: synthetics_api_test_multi_step_with_subtest.json\",\"name\":\"Test-Create_a_multistep_test_with_subtest_returns_OK_response-1766762565\",\"options\":{\"tick_every\":60},\"subtype\":\"multi\",\"type\":\"api\"}"
89+
},
90+
"queryString": [],
91+
"url": "https://api.datadoghq.com/api/v1/synthetics/tests/api"
92+
},
93+
"response": {
94+
"bodySize": 1098,
95+
"content": {
96+
"mimeType": "application/json",
97+
"size": 1098,
98+
"text": "{\"public_id\":\"5kg-4fz-eh9\",\"name\":\"Test-Create_a_multistep_test_with_subtest_returns_OK_response-1766762565\",\"status\":\"live\",\"type\":\"api\",\"subtype\":\"multi\",\"tags\":[],\"created_at\":\"2025-12-26T15:22:45.980687+00:00\",\"modified_at\":\"2025-12-26T15:22:45.980687+00:00\",\"config\":{\"steps\":[{\"assertions\":[{\"operator\":\"is\",\"target\":200,\"type\":\"statusCode\"}],\"name\":\"request is sent\",\"request\":{\"basicAuth\":{\"password\":\"password\",\"username\":\"username\"},\"method\":\"GET\",\"url\":\"https://httpbin.org/status/200\"},\"subtype\":\"http\",\"id\":\"cyy-kz8-9b6\"},{\"name\":\"subtest step\",\"subtestPublicId\":\"f8v-zk3-x5h\",\"subtype\":\"playSubTest\",\"id\":\"se7-rsj-k3p\"}]},\"message\":\"BDD test payload: synthetics_api_test_multi_step_with_subtest.json\",\"options\":{\"tick_every\":60},\"locations\":[\"aws:us-east-2\"],\"created_by\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\"},\"deleted_at\":null,\"monitor_id\":246774122,\"org_id\":321813,\"modified_by\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\"}}"
99+
},
100+
"cookies": [],
101+
"headers": [
102+
{
103+
"name": "content-type",
104+
"value": "application/json"
105+
}
106+
],
107+
"headersSize": 694,
108+
"httpVersion": "HTTP/1.1",
109+
"redirectURL": "",
110+
"status": 200,
111+
"statusText": "OK"
112+
},
113+
"startedDateTime": "2025-12-26T15:22:45.540Z",
114+
"time": 603
115+
},
116+
{
117+
"_id": "54491da2fbfa2588131ab10b8d962034",
118+
"_order": 0,
119+
"cache": {},
120+
"request": {
121+
"bodySize": 30,
122+
"cookies": [],
123+
"headers": [
124+
{
125+
"_fromType": "array",
126+
"name": "accept",
127+
"value": "application/json"
128+
},
129+
{
130+
"_fromType": "array",
131+
"name": "content-type",
132+
"value": "application/json"
133+
}
134+
],
135+
"headersSize": 568,
136+
"httpVersion": "HTTP/1.1",
137+
"method": "POST",
138+
"postData": {
139+
"mimeType": "application/json",
140+
"params": [],
141+
"text": "{\"public_ids\":[\"5kg-4fz-eh9\"]}"
142+
},
143+
"queryString": [],
144+
"url": "https://api.datadoghq.com/api/v1/synthetics/tests/delete"
145+
},
146+
"response": {
147+
"bodySize": 96,
148+
"content": {
149+
"mimeType": "application/json",
150+
"size": 96,
151+
"text": "{\"deleted_tests\":[{\"public_id\":\"5kg-4fz-eh9\",\"deleted_at\":\"2025-12-26T15:22:46.386306+00:00\"}]}\n"
152+
},
153+
"cookies": [],
154+
"headers": [
155+
{
156+
"name": "content-type",
157+
"value": "application/json"
158+
}
159+
],
160+
"headersSize": 693,
161+
"httpVersion": "HTTP/1.1",
162+
"redirectURL": "",
163+
"status": 200,
164+
"statusText": "OK"
165+
},
166+
"startedDateTime": "2025-12-26T15:22:46.149Z",
167+
"time": 473
168+
},
169+
{
170+
"_id": "711d0c79366cf9fbdac1674f371fa343",
171+
"_order": 0,
172+
"cache": {},
173+
"request": {
174+
"bodySize": 30,
175+
"cookies": [],
176+
"headers": [
177+
{
178+
"_fromType": "array",
179+
"name": "accept",
180+
"value": "application/json"
181+
},
182+
{
183+
"_fromType": "array",
184+
"name": "content-type",
185+
"value": "application/json"
186+
}
187+
],
188+
"headersSize": 568,
189+
"httpVersion": "HTTP/1.1",
190+
"method": "POST",
191+
"postData": {
192+
"mimeType": "application/json",
193+
"params": [],
194+
"text": "{\"public_ids\":[\"f8v-zk3-x5h\"]}"
195+
},
196+
"queryString": [],
197+
"url": "https://api.datadoghq.com/api/v1/synthetics/tests/delete"
198+
},
199+
"response": {
200+
"bodySize": 96,
201+
"content": {
202+
"mimeType": "application/json",
203+
"size": 96,
204+
"text": "{\"deleted_tests\":[{\"public_id\":\"f8v-zk3-x5h\",\"deleted_at\":\"2025-12-26T15:22:46.982158+00:00\"}]}\n"
205+
},
206+
"cookies": [],
207+
"headers": [
208+
{
209+
"name": "content-type",
210+
"value": "application/json"
211+
}
212+
],
213+
"headersSize": 693,
214+
"httpVersion": "HTTP/1.1",
215+
"redirectURL": "",
216+
"status": 200,
217+
"statusText": "OK"
218+
},
219+
"startedDateTime": "2025-12-26T15:22:46.641Z",
220+
"time": 635
221+
}
222+
],
223+
"pages": [],
224+
"version": "1.2"
225+
}
226+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* Create a multistep test with subtest returns "OK" response
3+
*/
4+
5+
import { client, v1 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v1.SyntheticsApi(configuration);
9+
10+
// there is a valid "synthetics_api_test" in the system
11+
const SYNTHETICS_API_TEST_PUBLIC_ID = process.env
12+
.SYNTHETICS_API_TEST_PUBLIC_ID as string;
13+
14+
const params: v1.SyntheticsApiCreateSyntheticsAPITestRequest = {
15+
body: {
16+
config: {
17+
steps: [
18+
{
19+
assertions: [
20+
{
21+
operator: "is",
22+
type: "statusCode",
23+
target: 200,
24+
},
25+
],
26+
name: "request is sent",
27+
request: {
28+
url: "https://httpbin.org/status/200",
29+
method: "GET",
30+
basicAuth: {
31+
password: "password",
32+
username: "username",
33+
},
34+
},
35+
subtype: "http",
36+
},
37+
{
38+
subtype: "playSubTest",
39+
subtestPublicId: SYNTHETICS_API_TEST_PUBLIC_ID,
40+
name: "subtest step",
41+
},
42+
],
43+
},
44+
locations: ["aws:us-east-2"],
45+
message:
46+
"BDD test payload: synthetics_api_test_multi_step_with_subtest.json",
47+
name: "Example-Synthetic",
48+
options: {
49+
tickEvery: 60,
50+
},
51+
subtype: "multi",
52+
type: "api",
53+
},
54+
};
55+
56+
apiInstance
57+
.createSyntheticsAPITest(params)
58+
.then((data: v1.SyntheticsAPITest) => {
59+
console.log(
60+
"API called successfully. Returned data: " + JSON.stringify(data)
61+
);
62+
})
63+
.catch((error: any) => console.error(error));

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

0 commit comments

Comments
 (0)