From b1c986a10665c30a60512c36283174f8f5488ee9 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Fri, 30 Sep 2022 10:27:41 -0400 Subject: [PATCH 1/3] Enhance REST tests for moving_percentiles This adds a few more tests to the REST layer tests for `moving_percentiles` in an effort to buy us forwards and backwards compatibility tests for all aggregations. --- ..._percentile.yml => moving_percentiles.yml} | 109 +++++++++++++++++- 1 file changed, 105 insertions(+), 4 deletions(-) rename x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/{moving_percentile.yml => moving_percentiles.yml} (58%) diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/moving_percentile.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/moving_percentiles.yml similarity index 58% rename from x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/moving_percentile.yml rename to x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/moving_percentiles.yml index 318e32cdef317..7477e556d1fef 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/moving_percentile.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/moving_percentiles.yml @@ -11,6 +11,8 @@ setup: type: date histogram: type: histogram + i: + type: long - do: @@ -62,7 +64,7 @@ setup: counts: [1, 4, 5, 4, 5, 1] --- -"Basic Search TDigest": +shift: - do: search: index: "foo" @@ -100,7 +102,44 @@ setup: - match: { aggregations.histo.buckets.2.moving_percentiles.values.0.value: 4.0 } --- -"Basic Search HDR": +tdest: + - do: + search: + index: "foo" + body: + size: 0 + aggs: + histo: + date_histogram: + field: "timestamp" + calendar_interval: "day" + aggs: + percentiles: + percentiles: + field: "histogram" + percents: [90] + keyed: false + moving_percentiles: + moving_percentiles: + buckets_path: "percentiles" + window: 2 + + - length: { aggregations.histo.buckets: 3 } + - match: { aggregations.histo.buckets.0.key_as_string: "2017-01-01T00:00:00.000Z" } + - match: { aggregations.histo.buckets.0.doc_count: 3 } + - match: { aggregations.histo.buckets.0.percentiles.values.0.value: 4.0 } + - is_false: aggregations.histo.buckets.0.moving_percentiles + - match: { aggregations.histo.buckets.1.key_as_string: "2017-01-02T00:00:00.000Z" } + - match: { aggregations.histo.buckets.1.doc_count: 2 } + - match: { aggregations.histo.buckets.1.percentiles.values.0.value: 5.0 } + - match: { aggregations.histo.buckets.1.moving_percentiles.values.0.value: 4.0 } + - match: { aggregations.histo.buckets.2.key_as_string: "2017-01-03T00:00:00.000Z" } + - match: { aggregations.histo.buckets.2.doc_count: 1 } + - match: { aggregations.histo.buckets.2.percentiles.values.0.value: 7.0 } + - match: { aggregations.histo.buckets.2.moving_percentiles.values.0.value: 4.0 } + +--- +hdr: - do: search: index: "foo" @@ -123,13 +162,12 @@ setup: moving_percentiles: buckets_path: "percentiles" window: 3 - shift: 1 - length: { aggregations.histo.buckets: 3 } - match: { aggregations.histo.buckets.0.key_as_string: "2017-01-01T00:00:00.000Z" } - match: { aggregations.histo.buckets.0.doc_count: 3 } - match: { aggregations.histo.buckets.0.percentiles.values.0.value: 4.24609375 } - - match: { aggregations.histo.buckets.0.moving_percentiles.values.0.value: 4.24609375 } + - is_false: aggregations.histo.buckets.0.moving_percentiles - match: { aggregations.histo.buckets.1.key_as_string: "2017-01-02T00:00:00.000Z" } - match: { aggregations.histo.buckets.1.doc_count: 2 } - match: { aggregations.histo.buckets.1.percentiles.values.0.value: 4.24609375 } @@ -139,4 +177,67 @@ setup: - match: { aggregations.histo.buckets.2.percentiles.values.0.value: 4.24609375 } - match: { aggregations.histo.buckets.2.moving_percentiles.values.0.value: 4.24609375 } +--- +bad path: + - do: + catch: /No aggregation found for path \[bad_path\]/ + search: + body: + size: 0 + aggs: + the_histo: + date_histogram: + field: date + calendar_interval: 1d + aggs: + percentiles: + percentiles: + field: histogram + percents: [ 90 ] + keyed: false + moving_percentiles: + moving_percentiles: + buckets_path: bad_path + window: 3 +--- +Bad window: + - do: + catch: /\[window\] must be a positive, non-zero integer\./ + search: + body: + size: 0 + aggs: + the_histo: + date_histogram: + field: date + calendar_interval: 1d + aggs: + percentiles: + percentiles: + field: histogram + percents: [ 90 ] + keyed: false + moving_percentiles: + moving_percentiles: + buckets_path: percentiles + window: -1 + +--- +Not under date histo: + - do: + catch: /moving_percentiles aggregation \[moving_percentiles\] must have a histogram, date_histogram or auto_date_histogram as parent but doesn't have a parent/ + search: + body: + size: 0 + aggs: + percentiles: + percentiles: + field: histogram + percents: [90] + keyed: false + moving_percentiles: + moving_percentiles: + buckets_path: percentiles + window: 2 + shift: 1 From a41a76f4f8c30148f8f0663fffa8ef8455bbd9af Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Fri, 30 Sep 2022 10:29:02 -0400 Subject: [PATCH 2/3] unneeded --- .../rest-api-spec/test/analytics/moving_percentiles.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/moving_percentiles.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/moving_percentiles.yml index 7477e556d1fef..bf2c0a287cf4e 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/moving_percentiles.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/moving_percentiles.yml @@ -11,9 +11,6 @@ setup: type: date histogram: type: histogram - i: - type: long - - do: headers: From 717e87a105bcbd7c16cde47c6fa036ee58bd79ee Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 20 Oct 2022 07:33:48 -0400 Subject: [PATCH 3/3] Fix --- .../test/analytics/moving_percentiles.yml | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/moving_percentiles.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/moving_percentiles.yml index bf2c0a287cf4e..7ed941571642a 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/moving_percentiles.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/moving_percentiles.yml @@ -99,7 +99,7 @@ shift: - match: { aggregations.histo.buckets.2.moving_percentiles.values.0.value: 4.0 } --- -tdest: +default choses tdigest: - do: search: index: "foo" @@ -135,6 +135,44 @@ tdest: - match: { aggregations.histo.buckets.2.percentiles.values.0.value: 7.0 } - match: { aggregations.histo.buckets.2.moving_percentiles.values.0.value: 4.0 } +--- +tdest explicitly: + - do: + search: + index: "foo" + body: + size: 0 + aggs: + histo: + date_histogram: + field: "timestamp" + calendar_interval: "day" + aggs: + percentiles: + percentiles: + field: "histogram" + percents: [90] + keyed: false + tdigest: {} + moving_percentiles: + moving_percentiles: + buckets_path: "percentiles" + window: 2 + + - length: { aggregations.histo.buckets: 3 } + - match: { aggregations.histo.buckets.0.key_as_string: "2017-01-01T00:00:00.000Z" } + - match: { aggregations.histo.buckets.0.doc_count: 3 } + - match: { aggregations.histo.buckets.0.percentiles.values.0.value: 4.0 } + - is_false: aggregations.histo.buckets.0.moving_percentiles + - match: { aggregations.histo.buckets.1.key_as_string: "2017-01-02T00:00:00.000Z" } + - match: { aggregations.histo.buckets.1.doc_count: 2 } + - match: { aggregations.histo.buckets.1.percentiles.values.0.value: 5.0 } + - match: { aggregations.histo.buckets.1.moving_percentiles.values.0.value: 4.0 } + - match: { aggregations.histo.buckets.2.key_as_string: "2017-01-03T00:00:00.000Z" } + - match: { aggregations.histo.buckets.2.doc_count: 1 } + - match: { aggregations.histo.buckets.2.percentiles.values.0.value: 7.0 } + - match: { aggregations.histo.buckets.2.moving_percentiles.values.0.value: 4.0 } + --- hdr: - do: