Skip to content

Commit f05f29b

Browse files
committed
Fix rest test
1 parent 8ede6c4 commit f05f29b

File tree

7 files changed

+32
-9
lines changed

7 files changed

+32
-9
lines changed

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/EsqlRestValidationIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ private RestClient remoteClusterClient() throws IOException {
8383

8484
@Before
8585
public void skipTestOnOldVersions() {
86-
assumeTrue("skip on old versions", Clusters.localClusterVersion().equals(Version.V_8_16_0));
86+
assumeTrue("skip on old versions", Clusters.localClusterVersion().equals(Version.V_8_19_0));
8787
}
8888
}

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/RequestIndexFilteringIT.java

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
1111

1212
import org.apache.http.HttpHost;
13+
import org.elasticsearch.Version;
1314
import org.elasticsearch.client.Request;
1415
import org.elasticsearch.client.ResponseException;
1516
import org.elasticsearch.client.RestClient;
@@ -87,6 +88,9 @@ protected String from(String... indexName) {
8788

8889
@Override
8990
public Map<String, Object> runEsql(RestEsqlTestCase.RequestObjectBuilder requestObject) throws IOException {
91+
if (requestObject.allowPartialResults() != null) {
92+
assumeTrue("require allow_partial_results on local cluster", Clusters.localClusterVersion().equals(Version.V_8_19_0));
93+
}
9094
requestObject.includeCCSMetadata(true);
9195
return super.runEsql(requestObject);
9296
}

x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/RestEsqlIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void testInvalidPragma() throws IOException {
111111
request.setJsonEntity("{\"f\":" + i + "}");
112112
assertOK(client().performRequest(request));
113113
}
114-
RequestObjectBuilder builder = requestObjectBuilder().query("from test-index | limit 1 | keep f");
114+
RequestObjectBuilder builder = requestObjectBuilder().query("from test-index | limit 1 | keep f").allowPartialResults(false);
115115
builder.pragmas(Settings.builder().put("data_partitioning", "invalid-option").build());
116116
ResponseException re = expectThrows(ResponseException.class, () -> runEsqlSync(builder));
117117
assertThat(EntityUtils.toString(re.getResponse().getEntity()), containsString("No enum constant"));

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlRestValidationTestCase.java

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ private Request createRequest(String indexName) throws IOException {
129129
final var request = new Request("POST", "/_query");
130130
request.addParameter("error_trace", "true");
131131
request.addParameter("pretty", "true");
132+
request.addParameter("allow_partial_results", Boolean.toString(false));
132133
request.setJsonEntity(
133134
Strings.toString(JsonXContent.contentBuilder().startObject().field("query", "from " + indexName).endObject())
134135
);

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RequestIndexFilteringTestCase.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,26 @@ public void testIndicesDontExist() throws IOException {
198198
int docsTest1 = 0; // we are interested only in the created index, not necessarily that it has data
199199
indexTimestampData(docsTest1, "test1", "2024-11-26", "id1");
200200

201-
ResponseException e = expectThrows(ResponseException.class, () -> runEsql(timestampFilter("gte", "2020-01-01").query(from("foo"))));
201+
ResponseException e = expectThrows(
202+
ResponseException.class,
203+
() -> runEsql(timestampFilter("gte", "2020-01-01").query(from("foo")).allowPartialResults(false))
204+
);
202205
assertEquals(400, e.getResponse().getStatusLine().getStatusCode());
203206
assertThat(e.getMessage(), containsString("verification_exception"));
204207
assertThat(e.getMessage(), anyOf(containsString("Unknown index [foo]"), containsString("Unknown index [remote_cluster:foo]")));
205208

206-
e = expectThrows(ResponseException.class, () -> runEsql(timestampFilter("gte", "2020-01-01").query(from("foo*"))));
209+
e = expectThrows(
210+
ResponseException.class,
211+
() -> runEsql(timestampFilter("gte", "2020-01-01").query(from("foo*")).allowPartialResults(false))
212+
);
207213
assertEquals(400, e.getResponse().getStatusLine().getStatusCode());
208214
assertThat(e.getMessage(), containsString("verification_exception"));
209215
assertThat(e.getMessage(), anyOf(containsString("Unknown index [foo*]"), containsString("Unknown index [remote_cluster:foo*]")));
210216

211-
e = expectThrows(ResponseException.class, () -> runEsql(timestampFilter("gte", "2020-01-01").query(from("foo", "test1"))));
217+
e = expectThrows(
218+
ResponseException.class,
219+
() -> runEsql(timestampFilter("gte", "2020-01-01").query(from("foo", "test1")).allowPartialResults(false))
220+
);
212221
assertEquals(404, e.getResponse().getStatusLine().getStatusCode());
213222
assertThat(e.getMessage(), containsString("index_not_found_exception"));
214223
assertThat(e.getMessage(), anyOf(containsString("no such index [foo]"), containsString("no such index [remote_cluster:foo]")));
@@ -217,7 +226,7 @@ public void testIndicesDontExist() throws IOException {
217226
var pattern = from("test1");
218227
e = expectThrows(
219228
ResponseException.class,
220-
() -> runEsql(timestampFilter("gte", "2020-01-01").query(pattern + " | LOOKUP JOIN foo ON id1"))
229+
() -> runEsql(timestampFilter("gte", "2020-01-01").query(pattern + " | LOOKUP JOIN foo ON id1").allowPartialResults(false))
221230
);
222231
assertEquals(400, e.getResponse().getStatusLine().getStatusCode());
223232
assertThat(

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,15 @@ public RequestObjectBuilder filter(CheckedConsumer<XContentBuilder, IOException>
210210
return this;
211211
}
212212

213-
public RequestObjectBuilder allPartialResults(boolean allPartialResults) {
214-
this.allPartialResults = allPartialResults;
213+
public RequestObjectBuilder allowPartialResults(boolean allowPartialResults) {
214+
this.allPartialResults = allowPartialResults;
215215
return this;
216216
}
217217

218+
public Boolean allowPartialResults() {
219+
return allPartialResults;
220+
}
221+
218222
public RequestObjectBuilder build() throws IOException {
219223
if (isBuilt == false) {
220224
if (tables != null) {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,12 @@ public enum Cap {
891891
/**
892892
* Use double parameter markers to represent field or function names.
893893
*/
894-
DOUBLE_PARAMETER_MARKERS_FOR_IDENTIFIERS(Build.current().isSnapshot());
894+
DOUBLE_PARAMETER_MARKERS_FOR_IDENTIFIERS(Build.current().isSnapshot()),
895+
896+
/**
897+
* Support and enable partial results by default
898+
*/
899+
ESQL_PARTIAL_RESULTS;
895900

896901
private final boolean enabled;
897902

0 commit comments

Comments
 (0)