From 3835988a60338cb1ba93ea1493b109fc9ab4cc41 Mon Sep 17 00:00:00 2001 From: Bogdan Pintea Date: Wed, 11 Jun 2025 18:12:25 +0200 Subject: [PATCH 1/2] Run tests with `allow_partial_results` set to `false` This switches spec-based integration and YAML tests to run with `"allow_partial_results": false` to conteract the default, set to `true`. --- .../esql/qa/single_node/EsqlClientYamlIT.java | 15 ++++++++++++++- .../xpack/esql/qa/rest/EsqlSpecTestCase.java | 6 ++++-- .../test/esql/63_enrich_int_range.yml | 1 - 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlIT.java b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlIT.java index 7556b0916e1f6..3f8199ce46c54 100644 --- a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlIT.java +++ b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlIT.java @@ -10,6 +10,8 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; +import org.elasticsearch.test.rest.yaml.section.DoSection; +import org.elasticsearch.test.rest.yaml.section.ExecutableSection; /** * Run the ESQL yaml tests against the synchronous API. @@ -22,6 +24,17 @@ public EsqlClientYamlIT(final ClientYamlTestCandidate testCandidate) { @ParametersFactory public static Iterable parameters() throws Exception { - return createParameters(); + return updateEsqlQueryDoSections(createParameters(), EsqlClientYamlIT::modifyEsqlQueryExecutableSection); } + + private static ExecutableSection modifyEsqlQueryExecutableSection(DoSection doSection) { + var apiCallSection = doSection.getApiCallSection(); + if (apiCallSection.getApi().equals("esql.query")) { + if (apiCallSection.getParams().containsKey("allow_partial_results") == false) { + apiCallSection.addParam("allow_partial_results", "false"); // we want any error to fail the test + } + } + return doSection; + } + } 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 e4c8b67d4eb72..8cbfbc3a446dc 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 @@ -266,12 +266,14 @@ protected void doTest() throws Throwable { protected final void doTest(String query) throws Throwable { RequestObjectBuilder builder = new RequestObjectBuilder(randomFrom(XContentType.values())); + builder.query(query); + builder.allowPartialResults(false); // we want any error to fail the test if (query.toUpperCase(Locale.ROOT).contains("LOOKUP_\uD83D\uDC14")) { builder.tables(tables()); } Map prevTooks = supportsTook() ? tooks() : null; - Map answer = runEsql(builder.query(query), testCase.assertWarnings(deduplicateExactWarnings())); + Map answer = runEsql(builder, testCase.assertWarnings(deduplicateExactWarnings())); var expectedColumnsWithValues = loadCsvSpecValues(testCase.expectedResults); @@ -296,7 +298,7 @@ protected final void doTest(String query) throws Throwable { } } - private Map tooks() throws IOException { + private static Map tooks() throws IOException { Request request = new Request("GET", "/_xpack/usage"); HttpEntity entity = client().performRequest(request).getEntity(); Map usage = XContentHelper.convertToMap(XContentType.JSON.xContent(), entity.getContent(), false); diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/63_enrich_int_range.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/63_enrich_int_range.yml index 07a8d2ee5aa9c..9d25df1fc567a 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/63_enrich_int_range.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/63_enrich_int_range.yml @@ -203,6 +203,5 @@ teardown: - do: catch: /ENRICH range and input types are incompatible. range\[INTEGER\], input\[DOUBLE\]/ esql.query: - allow_partial_results: false body: query: 'FROM employees | ENRICH ages-policy ON salary | STATS count=COUNT(*) BY description | SORT count DESC, description ASC' From 659b1da1853bf882aa1d4d827d835382a2c81171 Mon Sep 17 00:00:00 2001 From: Bogdan Pintea Date: Wed, 11 Jun 2025 21:40:54 +0200 Subject: [PATCH 2/2] Review feedback --- .../qa/single_node/AbstractEsqlClientYamlIT.java | 14 ++++++++++++++ .../qa/single_node/EsqlClientYamlAsyncIT.java | 2 +- .../EsqlClientYamlAsyncSubmitAndFetchIT.java | 2 +- .../esql/qa/single_node/EsqlClientYamlIT.java | 15 +-------------- .../test/esql/63_enrich_int_range.yml | 1 + 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/AbstractEsqlClientYamlIT.java b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/AbstractEsqlClientYamlIT.java index b2a3b12c2a027..3a140c7637f80 100644 --- a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/AbstractEsqlClientYamlIT.java +++ b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/AbstractEsqlClientYamlIT.java @@ -51,6 +51,20 @@ private void assertRequestBreakerEmpty() throws Exception { EsqlSpecTestCase.assertRequestBreakerEmpty(); } + public static Iterable partialResultsDisablingParameters() throws Exception { + return updateEsqlQueryDoSections(createParameters(), AbstractEsqlClientYamlIT::modifyEsqlQueryExecutableSection); + } + + private static ExecutableSection modifyEsqlQueryExecutableSection(DoSection doSection) { + var apiCallSection = doSection.getApiCallSection(); + if (apiCallSection.getApi().equals("esql.query")) { + if (apiCallSection.getParams().containsKey("allow_partial_results") == false) { + apiCallSection.addParam("allow_partial_results", "false"); // we want any error to fail the test + } + } + return doSection; + } + public static Iterable updateEsqlQueryDoSections(Iterable parameters, Function modify) throws Exception { List result = new ArrayList<>(); diff --git a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncIT.java b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncIT.java index f5bd1efb106a3..20dd2725d73e8 100644 --- a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncIT.java +++ b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncIT.java @@ -26,7 +26,7 @@ public EsqlClientYamlAsyncIT(final ClientYamlTestCandidate testCandidate) { @ParametersFactory public static Iterable parameters() throws Exception { - return updateEsqlQueryDoSections(createParameters(), doSection -> { + return updateEsqlQueryDoSections(partialResultsDisablingParameters(), doSection -> { ApiCallSection copy = doSection.getApiCallSection().copyWithNewApi("esql.async_query"); for (Map body : copy.getBodies()) { body.put("wait_for_completion_timeout", "30m"); diff --git a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncSubmitAndFetchIT.java b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncSubmitAndFetchIT.java index 38051007568e9..847a78faa247a 100644 --- a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncSubmitAndFetchIT.java +++ b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncSubmitAndFetchIT.java @@ -32,7 +32,7 @@ public EsqlClientYamlAsyncSubmitAndFetchIT(final ClientYamlTestCandidate testCan @ParametersFactory public static Iterable parameters() throws Exception { - return updateEsqlQueryDoSections(createParameters(), DoEsqlAsync::new); + return updateEsqlQueryDoSections(partialResultsDisablingParameters(), DoEsqlAsync::new); } private static class DoEsqlAsync implements ExecutableSection { diff --git a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlIT.java b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlIT.java index 3f8199ce46c54..111e5b8ff3794 100644 --- a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlIT.java +++ b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlIT.java @@ -10,8 +10,6 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; -import org.elasticsearch.test.rest.yaml.section.DoSection; -import org.elasticsearch.test.rest.yaml.section.ExecutableSection; /** * Run the ESQL yaml tests against the synchronous API. @@ -24,17 +22,6 @@ public EsqlClientYamlIT(final ClientYamlTestCandidate testCandidate) { @ParametersFactory public static Iterable parameters() throws Exception { - return updateEsqlQueryDoSections(createParameters(), EsqlClientYamlIT::modifyEsqlQueryExecutableSection); + return partialResultsDisablingParameters(); } - - private static ExecutableSection modifyEsqlQueryExecutableSection(DoSection doSection) { - var apiCallSection = doSection.getApiCallSection(); - if (apiCallSection.getApi().equals("esql.query")) { - if (apiCallSection.getParams().containsKey("allow_partial_results") == false) { - apiCallSection.addParam("allow_partial_results", "false"); // we want any error to fail the test - } - } - return doSection; - } - } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/63_enrich_int_range.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/63_enrich_int_range.yml index 9d25df1fc567a..07a8d2ee5aa9c 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/63_enrich_int_range.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/63_enrich_int_range.yml @@ -203,5 +203,6 @@ teardown: - do: catch: /ENRICH range and input types are incompatible. range\[INTEGER\], input\[DOUBLE\]/ esql.query: + allow_partial_results: false body: query: 'FROM employees | ENRICH ages-policy ON salary | STATS count=COUNT(*) BY description | SORT count DESC, description ASC'