Skip to content

Commit

Permalink
add rest-regression aggs test (#3820)
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz authored Sep 13, 2023
1 parent 38910c7 commit e745f1c
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 0 deletions.
1 change: 1 addition & 0 deletions quickwit/rest-api-tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ def filter_test(prefixes, test_name):
return False

def filter_tests(prefixes, test_names):
print("Filtering tests prefixes: %s" % prefixes)
if prefixes is None or len(prefixes) == 0:
return test_names
return [
Expand Down
151 changes: 151 additions & 0 deletions quickwit/rest-api-tests/scenarii/aggregations/0001-aggregations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Test date histogram aggregation
method: [GET]
engines:
- quickwit
endpoint: _elastic/aggregations/_search
json:
query:
match_all: {}
aggs:
date_histo:
date_histogram:
field: "date"
fixed_interval: "30d"
offset: "-4d"
expected:
aggregations:
date_histo:
buckets:
- { "doc_count": 4, "key": 1420070400000.0, "key_as_string": "2015-01-01T00:00:00Z" }
- { "doc_count": 2, "key": 1422662400000.0, "key_as_string": "2015-01-31T00:00:00Z" }
---
# Test date histogram aggregation and sub-aggregation
method: [GET]
engines:
- quickwit
endpoint: _elastic/aggregations/_search
json:
query:
match_all: {}
aggs:
date_histo:
date_histogram:
field: "date"
fixed_interval: "30d"
offset: "-4d"
aggs:
response:
stats:
field: response
expected:
aggregations:
date_histo:
buckets:
- { "doc_count": 4, "key": 1420070400000.0, "key_as_string": "2015-01-01T00:00:00Z", "response": { "avg": 80.0, "count": 3, "max": 120.0, "min": 20.0, "sum": 240.0 } }
- { "doc_count": 2, "key": 1422662400000.0, "key_as_string": "2015-01-31T00:00:00Z", "response": { "avg": 80.0, "count": 2, "max": 130.0, "min": 30.0, "sum": 160.0 } }
---
# Test date histogram aggregation + exists and sub-aggregation
method: [GET]
engines:
- quickwit
endpoint: _elastic/aggregations/_search
json:
query:
bool:
must:
- exists:
field: response
aggs:
date_histo:
date_histogram:
field: "date"
fixed_interval: "30d"
offset: "-4d"
aggs:
response:
stats:
field: response
expected:
aggregations:
date_histo:
buckets:
- { "doc_count": 3, "key": 1420070400000.0, "key_as_string": "2015-01-01T00:00:00Z", "response": { "avg": 80.0, "count": 3, "max": 120.0, "min": 20.0, "sum": 240.0 } }
- { "doc_count": 2, "key": 1422662400000.0, "key_as_string": "2015-01-31T00:00:00Z", "response": { "avg": 80.0, "count": 2, "max": 130.0, "min": 30.0, "sum": 160.0 } }
---
# Test term aggs
method: [GET]
engines:
- quickwit
endpoint: _elastic/aggregations/_search
json:
query:
match_all: {}
aggs:
hosts:
terms:
field: "host"
tags:
terms:
field: "tags"
expected:
aggregations:
hosts:
buckets:
- doc_count: 3
key: 192.168.0.10
- doc_count: 2
key: 192.168.0.1
- doc_count: 1
key: 192.168.0.15
- doc_count: 1
key: 192.168.0.11
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
tags:
buckets:
- doc_count: 4
key: nice
- doc_count: 2
key: cool
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
---
# Test date histogram + percentiles sub-aggregation
method: [GET]
engines:
- quickwit
endpoint: _elastic/aggregations/_search
json:
query:
match_all: {}
aggs:
metrics:
date_histogram:
field: date
fixed_interval: 30d
offset: "-4d"
aggs:
response:
percentiles:
field: response
percents:
- 85
keyed: false
expected:
aggregations:
metrics:
buckets:
- doc_count: 4
key: 1420070400000.0
key_as_string: '2015-01-01T00:00:00Z'
response:
values:
- key: 85.0
value: 100.49456770856702
- doc_count: 2
key: 1422662400000.0
key_as_string: '2015-01-31T00:00:00Z'
response:
values:
- key: 85.0
value: 30.26717133872237
5 changes: 5 additions & 0 deletions quickwit/rest-api-tests/scenarii/aggregations/_ctx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
method: GET
engines: ["quickwit"]
api_root: "http://localhost:7280/api/v1/"
headers:
Content-Type: application/json
47 changes: 47 additions & 0 deletions quickwit/rest-api-tests/scenarii/aggregations/_setup.quickwit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Delete possibly remaining index
method: DELETE
endpoint: indexes/aggregations
status_code: null
---
# Create index
method: POST
endpoint: indexes/
json:
version: "0.6"
index_id: aggregations
doc_mapping:
mode: dynamic
dynamic_mapping:
tokenizer: default
fast: true
field_mappings:
- name: date
type: datetime
input_formats:
- rfc3339
precision: seconds
fast: true
---
# Ingest documents
method: POST
endpoint: aggregations/ingest
num_retries: 10
params:
commit: force
ndjson:
- {"name": "Fred", "response": 100, "id": 1, "date": "2015-01-01T12:10:30Z", "host": "192.168.0.1", "tags": ["nice"]}
- {"name": "Manfred", "response": 120, "id": 13, "date": "2015-01-11T12:10:30Z", "host": "192.168.0.11", "tags": ["nice"]}
- {"name": "Horst", "id": 2, "date": "2015-01-01T11:11:30Z", "host": "192.168.0.10", "tags": ["nice", "cool"]}
- {"name": "Fritz", "response": 30, "id": 5, "host": "192.168.0.1", "tags": ["nice", "cool"]}
---
# Ingest documents split #2
method: POST
endpoint: aggregations/ingest
params:
commit: force
ndjson:
- {"name": "Werner", "response": 20, "id": 0, "date": "2015-01-02T00:00:00Z", "host": "192.168.0.10"}
- {"name": "Holger", "response": 30, "id": 4, "date": "2015-02-06T00:00:00Z", "host": "192.168.0.10"}
- {"name": "Bernhard", "response": 130, "id": 14, "date": "2015-02-16T00:00:00Z", "host": "192.168.0.15"}
- {"name": "Fritz", "response": 30, "id": 5}

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# # Delete index
method: DELETE
endpoint: indexes/aggregations

0 comments on commit e745f1c

Please sign in to comment.