Skip to content

Commit

Permalink
REST tests for variable width historam (elastic#84836)
Browse files Browse the repository at this point in the history
This expands on the super basic REST tests for variable width histogram
with some ever so slightly less basic tests. They are still pretty
basic, but they do a good job of making sure that we don't break
backwards compatibility with the API.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
nik9000 and elasticmachine committed Mar 18, 2022
1 parent 298d625 commit 47df4af
Showing 1 changed file with 82 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,47 @@ setup:
- '{"number": 4}'
- '{"index": {}}'
- '{"number": 5}'
- '{"index": {}}'
- '{"number": 6}'
- '{"index": {}}'
- '{"number": 7}'
- '{"index": {}}'
- '{"number": 8}'
- '{"index": {}}'
- '{"number": 9}'
- '{"index": {}}'
- '{"number": 10}'
- '{"index": {}}'
- '{"number": 11}'

---
defaults:
- skip:
version: " - 7.8.99"
reason: added in 7.9.0
- do:
search:
body:
size: 0
aggs:
histo:
variable_width_histogram:
field: number
- match: { hits.total.value: 11 }
- length: { aggregations.histo.buckets: 10 }
- match: { aggregations.histo.buckets.0: {"min": -3.0, "key": -2.5, "max": -2.0, "doc_count": 2 } }
- match: { aggregations.histo.buckets.1: {"min": 1.0, "key": 1.0, "max": 1.0, "doc_count": 1 } }
- match: { aggregations.histo.buckets.2: {"min": 4.0, "key": 4.0, "max": 4.0, "doc_count": 1 } }
- match: { aggregations.histo.buckets.3: {"min": 5.0, "key": 5.0, "max": 5.0, "doc_count": 1 } }
- match: { aggregations.histo.buckets.4: {"min": 6.0, "key": 6.0, "max": 6.0, "doc_count": 1 } }
- match: { aggregations.histo.buckets.5: {"min": 7.0, "key": 7.0, "max": 7.0, "doc_count": 1 } }
- match: { aggregations.histo.buckets.6: {"min": 8.0, "key": 8.0, "max": 8.0, "doc_count": 1 } }
- match: { aggregations.histo.buckets.7: {"min": 9.0, "key": 9.0, "max": 9.0, "doc_count": 1 } }
- match: { aggregations.histo.buckets.8: {"min": 10.0, "key": 10.0, "max": 10.0, "doc_count": 1 } }
- match: { aggregations.histo.buckets.9: {"min": 11.0, "key": 11.0, "max": 11.0, "doc_count": 1 } }

---
"basic":
num_buckets:
- skip:
version: " - 7.8.99"
reason: added in 7.9.0
Expand All @@ -39,12 +77,48 @@ setup:
variable_width_histogram:
field: number
buckets: 3
- match: { hits.total.value: 5 }
- match: { hits.total.value: 11 }
- length: { aggregations.histo.buckets: 3 }
- match: { aggregations.histo.buckets.0.key: -2.5 }
- match: { aggregations.histo.buckets.0.doc_count: 2 }
- match: { aggregations.histo.buckets.1.key: 1.0 }
- match: { aggregations.histo.buckets.1.doc_count: 1 }
- match: { aggregations.histo.buckets.2.key: 4.5 }
- match: { aggregations.histo.buckets.2.doc_count: 2 }
- match: { aggregations.histo.buckets.0: {"min": -3.0, "key": -1.3333333333333333, "max": 1.0, "doc_count": 3 } }
- match: { aggregations.histo.buckets.1: {"min": 4.0, "key": 5.5, "max": 7.0, "doc_count": 4 } }
- match: { aggregations.histo.buckets.2: {"min": 8.0, "key": 9.5, "max": 11.0, "doc_count": 4 } }

---
shard_size:
- skip:
version: " - 7.8.99"
reason: added in 7.9.0
- do:
search:
body:
size: 0
aggs:
histo:
variable_width_histogram:
field: number
buckets: 2
shard_size: 10000 # This is an accuracy tuning parameter that the tests can't do much with. This just makes sure you can set it.
- match: { hits.total.value: 11 }
- length: { aggregations.histo.buckets: 2 }
- match: { aggregations.histo.buckets.0: {"min": -3.0, "key": -1.3333333333333333, "max": 1.0, "doc_count": 3 } }
- match: { aggregations.histo.buckets.1: {"min": 4.0, "key": 7.5, "max": 11.0, "doc_count": 8 } }

---
initial_buffer:
- skip:
version: " - 7.8.99"
reason: added in 7.9.0
- do:
search:
body:
size: 0
aggs:
histo:
variable_width_histogram:
field: number
buckets: 2
initial_buffer: 10000 # This is an accuracy tuning parameter that the tests can't do much with. This just makes sure you can set it.
- match: { hits.total.value: 11 }
- length: { aggregations.histo.buckets: 2 }
- match: { aggregations.histo.buckets.0: {"min": -3.0, "key": -1.3333333333333333, "max": 1.0, "doc_count": 3 } }
- match: { aggregations.histo.buckets.1: {"min": 4.0, "key": 7.5, "max": 11.0, "doc_count": 8 } }

0 comments on commit 47df4af

Please sign in to comment.