Skip to content

Commit 43c3133

Browse files
authored
Add missing usage tests and asserts (#239)
1 parent 2000294 commit 43c3133

File tree

5 files changed

+93
-18
lines changed

5 files changed

+93
-18
lines changed

src/test/java/com/datadog/api/v1/client/api/UsageMeteringApiTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,10 @@ public void getUsageSummaryTest() throws ApiException, IOException {
180180
assertEquals(usage.getInfraHostTop99pSum().longValue(), 2L);
181181
assertEquals(usage.getContainerHwmSum().longValue(), 1L);
182182
assertEquals(usage.getCustomTsSum().longValue(), 4L);
183+
assertEquals(usage.getRumSessionCountAggSum().longValue(), 5L);
183184

184185
// Note the nanosecond field had to be converted from the value in the summary fixture (i.e. 0.014039s -> 14039000ns)
185-
OffsetDateTime dateExpected = OffsetDateTime.of(LocalDateTime.of(2020, 02, 02, 16, 34, 14, 14039000),
186+
OffsetDateTime dateExpected = OffsetDateTime.of(LocalDateTime.of(2020, 02, 02, 23, 00),
186187
ZoneOffset.ofHoursMinutes(0, 0));
187188
UsageSummaryDate usageItem = usage.getUsage().get(0);
188189
assertEquals(usageItem.getDate(), dateExpected);
@@ -193,6 +194,7 @@ public void getUsageSummaryTest() throws ApiException, IOException {
193194
assertEquals(usageItem.getCustomTsAvg().longValue(), 6L);
194195
assertEquals(usageItem.getGcpHostTop99p().longValue(), 7L);
195196
assertEquals(usageItem.getInfraHostTop99p().longValue(), 8L);
197+
assertEquals(usageItem.getRumSessionCountSum().longValue(), 9L);
196198

197199
UsageSummaryDateOrg usageOrgItem = usageItem.getOrgs().get(0);
198200
assertEquals(usageOrgItem.getId(), "1b");
@@ -204,6 +206,7 @@ public void getUsageSummaryTest() throws ApiException, IOException {
204206
assertEquals(usageOrgItem.getCustomTsAvg().longValue(), 6L);
205207
assertEquals(usageOrgItem.getGcpHostTop99p().longValue(), 7L);
206208
assertEquals(usageOrgItem.getInfraHostTop99p().longValue(), 8L);
209+
assertEquals(usageOrgItem.getRumSessionCountSum().longValue(), 9L);
207210
}
208211

209212
@Test
@@ -261,6 +264,15 @@ public void getUsageTraceTest() throws ApiException {
261264
assertNotNull(response.getUsage());
262265
}
263266

267+
@Test
268+
public void getUsageLambdaTest() throws ApiException {
269+
UsageLambdaResponse response = api.getUsageLambda()
270+
.startHr(startHr)
271+
.endHr(endHr)
272+
.execute();
273+
assertNotNull(response.getUsage());
274+
}
275+
264276
@Test
265277
public void getUsageAnalyzedLogsErrorsTest() throws IOException {
266278
try {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2020-05-27T21:24:37.647Z
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[{
2+
"id" : "18ae89aa-fbdc-4151-8cc6-fc506245f02a",
3+
"httpRequest" : {
4+
"method" : "GET",
5+
"path" : "/api/v1/usage/aws_lambda",
6+
"queryStringParameters" : {
7+
"start_hr" : [ "2020-04-01T12:00Z" ],
8+
"end_hr" : [ "2020-04-01T13:00Z" ]
9+
},
10+
"headers" : {
11+
"Accept" : [ "application/json;datetime-format=rfc3339" ],
12+
"JAVA-TEST-NAME" : [ "getUsageLambdaTest" ],
13+
"DD-OPERATION-ID" : [ "getUsageLambda" ],
14+
"Connection" : [ "close" ],
15+
"content-length" : [ "0" ]
16+
},
17+
"keepAlive" : false,
18+
"secure" : true
19+
},
20+
"times" : {
21+
"remainingTimes" : 1
22+
},
23+
"timeToLive" : {
24+
"unlimited" : true
25+
},
26+
"httpResponse" : {
27+
"statusCode" : 200,
28+
"reasonPhrase" : "OK",
29+
"headers" : {
30+
"Date" : [ "Wed, 27 May 2020 21:24:44 GMT" ],
31+
"Content-Type" : [ "application/json" ],
32+
"Connection" : [ "keep-alive" ],
33+
"Vary" : [ "Accept-Encoding" ],
34+
"Pragma" : [ "no-cache" ],
35+
"Cache-Control" : [ "no-cache" ],
36+
"Set-Cookie" : [ "DD-PSHARD=233; Max-Age=604800; Path=/; expires=Wed, 03-Jun-2020 21:24:44 GMT; secure; HttpOnly" ],
37+
"X-DD-VERSION" : [ "35.2552800" ],
38+
"X-RateLimit-Limit" : [ "400" ],
39+
"X-RateLimit-Period" : [ "3600" ],
40+
"X-RateLimit-Reset" : [ "2116" ],
41+
"X-RateLimit-Remaining" : [ "367" ],
42+
"X-DD-Debug" : [ "aERr2Ftx8O/BR8oAhSymZ3bVROQEC+81YMSphOQK1me4DxXSbMIcFkB0Di4ggZ++" ],
43+
"DD-POOL" : [ "dogweb" ],
44+
"Content-Security-Policy" : [ "frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report" ],
45+
"X-Frame-Options" : [ "SAMEORIGIN" ],
46+
"X-Content-Type-Options" : [ "nosniff" ],
47+
"Strict-Transport-Security" : [ "max-age=15724800;" ],
48+
"content-length" : [ "83" ]
49+
},
50+
"cookies" : {
51+
"DD-PSHARD" : "233"
52+
},
53+
"body" : "{\"usage\":[{\"func_count\":0,\"hour\":\"2020-04-01T12:00:00+00:00\",\"invocations_sum\":0}]}"
54+
}
55+
}]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2020-05-27T10:28:10.845Z
1+
2020-05-27T21:23:59.012Z

src/test/resources/com/datadog/api/v1/client/api/usage_fixtures/usage_summary.json

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,32 @@
55
"infra_host_top99p_sum": 2,
66
"container_hwm_sum": 1,
77
"custom_ts_sum": 4,
8-
"usage": [{
9-
"date": "2020-02-02T16:34:14.014039+00:00",
10-
"agent_host_top99p": 1,
11-
"apm_host_top99p": 2,
12-
"aws_host_top99p": 3,
13-
"container_hwm": 5,
14-
"custom_ts_avg": 6,
15-
"gcp_host_top99p": 7,
16-
"infra_host_top99p": 8,
17-
"orgs": [{
18-
"id": "1b",
19-
"name": "datadog",
8+
"rum_session_count_agg_sum": 5,
9+
"usage": [
10+
{
11+
"date": "2020-02-02T23:00:00+00:00",
2012
"agent_host_top99p": 1,
2113
"apm_host_top99p": 2,
2214
"aws_host_top99p": 3,
2315
"container_hwm": 5,
2416
"custom_ts_avg": 6,
2517
"gcp_host_top99p": 7,
26-
"infra_host_top99p": 8
27-
}]
28-
}]
29-
}
18+
"infra_host_top99p": 8,
19+
"rum_session_count_sum": 9,
20+
"orgs": [
21+
{
22+
"id": "1b",
23+
"name": "datadog",
24+
"agent_host_top99p": 1,
25+
"apm_host_top99p": 2,
26+
"aws_host_top99p": 3,
27+
"container_hwm": 5,
28+
"custom_ts_avg": 6,
29+
"gcp_host_top99p": 7,
30+
"infra_host_top99p": 8,
31+
"rum_session_count_sum": 9
32+
}
33+
]
34+
}
35+
]
36+
}

0 commit comments

Comments
 (0)