elasticsearch: always use fixed_interval (#50297)

This commit is contained in:
Gábor Farkas
2022-06-13 10:28:29 +02:00
committed by GitHub
parent 0a815a7777
commit a2eb4e85e5
7 changed files with 15 additions and 60 deletions

View File

@@ -399,7 +399,7 @@ func TestExecuteTimeSeriesQuery(t *testing.T) {
require.Equal(t, firstLevel.Aggregation.Type, "date_histogram")
hAgg := firstLevel.Aggregation.Aggregation.(*es.DateHistogramAgg)
require.Equal(t, hAgg.Field, "@timestamp")
require.Equal(t, hAgg.Interval, "$__interval")
require.Equal(t, hAgg.FixedInterval, "$__interval")
require.Equal(t, hAgg.MinDocCount, 2)
t.Run("Should not include time_zone when timeZone is utc", func(t *testing.T) {
@@ -1050,35 +1050,8 @@ func TestSettingsCasting(t *testing.T) {
})
t.Run("interval parameter", func(t *testing.T) {
t.Run("Uses interval with ES < 8.0.0", func(t *testing.T) {
c := newFakeClient("7.7.0")
_, err := executeTsdbQuery(c, `{
"timeField": "@timestamp",
"bucketAggs": [
{
"type": "date_histogram",
"field": "@timestamp",
"id": "2",
"settings": {
"interval": "1d"
}
}
],
"metrics": [
{ "id": "1", "type": "average", "field": "@value" }
]
}`, from, to, 15*time.Second)
assert.Nil(t, err)
sr := c.multisearchRequests[0].Requests[0]
dateHistogramAgg := sr.Aggs[0].Aggregation.Aggregation.(*es.DateHistogramAgg)
assert.Zero(t, dateHistogramAgg.FixedInterval)
assert.NotZero(t, dateHistogramAgg.Interval)
})
t.Run("Uses fixed_interval with ES >= 8.0.0", func(t *testing.T) {
c := newFakeClient("8.0.0")
t.Run("Uses fixed_interval", func(t *testing.T) {
c := newFakeClient("7.10.0")
_, err := executeTsdbQuery(c, `{
"timeField": "@timestamp",
"bucketAggs": [
@@ -1101,7 +1074,6 @@ func TestSettingsCasting(t *testing.T) {
dateHistogramAgg := sr.Aggs[0].Aggregation.Aggregation.(*es.DateHistogramAgg)
assert.NotZero(t, dateHistogramAgg.FixedInterval)
assert.Zero(t, dateHistogramAgg.Interval)
})
})
})