Skip to content

Commit 6dba334

Browse files
authored
[CI] Fix 70_time_series/default sort yaml test failures (#83217)
Fixes test failures like: https://gradle-enterprise.elastic.co/s/gkjt33zqmnjuu The test executes a match_all query that returns all results in the index. Since _score for all search results is 1, the test erroneously assumed that results are returned in the order documents are stored on disk. However, if a shard has multiple segments, the results order can be unpredictable. This PR fixes the test by explicitly setting the sort parameter for the query.
1 parent 2b36b52 commit 6dba334

File tree

1 file changed

+9
-4
lines changed
  • x-pack/plugin/mapper-unsigned-long/src/yamlRestTest/resources/rest-api-spec/test

1 file changed

+9
-4
lines changed

x-pack/plugin/mapper-unsigned-long/src/yamlRestTest/resources/rest-api-spec/test/70_time_series.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ fetch the _tsid:
6161
query:
6262
query_string:
6363
query: '+@timestamp:"2021-04-28T18:35:24.467Z" +metricset:aa'
64+
sort: [ _tsid ]
6465

6566
- match: {hits.total.value: 2}
6667
- match: {hits.hits.0.fields._tsid: [{metricset: aa, ul: 9223372036854775808}]}
@@ -71,7 +72,9 @@ fetch the _tsid:
7172
- match: {hits.hits.1.fields.ul: [9223372036854775807]}
7273

7374
---
74-
# TODO: Sort order is wrong here. Probably this is caused by the encoding of unsigned_long
75+
# Sort order is of unsigned_long fields is not the one we would expect.
76+
# This is caused by the encoding of unsigned_long as a signed long before
77+
# being serialized in _tsid
7578
aggregate the _tsid:
7679
- skip:
7780
version: " - 8.0.99"
@@ -100,9 +103,10 @@ aggregate the _tsid:
100103
- match: {aggregations.tsids.buckets.3.doc_count: 3}
101104

102105
---
103-
# The time-series index is sorted by [_tsid, @timestamp] in ascending order by default
104-
# TODO: Sort order is wrong here. Probably this is caused by the encoding of unsigned_long
105-
default sort:
106+
# Sort order is of unsigned_long fields is not the one we would expect.
107+
# This is caused by the encoding of unsigned_long as a signed long before
108+
# being serialized in _tsid
109+
sort by tsid:
106110
- skip:
107111
version: " - 8.0.99"
108112
reason: _tsid support introduced in 8.1.0
@@ -112,6 +116,7 @@ default sort:
112116
index: test
113117
body:
114118
fields: [ _tsid ]
119+
sort: [ _tsid ]
115120

116121
- match: {hits.total.value: 8 }
117122
- match: {hits.hits.0.fields._tsid: [{metricset: aa, ul: 9223372036854775808}]}

0 commit comments

Comments
 (0)