Skip to content

Commit

Permalink
[datadog_synthetics_test] Add default value to http_version (#2406)
Browse files Browse the repository at this point in the history
* Fix location of `http_version`

* Add a default value for `httpVersion`

* update cassettes

* make docs

* update monitor test that uses a synthetics test

* deprecate request_defintion.http_version instead of removing it

---------

Co-authored-by: Kevin Zou <[email protected]>
  • Loading branch information
Drarig29 and nkzou authored Jul 5, 2024
1 parent d5d4b67 commit ba28000
Show file tree
Hide file tree
Showing 68 changed files with 1,970 additions and 1,576 deletions.
14 changes: 13 additions & 1 deletion datadog/resource_datadog_synthetics_test_.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,12 @@ func syntheticsTestRequest() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"http_version": syntheticsHttpVersionOption(),
"http_version": {
Description: "HTTP version to use for an HTTP request in an API test or step.",
Deprecated: "Use `http_version` in the `options_list` field instead.",
Type: schema.TypeString,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -808,6 +813,7 @@ func syntheticsTestAPIStep() *schema.Schema {
// In test `options_list` for single API tests, but in `api_step.request_definition` for API steps.
requestElemSchema.Schema["allow_insecure"] = syntheticsAllowInsecureOption()
requestElemSchema.Schema["follow_redirects"] = syntheticsFollowRedirectsOption()
requestElemSchema.Schema["http_version"] = syntheticsHttpVersionOption()

return &schema.Schema{
Description: "Steps for multi-step api tests",
Expand Down Expand Up @@ -1307,6 +1313,7 @@ func syntheticsFollowRedirectsOption() *schema.Schema {
func syntheticsHttpVersionOption() *schema.Schema {
return &schema.Schema{
Description: "HTTP version to use for an HTTP request in an API test or step.",
Default: datadogV1.SYNTHETICSTESTOPTIONSHTTPVERSION_ANY,
Type: schema.TypeString,
Optional: true,
ValidateDiagFunc: validators.ValidateEnumValue(datadogV1.NewSyntheticsTestOptionsHTTPVersionFromValue),
Expand Down Expand Up @@ -3392,6 +3399,11 @@ func updateSyntheticsAPITestLocalState(d *schema.ResourceData, syntheticsTest *d
localRequest := buildLocalRequest(stepRequest)
localRequest["allow_insecure"] = stepRequest.GetAllowInsecure()
localRequest["follow_redirects"] = stepRequest.GetFollowRedirects()
if step.SyntheticsAPITestStep.GetSubtype() == "grpc" {
// the schema defines a default value of `http_version` for any kind of step,
// but it's not supported for `grpc` - so we save `any` in the local state to avoid diffs
localRequest["http_version"] = datadogV1.SYNTHETICSTESTOPTIONSHTTPVERSION_ANY
}
localStep["request_definition"] = []map[string]interface{}{localRequest}
localStep["request_headers"] = stepRequest.GetHeaders()
localStep["request_query"] = stepRequest.GetQuery()
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-10-31T14:16:21.62046-04:00
2024-07-03T17:03:01.871728-04:00
1,290 changes: 836 additions & 454 deletions datadog/tests/cassettes/TestAccDatadogMonitor_ComposeWithSyntheticsTest.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-06-28T17:54:58.10298+02:00
2024-07-03T16:50:11.080832-04:00

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-06-28T17:54:50.822748+02:00
2024-07-03T16:50:01.440026-04:00
120 changes: 60 additions & 60 deletions datadog/tests/cassettes/TestAccDatadogSyntheticsAPITest_Updated.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-06-28T17:54:50.818516+02:00
2024-07-03T16:50:07.519095-04:00

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-06-28T17:54:58.626473+02:00
2024-07-03T16:49:55.107622-04:00

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-06-28T17:55:03.218618+02:00
2024-07-03T16:50:01.902524-04:00

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-06-28T17:55:09.157994+02:00
2024-07-03T16:50:06.409061-04:00

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-06-28T17:55:03.624982+02:00
2024-07-03T16:50:05.989258-04:00

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-06-28T17:55:02.970716+02:00
2024-07-03T16:49:55.112308-04:00

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-06-28T17:55:03.547984+02:00
2024-07-03T16:49:55.114475-04:00

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-06-28T17:54:50.814378+02:00
2024-07-03T16:50:08.196552-04:00

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-06-28T17:55:04.333647+02:00
2024-07-03T16:49:55.106358-04:00
42 changes: 21 additions & 21 deletions datadog/tests/cassettes/TestAccDatadogSyntheticsDNSTest_Basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ interactions:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 480
content_length: 500
transfer_encoding: []
trailer: {}
host: api.datadoghq.com
remote_addr: ""
request_uri: ""
body: |
{"config":{"assertions":[{"operator":"is","property":"A","target":"0.0.0.0","type":"recordSome"}],"configVariables":[],"request":{"dnsServer":"8.8.8.8","dnsServerPort":120,"host":"https://www.datadoghq.com","timeout":60}},"locations":["aws:eu-central-1"],"message":"Notify @datadog.user","name":"tf-TestAccDatadogSyntheticsDNSTest_Basic-local-1719590104","options":{"min_location_failed":1,"tick_every":60},"status":"paused","subtype":"dns","tags":["foo:bar","baz"],"type":"api"}
{"config":{"assertions":[{"operator":"is","property":"A","target":"0.0.0.0","type":"recordSome"}],"configVariables":[],"request":{"dnsServer":"8.8.8.8","dnsServerPort":120,"host":"https://www.datadoghq.com","timeout":60}},"locations":["aws:eu-central-1"],"message":"Notify @datadog.user","name":"tf-TestAccDatadogSyntheticsDNSTest_Basic-local-1720039795","options":{"httpVersion":"any","min_location_failed":1,"tick_every":60},"status":"paused","subtype":"dns","tags":["foo:bar","baz"],"type":"api"}
form: {}
headers:
Accept:
Expand All @@ -32,13 +32,13 @@ interactions:
content_length: -1
uncompressed: true
body: |
{"public_id":"dju-tzu-3d8","name":"tf-TestAccDatadogSyntheticsDNSTest_Basic-local-1719590104","status":"paused","type":"api","tags":["foo:bar","baz"],"created_at":"2024-06-28T15:55:07.514871+00:00","modified_at":"2024-06-28T15:55:07.514871+00:00","config":{"assertions":[{"operator":"is","property":"A","target":"0.0.0.0","type":"recordSome"}],"configVariables":[],"request":{"dnsServer":"8.8.8.8","dnsServerPort":120,"host":"https://www.datadoghq.com","timeout":60}},"message":"Notify @datadog.user","options":{"min_location_failed":1,"tick_every":60},"locations":["aws:eu-central-1"],"subtype":"dns","created_by":{"name":null,"handle":"[email protected]","email":"[email protected]"},"deleted_at":null,"monitor_id":148146231,"org_id":321813,"modified_by":{"name":null,"handle":"[email protected]","email":"[email protected]"}}
{"public_id":"4w8-djq-mcn","name":"tf-TestAccDatadogSyntheticsDNSTest_Basic-local-1720039795","status":"paused","type":"api","tags":["foo:bar","baz"],"created_at":"2024-07-03T20:49:57.813055+00:00","modified_at":"2024-07-03T20:49:57.813055+00:00","config":{"assertions":[{"operator":"is","property":"A","target":"0.0.0.0","type":"recordSome"}],"configVariables":[],"request":{"dnsServer":"8.8.8.8","dnsServerPort":120,"host":"https://www.datadoghq.com","timeout":60}},"message":"Notify @datadog.user","options":{"httpVersion":"any","min_location_failed":1,"tick_every":60},"locations":["aws:eu-central-1"],"subtype":"dns","created_by":{"name":null,"handle":"[email protected]","email":"[email protected]"},"deleted_at":null,"monitor_id":148530425,"org_id":321813,"modified_by":{"name":null,"handle":"[email protected]","email":"[email protected]"}}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 1.371106458s
duration: 716.77525ms
- id: 1
request:
proto: HTTP/1.1
Expand All @@ -55,7 +55,7 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/synthetics/tests/api/dju-tzu-3d8
url: https://api.datadoghq.com/api/v1/synthetics/tests/api/4w8-djq-mcn
method: GET
response:
proto: HTTP/1.1
Expand All @@ -67,13 +67,13 @@ interactions:
content_length: -1
uncompressed: true
body: |
{"public_id":"dju-tzu-3d8","name":"tf-TestAccDatadogSyntheticsDNSTest_Basic-local-1719590104","status":"paused","type":"api","tags":["foo:bar","baz"],"created_at":"2024-06-28T15:55:07.514871+00:00","modified_at":"2024-06-28T15:55:07.514871+00:00","config":{"assertions":[{"operator":"is","property":"A","target":"0.0.0.0","type":"recordSome"}],"configVariables":[],"request":{"dnsServer":"8.8.8.8","dnsServerPort":120,"host":"https://www.datadoghq.com","timeout":60}},"message":"Notify @datadog.user","options":{"min_location_failed":1,"tick_every":60},"locations":["aws:eu-central-1"],"subtype":"dns","monitor_id":148146231,"creator":{"name":null,"handle":"[email protected]","email":"[email protected]"}}
{"public_id":"4w8-djq-mcn","name":"tf-TestAccDatadogSyntheticsDNSTest_Basic-local-1720039795","status":"paused","type":"api","tags":["foo:bar","baz"],"created_at":"2024-07-03T20:49:57.813055+00:00","modified_at":"2024-07-03T20:49:57.813055+00:00","config":{"assertions":[{"operator":"is","property":"A","target":"0.0.0.0","type":"recordSome"}],"configVariables":[],"request":{"dnsServer":"8.8.8.8","dnsServerPort":120,"host":"https://www.datadoghq.com","timeout":60}},"message":"Notify @datadog.user","options":{"httpVersion":"any","min_location_failed":1,"tick_every":60},"locations":["aws:eu-central-1"],"subtype":"dns","monitor_id":148530425,"creator":{"name":null,"handle":"[email protected]","email":"[email protected]"}}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 148.16825ms
duration: 79.944084ms
- id: 2
request:
proto: HTTP/1.1
Expand All @@ -90,7 +90,7 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/synthetics/tests/dju-tzu-3d8
url: https://api.datadoghq.com/api/v1/synthetics/tests/4w8-djq-mcn
method: GET
response:
proto: HTTP/1.1
Expand All @@ -102,13 +102,13 @@ interactions:
content_length: -1
uncompressed: true
body: |
{"public_id":"dju-tzu-3d8","name":"tf-TestAccDatadogSyntheticsDNSTest_Basic-local-1719590104","status":"paused","type":"api","tags":["foo:bar","baz"],"created_at":"2024-06-28T15:55:07.514871+00:00","modified_at":"2024-06-28T15:55:07.514871+00:00","config":{"assertions":[{"operator":"is","property":"A","target":"0.0.0.0","type":"recordSome"}],"configVariables":[],"request":{"dnsServer":"8.8.8.8","dnsServerPort":120,"host":"https://www.datadoghq.com","timeout":60}},"message":"Notify @datadog.user","options":{"min_location_failed":1,"tick_every":60},"locations":["aws:eu-central-1"],"subtype":"dns","monitor_id":148146231,"creator":{"name":null,"handle":"[email protected]","email":"[email protected]"}}
{"public_id":"4w8-djq-mcn","name":"tf-TestAccDatadogSyntheticsDNSTest_Basic-local-1720039795","status":"paused","type":"api","tags":["foo:bar","baz"],"created_at":"2024-07-03T20:49:57.813055+00:00","modified_at":"2024-07-03T20:49:57.813055+00:00","config":{"assertions":[{"operator":"is","property":"A","target":"0.0.0.0","type":"recordSome"}],"configVariables":[],"request":{"dnsServer":"8.8.8.8","dnsServerPort":120,"host":"https://www.datadoghq.com","timeout":60}},"message":"Notify @datadog.user","options":{"httpVersion":"any","min_location_failed":1,"tick_every":60},"locations":["aws:eu-central-1"],"subtype":"dns","monitor_id":148530425,"creator":{"name":null,"handle":"[email protected]","email":"[email protected]"}}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 231.057791ms
duration: 84.062458ms
- id: 3
request:
proto: HTTP/1.1
Expand All @@ -125,7 +125,7 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/synthetics/tests/dju-tzu-3d8
url: https://api.datadoghq.com/api/v1/synthetics/tests/4w8-djq-mcn
method: GET
response:
proto: HTTP/1.1
Expand All @@ -137,13 +137,13 @@ interactions:
content_length: -1
uncompressed: true
body: |
{"public_id":"dju-tzu-3d8","name":"tf-TestAccDatadogSyntheticsDNSTest_Basic-local-1719590104","status":"paused","type":"api","tags":["foo:bar","baz"],"created_at":"2024-06-28T15:55:07.514871+00:00","modified_at":"2024-06-28T15:55:07.514871+00:00","config":{"assertions":[{"operator":"is","property":"A","target":"0.0.0.0","type":"recordSome"}],"configVariables":[],"request":{"dnsServer":"8.8.8.8","dnsServerPort":120,"host":"https://www.datadoghq.com","timeout":60}},"message":"Notify @datadog.user","options":{"min_location_failed":1,"tick_every":60},"locations":["aws:eu-central-1"],"subtype":"dns","monitor_id":148146231,"creator":{"name":null,"handle":"[email protected]","email":"[email protected]"}}
{"public_id":"4w8-djq-mcn","name":"tf-TestAccDatadogSyntheticsDNSTest_Basic-local-1720039795","status":"paused","type":"api","tags":["foo:bar","baz"],"created_at":"2024-07-03T20:49:57.813055+00:00","modified_at":"2024-07-03T20:49:57.813055+00:00","config":{"assertions":[{"operator":"is","property":"A","target":"0.0.0.0","type":"recordSome"}],"configVariables":[],"request":{"dnsServer":"8.8.8.8","dnsServerPort":120,"host":"https://www.datadoghq.com","timeout":60}},"message":"Notify @datadog.user","options":{"httpVersion":"any","min_location_failed":1,"tick_every":60},"locations":["aws:eu-central-1"],"subtype":"dns","monitor_id":148530425,"creator":{"name":null,"handle":"[email protected]","email":"[email protected]"}}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 151.227792ms
duration: 77.710291ms
- id: 4
request:
proto: HTTP/1.1
Expand All @@ -160,7 +160,7 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/synthetics/tests/api/dju-tzu-3d8
url: https://api.datadoghq.com/api/v1/synthetics/tests/api/4w8-djq-mcn
method: GET
response:
proto: HTTP/1.1
Expand All @@ -172,13 +172,13 @@ interactions:
content_length: -1
uncompressed: true
body: |
{"public_id":"dju-tzu-3d8","name":"tf-TestAccDatadogSyntheticsDNSTest_Basic-local-1719590104","status":"paused","type":"api","tags":["foo:bar","baz"],"created_at":"2024-06-28T15:55:07.514871+00:00","modified_at":"2024-06-28T15:55:07.514871+00:00","config":{"assertions":[{"operator":"is","property":"A","target":"0.0.0.0","type":"recordSome"}],"configVariables":[],"request":{"dnsServer":"8.8.8.8","dnsServerPort":120,"host":"https://www.datadoghq.com","timeout":60}},"message":"Notify @datadog.user","options":{"min_location_failed":1,"tick_every":60},"locations":["aws:eu-central-1"],"subtype":"dns","monitor_id":148146231,"creator":{"name":null,"handle":"[email protected]","email":"[email protected]"}}
{"public_id":"4w8-djq-mcn","name":"tf-TestAccDatadogSyntheticsDNSTest_Basic-local-1720039795","status":"paused","type":"api","tags":["foo:bar","baz"],"created_at":"2024-07-03T20:49:57.813055+00:00","modified_at":"2024-07-03T20:49:57.813055+00:00","config":{"assertions":[{"operator":"is","property":"A","target":"0.0.0.0","type":"recordSome"}],"configVariables":[],"request":{"dnsServer":"8.8.8.8","dnsServerPort":120,"host":"https://www.datadoghq.com","timeout":60}},"message":"Notify @datadog.user","options":{"httpVersion":"any","min_location_failed":1,"tick_every":60},"locations":["aws:eu-central-1"],"subtype":"dns","monitor_id":148530425,"creator":{"name":null,"handle":"[email protected]","email":"[email protected]"}}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 148.149125ms
duration: 74.1885ms
- id: 5
request:
proto: HTTP/1.1
Expand All @@ -191,7 +191,7 @@ interactions:
remote_addr: ""
request_uri: ""
body: |
{"public_ids":["dju-tzu-3d8"]}
{"public_ids":["4w8-djq-mcn"]}
form: {}
headers:
Accept:
Expand All @@ -210,13 +210,13 @@ interactions:
content_length: -1
uncompressed: true
body: |
{"deleted_tests":[{"public_id":"dju-tzu-3d8","deleted_at":"2024-06-28T15:55:10.953006+00:00"}]}
{"deleted_tests":[{"public_id":"4w8-djq-mcn","deleted_at":"2024-07-03T20:50:00.808868+00:00"}]}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 665.292459ms
duration: 1.511404709s
- id: 6
request:
proto: HTTP/1.1
Expand All @@ -233,7 +233,7 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/synthetics/tests/dju-tzu-3d8
url: https://api.datadoghq.com/api/v1/synthetics/tests/4w8-djq-mcn
method: GET
response:
proto: HTTP/1.1
Expand All @@ -250,4 +250,4 @@ interactions:
- application/json
status: 404 Not Found
code: 404
duration: 133.833459ms
duration: 56.432916ms
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-06-28T17:55:05.849411+02:00
2024-07-03T16:50:14.655997-04:00
Loading

0 comments on commit ba28000

Please sign in to comment.