From a19410f6caaf476f53701394b67621a40984628d Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Mon, 22 Apr 2024 14:08:11 +0200 Subject: [PATCH] ESQL: Fix mixed cluster tests (#107680) * Fix a test where pre-8.13 nodes in mixed cluster tests were sent a language version (added in 8.13.3). * Skip a test for a fix introduced in 8.13.2 on older clusters. --- .../xpack/esql/qa/rest/EsqlSpecTestCase.java | 2 +- .../xpack/esql/qa/rest/FieldExtractorTestCase.java | 11 +++++++++-- .../qa/testFixtures/src/main/resources/stats.csv-spec | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java index 14579dfb537da..a0e5213632c09 100644 --- a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java +++ b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java @@ -71,7 +71,6 @@ public abstract class EsqlSpecTestCase extends ESRestTestCase { public static Set availableVersions() { if ("true".equals(System.getProperty("tests.version_parameter_unsupported"))) { - // TODO: skip tests with explicitly set version and/or strip the version if it's 2024.04.01. return Set.of(); } return Build.current().isSnapshot() ? Set.of(EsqlVersion.values()) : Set.of(EsqlVersion.releasedAscending()); @@ -157,6 +156,7 @@ protected final void doTest() throws Throwable { RequestObjectBuilder builder = new RequestObjectBuilder(randomFrom(XContentType.values())); String versionString = null; + // TODO: skip tests with explicitly set version and/or strip the version if it's 2024.04.01. if (availableVersions().isEmpty() == false) { EsqlVersion version = randomFrom(availableVersions()); versionString = randomBoolean() ? version.toString() : version.versionStringWithoutEmoji(); diff --git a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/FieldExtractorTestCase.java b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/FieldExtractorTestCase.java index d5daab2d46a80..c7bb9d293e708 100644 --- a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/FieldExtractorTestCase.java +++ b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/FieldExtractorTestCase.java @@ -26,7 +26,7 @@ import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xcontent.json.JsonXContent; -import org.elasticsearch.xpack.esql.EsqlTestUtils; +import org.elasticsearch.xpack.esql.version.EsqlVersion; import org.hamcrest.Matcher; import org.junit.Before; @@ -1435,7 +1435,14 @@ private String deyaml(String err) { } private static Map runEsql(String query) throws IOException { - return runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query(query).version(EsqlTestUtils.latestEsqlVersionOrSnapshot())); + // Use the latest released version or SNAPSHOT, if available. + String versionString = EsqlSpecTestCase.availableVersions() + .stream() + .max(Comparator.comparingInt(EsqlVersion::id)) + .map(EsqlVersion::toString) + .orElse(null); + + return runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query(query).version(versionString)); } } diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/stats.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/stats.csv-spec index 113124d3a72a8..0d19f81059507 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/stats.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/stats.csv-spec @@ -1552,7 +1552,7 @@ s2point1:d | s_mv:i | languages:i 2.1 | 3 | null ; -evalOverridingKey +evalOverridingKey#[skip:-8.13.1,reason:fixed in 8.13.2] FROM employees | EVAL k = languages | STATS c = COUNT() BY languages, k