Skip to content

Commit 595f4f9

Browse files
committed
Add yaml tests for 4581, 4582, and 4632
Signed-off-by: Yuanchun Shen <[email protected]>
1 parent 9761de7 commit 595f4f9

File tree

4 files changed

+177
-3
lines changed

4 files changed

+177
-3
lines changed

integ-test/src/yamlRestTest/resources/rest-api-spec/test/issues/4550.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ setup:
4141
query: source=test_data_2023 | timechart span=500ms count()
4242

4343
- match: { total: 5 }
44-
- match: { "schema": [ { "name": "@timestamp", "type": "timestamp" }, { "name": "count", "type": "bigint" }] }
44+
- match: { "schema": [ { "name": "@timestamp", "type": "timestamp" }, { "name": "count()", "type": "bigint" }] }
4545
- match: {"datarows": [["2023-10-08 10:00:00", 1], ["2023-10-08 10:00:00.5", 1], ["2023-10-08 10:00:01", 1], ["2023-10-08 10:00:01.5", 1], ["2023-10-08 10:00:02", 1]]}
4646

4747
---
@@ -79,7 +79,7 @@ setup:
7979
query: source=test_data_2023 | timechart span=250milliseconds count()
8080

8181
- match: { total: 5 }
82-
- match: { "schema": [ { "name": "@timestamp", "type": "timestamp" }, { "name": "count", "type": "bigint" }] }
82+
- match: { "schema": [ { "name": "@timestamp", "type": "timestamp" }, { "name": "count()", "type": "bigint" }] }
8383

8484
---
8585
"timechart with second span for comparison":
@@ -97,5 +97,5 @@ setup:
9797
query: source=test_data_2023 | timechart span=1s count()
9898

