From 0b63e3235b2396cae195f9087a6d68b6175671b8 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Wed, 7 Aug 2024 11:17:41 -0700 Subject: [PATCH] Rest test for weekly agg over DST Signed-off-by: Finn Carroll --- .../search.aggregation/360_date_histogram.yml | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/360_date_histogram.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/360_date_histogram.yml index 0ea9d3de00926..7fb312d852c4f 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/360_date_histogram.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/360_date_histogram.yml @@ -61,3 +61,59 @@ setup: - match: { aggregations.histo.buckets.8.doc_count: 1 } - match: { aggregations.histo.buckets.12.key_as_string: "2016-06-01T00:00:00.000Z" } - match: { aggregations.histo.buckets.12.doc_count: 1 } + +--- +"date_histogram bucket offset over daylight savings": + - skip: + version: " - 2.16.99" + reason: 2.17 bug fix + + - do: + indices.create: + index: dst_test + body: + mappings: + properties: + weekday: + type: text + date: + type: date + + - do: + bulk: + index: dst_test + refresh: true + body: + - '{"index": {}}' + - '{"date": "2024-03-08", "weekday": "friday"}' + - '{"index": {}}' + - '{"date": "2024-03-09", "weekday": "saturday"}' + - '{"index": {}}' + - '{"date": "2024-03-10", "weekday": "sunday - -1d offset expected bucket start"}' + - '{"index": {}}' + - '{"date": "2016-03-11", "weekday": "monday - NO offset bucket start"}' + - '{"index": {}}' + - '{"date": "2016-03-12", "weekday": "tuesday"}' + + - do: + search: + index: dst_test + body: + size: 0 + aggs: + weekly_histogram: + date_histogram: + field: date + calendar_interval: week + offset: "-1d" + format: "yyyy-MM-dd" + time_zone: "America/New_York" + + - match: { hits.total.value: 5 } + - length: { aggregations.weekly_histogram.buckets: 2 } + + - match: { aggregations.weekly_histogram.buckets.0.key_as_string: "2024-03-03" } + - match: { aggregations.weekly_histogram.buckets.0.doc_count: 2 } + + - match: { aggregations.weekly_histogram.buckets.1.key_as_string: "2024-03-10" } + - match: { aggregations.weekly_histogram.buckets.1.doc_count: 3 }