Skip to content

Commit 5b525a2

Browse files
authored
REST tests for avg/max/min/sum_bucket aggs (#87009)
Adds REST layer tests for the `avg_bucket`, `max_bucket`, `min_bucket`, and `sum_bucket` pipeline aggregations. This gives us forwards and backwards compatibility tests for these aggs as well as mixed version cluster tests for these aggs. Relates to #26220
1 parent d74b45b commit 5b525a2

File tree

4 files changed

+551
-0
lines changed

4 files changed

+551
-0
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
setup:
2+
- do:
3+
bulk:
4+
index: no_gaps
5+
refresh: true
6+
body:
7+
- { "index": { } }
8+
- { "@timestamp": "2022-01-01T00:00:00", "v": 1 }
9+
- { "index": { } }
10+
- { "@timestamp": "2022-01-01T01:00:00", "v": 2 }
11+
- { "index": { } }
12+
- { "@timestamp": "2022-01-01T02:00:00", "v": 1 }
13+
14+
- do:
15+
bulk:
16+
index: gaps
17+
refresh: true
18+
body:
19+
- { "index": { } }
20+
- { "@timestamp": "2022-01-01T00:00:00", "v": 1 }
21+
- { "index": { } }
22+
- { "@timestamp": "2022-01-01T02:00:00", "v": 2 }
23+
- { "index": { } }
24+
- { "@timestamp": "2022-01-01T03:00:00", "v": 1 }
25+
26+
---
27+
basic:
28+
- skip:
29+
features: close_to
30+
31+
- do:
32+
search:
33+
index: no_gaps
34+
body:
35+
size: 0
36+
aggs:
37+
"@timestamp":
38+
date_histogram:
39+
field: "@timestamp"
40+
fixed_interval: 1h
41+
aggs:
42+
v: {avg: {field: v}}
43+
d:
44+
avg_bucket:
45+
buckets_path: "@timestamp>v"
46+
- match: { hits.total.value: 3 }
47+
- length: { aggregations.@timestamp.buckets: 3 }
48+
- close_to: { aggregations.d.value: { value: 1.333, error: 0.0005 }}
49+
50+
---
51+
format:
52+
- skip:
53+
features: close_to
54+
55+
- do:
56+
search:
57+
index: no_gaps
58+
body:
59+
size: 0
60+
aggs:
61+
"@timestamp":
62+
date_histogram:
63+
field: "@timestamp"
64+
fixed_interval: 1h
65+
aggs:
66+
v: {avg: {field: v}}
67+
d:
68+
avg_bucket:
69+
buckets_path: "@timestamp>v"
70+
format: "0.00"
71+
- match: { hits.total.value: 3 }
72+
- length: { aggregations.@timestamp.buckets: 3 }
73+
- close_to: { aggregations.d.value: { value: 1.333, error: 0.0005 }}
74+
- match: { aggregations.d.value_as_string: "1.33" }
75+
76+
---
77+
gap_policy=skip:
78+
- skip:
79+
features: close_to
80+
81+
- do:
82+
search:
83+
index: gaps
84+
body:
85+
size: 0
86+
aggs:
87+
"@timestamp":
88+
date_histogram:
89+
field: "@timestamp"
90+
fixed_interval: 1h
91+
aggs:
92+
v: {avg: {field: v}}
93+
d:
94+
avg_bucket:
95+
buckets_path: "@timestamp>v"
96+
gap_policy: skip
97+
- match: { hits.total.value: 3 }
98+
- length: { aggregations.@timestamp.buckets: 4 }
99+
- close_to: { aggregations.d.value: { value: 1.333, error: 0.0005 }}
100+
101+
---
102+
gap_policy=insert_zeros:
103+
- skip:
104+
features: close_to
105+
106+
- do:
107+
search:
108+
index: gaps
109+
body:
110+
size: 0
111+
aggs:
112+
"@timestamp":
113+
date_histogram:
114+
field: "@timestamp"
115+
fixed_interval: 1h
116+
aggs:
117+
v: {avg: {field: v}}
118+
d:
119+
avg_bucket:
120+
buckets_path: "@timestamp>v"
121+
gap_policy: insert_zeros
122+
- match: { hits.total.value: 3 }
123+
- length: { aggregations.@timestamp.buckets: 4 }
124+
- match: { aggregations.d.value: 1.0 }
125+
126+
---
127+
gap_policy=keep_value:
128+
- skip:
129+
features: close_to
130+
131+
- do:
132+
search:
133+
index: gaps
134+
body:
135+
size: 0
136+
aggs:
137+
"@timestamp":
138+
date_histogram:
139+
field: "@timestamp"
140+
fixed_interval: 1h
141+
aggs:
142+
v: {avg: {field: v}}
143+
d:
144+
avg_bucket:
145+
buckets_path: "@timestamp>v"
146+
gap_policy: keep_values
147+
- match: { hits.total.value: 3 }
148+
- length: { aggregations.@timestamp.buckets: 4 }
149+
- close_to: { aggregations.d.value: { value: 1.333, error: 0.0005 }}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
setup:
2+
- do:
3+
bulk:
4+
index: no_gaps
5+
refresh: true
6+
body:
7+
- { "index": { } }
8+
- { "@timestamp": "2022-01-01T00:00:00", "v": 1 }
9+
- { "index": { } }
10+
- { "@timestamp": "2022-01-01T01:00:00", "v": 2 }
11+
- { "index": { } }
12+
- { "@timestamp": "2022-01-01T02:00:00", "v": 1 }
13+
14+
- do:
15+
bulk:
16+
index: gaps
17+
refresh: true
18+
body:
19+
- { "index": { } }
20+
- { "@timestamp": "2022-01-01T00:00:00", "v": -1 }
21+
- { "index": { } }
22+
- { "@timestamp": "2022-01-01T02:00:00", "v": -2 }
23+
- { "index": { } }
24+
- { "@timestamp": "2022-01-01T03:00:00", "v": -1 }
25+
26+
---
27+
basic:
28+
- do:
29+
search:
30+
index: no_gaps
31+
body:
32+
size: 0
33+
aggs:
34+
"@timestamp":
35+
date_histogram:
36+
field: "@timestamp"
37+
fixed_interval: 1h
38+
aggs:
39+
v: {avg: {field: v}}
40+
d:
41+
max_bucket:
42+
buckets_path: "@timestamp>v"
43+
- match: { hits.total.value: 3 }
44+
- length: { aggregations.@timestamp.buckets: 3 }
45+
- match: { aggregations.d.value: 2.0 }
46+
47+
---
48+
format:
49+
- do:
50+
search:
51+
index: no_gaps
52+
body:
53+
size: 0
54+
aggs:
55+
"@timestamp":
56+
date_histogram:
57+
field: "@timestamp"
58+
fixed_interval: 1h
59+
aggs:
60+
v: {avg: {field: v}}
61+
d:
62+
max_bucket:
63+
buckets_path: "@timestamp>v"
64+
format: "0.00"
65+
- match: { hits.total.value: 3 }
66+
- length: { aggregations.@timestamp.buckets: 3 }
67+
- match: { aggregations.d.value: 2.0 }
68+
- match: { aggregations.d.value_as_string: "2.00" }
69+
70+
---
71+
gap_policy=skip:
72+
- do:
73+
search:
74+
index: gaps
75+
body:
76+
size: 0
77+
aggs:
78+
"@timestamp":
79+
date_histogram:
80+
field: "@timestamp"
81+
fixed_interval: 1h
82+
aggs:
83+
v: {avg: {field: v}}
84+
d:
85+
max_bucket:
86+
buckets_path: "@timestamp>v"
87+
gap_policy: skip
88+
- match: { hits.total.value: 3 }
89+
- length: { aggregations.@timestamp.buckets: 4 }
90+
- match: { aggregations.d.value: -1.0 }
91+
92+
---
93+
gap_policy=insert_zeros:
94+
- do:
95+
search:
96+
index: gaps
97+
body:
98+
size: 0
99+
aggs:
100+
"@timestamp":
101+
date_histogram:
102+
field: "@timestamp"
103+
fixed_interval: 1h
104+
aggs:
105+
v: {avg: {field: v}}
106+
d:
107+
max_bucket:
108+
buckets_path: "@timestamp>v"
109+
gap_policy: insert_zeros
110+
- match: { hits.total.value: 3 }
111+
- length: { aggregations.@timestamp.buckets: 4 }
112+
- match: { aggregations.d.value: 0.0 }
113+
114+
---
115+
gap_policy=keep_value:
116+
- do:
117+
search:
118+
index: gaps
119+
body:
120+
size: 0
121+
aggs:
122+
"@timestamp":
123+
date_histogram:
124+
field: "@timestamp"
125+
fixed_interval: 1h
126+
aggs:
127+
v: {avg: {field: v}}
128+
d:
129+
max_bucket:
130+
buckets_path: "@timestamp>v"
131+
gap_policy: keep_values
132+
- match: { hits.total.value: 3 }
133+
- length: { aggregations.@timestamp.buckets: 4 }
134+
- match: { aggregations.d.value: -1.0 }

0 commit comments

Comments
 (0)