9999
- match: { total: 3 }
100-
- match: { "schema": [ { "name": "@timestamp", "type": "timestamp" }, { "name": "count", "type": "bigint" }] }
100+
- match: { "schema": [ { "name": "@timestamp", "type": "timestamp" }, { "name": "count()", "type": "bigint" }] }
101101
- match: {"datarows": [["2023-10-08 10:00:00", 2], ["2023-10-08 10:00:01", 2], ["2023-10-08 10:00:02", 1]]}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
setup:
2+
- do:
3+
indices.create:
4+
index: opensearch-sql_test_index_otel_logs
5+
body:
6+
mappings:
7+
properties:
8+
"@timestamp":
9+
type: date
10+
"severityNumber":
11+
type: integer
12+
"flags":
13+
type: long
14+
- do:
15+
bulk:
16+
index: opensearch-sql_test_index_otel_logs
17+
refresh: true
18+
body:
19+
- '{"index":{}}'
20+
- '{"@timestamp":"2023-10-08T10:00:00.000Z","severityNumber":10,"flags":0}'
21+
- '{"index":{}}'
22+
- '{"@timestamp":"2023-10-08T10:00:01.000Z","severityNumber":12,"flags":0}'
23+
- '{"index":{}}'
24+
- '{"@timestamp":"2023-10-08T10:00:02.000Z","severityNumber":15,"flags":0}'
25+
- '{"index":{}}'
26+
- '{"@timestamp":"2023-10-08T10:00:03.000Z","severityNumber":13,"flags":0}'
27+
- '{"index":{}}'
28+
- '{"@timestamp":"2023-10-08T10:00:04.000Z","severityNumber":11,"flags":0}'
29+
- '{"index":{}}'
30+
- '{"@timestamp":"2023-10-08T10:00:05.000Z","severityNumber":14,"flags":0}'
31+
- '{"index":{}}'
32+
- '{"@timestamp":"2023-10-08T10:00:06.000Z","severityNumber":16,"flags":0}'
33+
- '{"index":{}}'
34+
- '{"@timestamp":"2023-10-08T10:00:07.000Z","severityNumber":9,"flags":1}'
35+
36+
---
37+
"timechart with grouping by non-string field":
38+
- skip:
39+
features:
40+
- headers
41+
- allowed_warnings
42+
- do:
43+
allowed_warnings:
44+
- 'Loading the fielddata on the _id field is deprecated and will be removed in future versions. If you require sorting or aggregating on this field you should also include the id in the body of your documents, and map this field as a keyword field that has [doc_values] enabled'
45+
headers:
46+
Content-Type: 'application/json'
47+
ppl:
48+
body:
49+
query: source=opensearch-sql_test_index_otel_logs | timechart avg(severityNumber) by flags
50+
51+
- match: { total: 2 }
52+
- match: { "schema": [ { "name": "@timestamp", "type": "timestamp" }, { "name": "flags", "type": "string" }, { "name": "avg(severityNumber)", "type": "double" }] }
53+
- match: {"datarows": [["2023-10-08 10:00:00", "0", 13.0], ["2023-10-08 10:00:00", "1", 9.0]]}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
setup:
2+
- do:
3+
indices.create:
4+
index: opensearch-sql_test_index_otel_logs
5+
body:
6+
mappings:
7+
properties:
8+
"@timestamp":
9+
type: date
10+
"severityNumber":
11+
type: long
12+
"severityText":
13+
type: keyword
14+
- do:
15+
bulk:
16+
index: opensearch-sql_test_index_otel_logs
17+
refresh: true
18+
body:
19+
- '{"index":{}}'
20+
- '{"@timestamp":"2024-01-15T10:00:00.000Z","severityNumber":24,"severityText":"FATAL4"}'
21+
- '{"index":{}}'
22+
- '{"@timestamp":"2024-01-15T10:00:01.000Z","severityNumber":24,"severityText":"FATAL4"}'
23+
- '{"index":{}}'
24+
- '{"@timestamp":"2024-01-15T10:00:02.000Z","severityNumber":23,"severityText":"ERROR5"}'
25+
- '{"index":{}}'
26+
- '{"@timestamp":"2024-01-15T10:00:03.000Z","severityNumber":22,"severityText":"ERROR6"}'
27+
- '{"index":{}}'
28+
- '{"@timestamp":"2024-01-15T10:00:04.000Z","severityNumber":21,"severityText":"WARN7"}'
29+
- '{"index":{}}'
30+
- '{"@timestamp":"2024-01-15T10:00:05.000Z","severityNumber":20,"severityText":"INFO8"}'
31+
- '{"index":{}}'
32+
- '{"@timestamp":"2024-01-15T10:00:06.000Z","severityNumber":19,"severityText":"DEBUG9"}'
33+
- '{"index":{}}'
34+
- '{"@timestamp":"2024-01-15T10:00:07.000Z","severityNumber":18,"severityText":"TRACE10"}'
35+
36+
---
37+
"timechart with limit should use max aggregation for OTHER category":
38+
- skip:
39+
features:
40+
- headers
41+
- do:
42+
headers:
43+
Content-Type: 'application/json'
44+
ppl:
45+
body:
46+
query: source=opensearch-sql_test_index_otel_logs | timechart limit=1 span=1d max(severityNumber) by severityText
47+
48+
- match: { total: 2 }
49+
- match: { "schema": [ { "name": "@timestamp", "type": "timestamp" }, { "name": "severityText", "type": "string" }, { "name": "max(severityNumber)", "type": "bigint" }] }
50+
# The FATAL4 category has max(severityNumber) = 24
51+
# The OTHER category should have max(severityNumber) = 23 (not sum of all others which would be 143)
52+
- match: {"datarows": [["2024-01-15 00:00:00", "FATAL4", 24], ["2024-01-15 00:00:00", "OTHER", 23]]}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
setup:
2+
- do:
3+
indices.create:
4+
index: events
5+
body:
6+
mappings:
7+
properties:
8+
"@timestamp":
9+
type: date
10+
"host":
11+
type: text
12+
"packets":
13+
type: long
14+
- do:
15+
bulk:
16+
index: events
17+
refresh: true
18+
body:
19+
- '{"index":{}}'
20+
- '{"@timestamp":"2023-01-01T10:00:00Z","host":"server1","packets":60}'
21+
- '{"index":{}}'
22+
- '{"@timestamp":"2023-01-01T10:05:00Z","host":"server2","packets":30}'
23+
- '{"index":{}}'
24+
- '{"@timestamp":"2023-01-01T10:10:00Z","host":"server1","packets":60}'
25+
- '{"index":{}}'
26+
- '{"@timestamp":"2023-01-01T10:15:00Z","host":"server2","packets":30}'
27+
- '{"index":{}}'
28+
- '{"@timestamp":"2023-01-01T10:20:00Z","host":"server1","packets":60}'
29+
- '{"index":{}}'
30+
- '{"@timestamp":"2023-01-01T10:25:00Z","host":"server2","packets":30}'
31+
- '{"index":{}}'
32+
- '{"@timestamp":"2023-01-01T10:30:00Z","host":"server1","packets":180}'
33+
- '{"index":{}}'
34+
- '{"@timestamp":"2023-01-01T10:35:00Z","host":"server2","packets":90}'
35+
36+
---
37+
"timechart count() by field should not return empty buckets":
38+
- skip:
39+
features:
40+
- headers
41+
- do:
42+
headers:
43+
Content-Type: 'application/json'
44+
ppl:
45+
body:
46+
query: source=events | timechart span=1m count() by host
47+
48+
- match: { total: 8 }
49+
- match: { "schema": [ { "name": "@timestamp", "type": "timestamp" }, { "name": "host", "type": "string" }, { "name": "count()", "type": "bigint" }] }
50+
# Verify that only non-empty buckets are returned (8 rows instead of 16)
51+
# Each time bucket should only have one host with actual data
52+
- match: {"datarows": [["2023-01-01 10:00:00", "server1", 1], ["2023-01-01 10:05:00", "server2", 1], ["2023-01-01 10:10:00", "server1", 1], ["2023-01-01 10:15:00", "server2", 1], ["2023-01-01 10:20:00", "server1", 1], ["2023-01-01 10:25:00", "server2", 1], ["2023-01-01 10:30:00", "server1", 1], ["2023-01-01 10:35:00", "server2", 1]]}
53+
54+
---
55+
"timechart max() by field should not return empty buckets":
56+
- skip:
57+
features:
58+
- headers
59+
- do:
60+
headers:
61+
Content-Type: 'application/json'
62+
ppl:
63+
body:
64+
query: source=events | timechart span=1m max(packets) by host
65+
66+
- match: { total: 8 }
67+
- match: { "schema": [ { "name": "@timestamp", "type": "timestamp" }, { "name": "host", "type": "string" }, { "name": "max(packets)", "type": "bigint" }] }
68+
# Verify that only non-empty buckets are returned
69+
- match: {"datarows": [["2023-01-01 10:00:00", "server1", 60], ["2023-01-01 10:05:00", "server2", 30], ["2023-01-01 10:10:00", "server1", 60], ["2023-01-01 10:15:00", "server2", 30], ["2023-01-01 10:20:00", "server1", 60], ["2023-01-01 10:25:00", "server2", 30], ["2023-01-01 10:30:00", "server1", 180], ["2023-01-01 10:35:00", "server2", 90]]}

0 commit comments

Comments
 (0)