Skip to content

Commit

Permalink
[SLO-3499] Remove hardcoded slo-reporter timestamps (#2138)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec committed Aug 29, 2024
1 parent 2b9db0c commit 9221073
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 25 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-08-28 20:30:29.955583",
"spec_repo_commit": "6b2f00dd"
"regenerated": "2024-08-29 20:02:03.124770",
"spec_repo_commit": "518ca9df"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-08-28 20:30:29.972727",
"spec_repo_commit": "6b2f00dd"
"regenerated": "2024-08-29 20:02:03.141872",
"spec_repo_commit": "518ca9df"
}
}
}
6 changes: 4 additions & 2 deletions examples/v2/service-level-objectives/CreateSLOReportJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Create a new SLO report returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.service_level_objectives_api import ServiceLevelObjectivesApi
from datadog_api_client.v2.model.slo_report_create_request import SloReportCreateRequest
Expand All @@ -12,8 +14,8 @@
body = SloReportCreateRequest(
data=SloReportCreateRequestData(
attributes=SloReportCreateRequestAttributes(
from_ts=1690901870,
to_ts=1706803070,
from_ts=int((datetime.now() + relativedelta(days=-40)).timestamp()),
to_ts=int(datetime.now().timestamp()),
query='slo_type:metric "SLO Reporting Test"',
interval=SLOReportInterval.MONTHLY,
timezone="America/New_York",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-04-18T20:09:43.575Z
2024-08-29T19:53:50.818Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
body: '{"data":{"attributes":{"from_ts":1690901870,"interval":"bad-interval","query":"slo_type:metric
\"SLO Reporting Test\"","to_ts":1706803070}}}'
body: '{"data":{"attributes":{"from_ts":1721505230,"interval":"bad-interval","query":"slo_type:metric
\"SLO Reporting Test\"","to_ts":1724961230}}}'
headers:
accept:
- application/json
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-04-18T20:09:43.729Z
2024-08-29T19:53:50.962Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
body: '{"data":{"attributes":{"from_ts":1690901870,"interval":"monthly","query":"slo_type:metric
\"SLO Reporting Test\"","timezone":"America/New_York","to_ts":1706803070}}}'
body: '{"data":{"attributes":{"from_ts":1721505230,"interval":"monthly","query":"slo_type:metric
\"SLO Reporting Test\"","timezone":"America/New_York","to_ts":1724961230}}}'
headers:
accept:
- application/json
Expand All @@ -11,7 +11,7 @@ interactions:
uri: https://api.datadoghq.com/api/v2/slo/report
response:
body:
string: '{"data":{"id":"98c67bea-fdbf-11ee-8a01-bfd37432018b","type":"report_id"}}'
string: '{"data":{"id":"69cfaa02-6640-11ef-8501-33b2b403f044","type":"report_id"}}'
headers:
content-type:
- application/vnd.api+json
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-04-18T20:09:43.887Z
2024-08-29T19:53:51.070Z
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-04-18T20:09:43.972Z
2024-08-29T19:53:51.158Z
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-04-18T20:09:44.063Z
2024-08-29T19:53:51.260Z
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-04-18T20:09:44.147Z
2024-08-29T19:53:51.364Z
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-04-18T20:09:44.243Z
2024-08-29T19:53:51.486Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
body: '{"data":{"attributes":{"from_ts":1711656584,"interval":"monthly","query":"slo_type:metric
\"SLO Reporting Test\"","to_ts":1713470984}}}'
body: '{"data":{"attributes":{"from_ts":1723146831,"interval":"monthly","query":"slo_type:metric
\"SLO Reporting Test\"","to_ts":1724961231}}}'
headers:
accept:
- application/json
Expand All @@ -11,7 +11,7 @@ interactions:
uri: https://api.datadoghq.com/api/v2/slo/report
response:
body:
string: '{"data":{"id":"990d70d6-fdbf-11ee-99ae-1f9640631fbf","type":"report_id"}}'
string: '{"data":{"id":"6a25239c-6640-11ef-943f-83644ac57ee3","type":"report_id"}}'
headers:
content-type:
- application/vnd.api+json
Expand All @@ -24,10 +24,10 @@ interactions:
accept:
- application/json
method: GET
uri: https://api.datadoghq.com/api/v2/slo/report/990d70d6-fdbf-11ee-99ae-1f9640631fbf/status
uri: https://api.datadoghq.com/api/v2/slo/report/6a25239c-6640-11ef-943f-83644ac57ee3/status
response:
body:
string: '{"data":{"id":"990d70d6-fdbf-11ee-99ae-1f9640631fbf","type":"report_id","attributes":{"status":"in_progress"}}}'
string: '{"data":{"id":"6a25239c-6640-11ef-943f-83644ac57ee3","type":"report_id","attributes":{"status":"in_progress"}}}'
headers:
content-type:
- application/vnd.api+json
Expand Down
4 changes: 2 additions & 2 deletions tests/v2/features/service_level_objectives.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ Feature: Service Level Objectives
Scenario: Create a new SLO report returns "Bad Request" response
Given operation "CreateSLOReportJob" enabled
And new "CreateSLOReportJob" request
And body with value {"data": {"attributes": {"from_ts": 1690901870, "to_ts": 1706803070, "query": "slo_type:metric \"SLO Reporting Test\"", "interval": "bad-interval"}}}
And body with value {"data": {"attributes": {"from_ts": {{ timestamp('now - 40d') }}, "to_ts": {{ timestamp('now') }}, "query": "slo_type:metric \"SLO Reporting Test\"", "interval": "bad-interval"}}}
When the request is sent
Then the response status is 400 Bad Request

@team:DataDog/slo-app
Scenario: Create a new SLO report returns "OK" response
Given operation "CreateSLOReportJob" enabled
And new "CreateSLOReportJob" request
And body with value {"data": {"attributes": {"from_ts": 1690901870, "to_ts": 1706803070, "query": "slo_type:metric \"SLO Reporting Test\"", "interval": "monthly", "timezone": "America/New_York"}}}
And body with value {"data": {"attributes": {"from_ts": {{ timestamp('now - 40d') }}, "to_ts": {{ timestamp('now') }}, "query": "slo_type:metric \"SLO Reporting Test\"", "interval": "monthly", "timezone": "America/New_York"}}}
When the request is sent
Then the response status is 200 OK
And the response "data.type" is equal to "report_id"
Expand Down

0 comments on commit 9221073

Please sign in to comment.