Skip to content

Commit

Permalink
[Tests] Fix rare edge case in SimpleQueryStringBuilderTests (#35201)
Browse files Browse the repository at this point in the history
If the random query string is "now" by accident _and_ we are also not setting
some field names to use explicitely, then we can hit the "mapped_date" field
from default test setup. This correctly leads to the query being was marked as
not cacheable, but we assume and check so later. This change fixes this rare
edge case by making sure we don't hit the "date" field in this rare cases.

Closes #35183
  • Loading branch information
Christoph Büscher committed Nov 5, 2018
1 parent 1ae813c commit c33aa34
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ protected SimpleQueryStringBuilder doCreateTestQueryBuilder() {
fields.put(STRING_FIELD_NAME_2, 2.0f / randomIntBetween(1, 20));
}
}
// special handling if query is "now" and no field specified. This hits the "mapped_date" field which leads to the query not being
// cacheable and trigger later test failures (see https://github.com/elastic/elasticsearch/issues/35183)
if (fieldCount == 0 && result.value().equalsIgnoreCase("now")) {
fields.put(STRING_FIELD_NAME_2, 2.0f / randomIntBetween(1, 20));
}

result.fields(fields);
if (randomBoolean()) {
result.autoGenerateSynonymsPhraseQuery(randomBoolean());
Expand Down

0 comments on commit c33aa34

Please sign in to comment.