From 7cd52634b74c1fb418f4bf54e8bd603d90911b46 Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Tue, 28 Sep 2021 11:16:57 -1000 Subject: [PATCH] Adds some REST tests for boxplot metric aggregations. (#78354) Adds more REST tests for boxplot metric aggregations. Related to #26220 --- .../rest-api-spec/test/analytics/boxplot.yml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/boxplot.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/boxplot.yml index f65b9923f1948..3247920e29d83 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/boxplot.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/boxplot.yml @@ -35,6 +35,11 @@ setup: - index: _index: "latency" - load_time: 15 + + - index: + _index: "latency" + - { } + --- "Basic Search": @@ -54,3 +59,55 @@ setup: - match: { aggregations.plot.q2: 5.0 } - match: { aggregations.plot.q3: 11.25 } +--- +"Search With Runtime Field": + + - do: + search: + index: "latency" + body: + query: + exists: + field: load_time + runtime_mappings: + load_time_adjusted: + type: long + script: + source: "emit((long)((doc['load_time'].value == 10 ? 1000 : doc['load_time'].value) * params.multiplier))" + params: + multiplier: 10 + size: 0 + aggs: + plot: + boxplot: + field: "load_time_adjusted" + + - match: { aggregations.plot.min: 20.0 } + - match: { aggregations.plot.max: 10000.0 } + - match: { aggregations.plot.q1: 27.5 } + - match: { aggregations.plot.q2: 50.0 } + - match: { aggregations.plot.q3: 2612.5 } + - match: { aggregations.plot.lower: 20.0 } + - match: { aggregations.plot.upper: 150.0 } + +--- +"Search With Missing": + + - do: + search: + index: "latency" + body: + size: 0 + aggs: + plot: + boxplot: + field: "load_time" + missing: 10000 + + - match: { aggregations.plot.min: 2.0 } + - match: { aggregations.plot.max: 10000.0 } + - match: { aggregations.plot.q1: 3 } + - match: { aggregations.plot.q2: 7.5 } + - match: { aggregations.plot.q3: 15.0 } + - match: { aggregations.plot.lower: 2.0 } + - match: { aggregations.plot.upper: 15.0 }