Skip to content

Commit f8cf0da

Browse files
committed
fix some tests
1 parent 4715c50 commit f8cf0da

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,23 @@ public void wipeTestData() throws IOException {
7373
}
7474
}
7575

76-
private String getInexistentIndexErrorMessage() {
77-
return "\"reason\" : \"Found 1 problem\\nline 1:1: Unknown index ";
78-
}
79-
8076
public void testInexistentIndexNameWithWildcard() throws IOException {
81-
assertErrorMessages(inexistentIndexNameWithWildcard, getInexistentIndexErrorMessage(), 400);
77+
for (String indexName : inexistentIndexNameWithWildcard) {
78+
assertErrorMessage(indexName, "Unknown index " + "[" + clusterSpecificIndexName(indexName) + "]", 400);
79+
}
8280
}
8381

82+
@AwaitsFix(bugUrl = "TBD")
83+
// field caps report only first missing index
8484
public void testInexistentIndexNameWithoutWildcard() throws IOException {
85-
assertErrorMessages(inexistentIndexNameWithoutWildcard, getInexistentIndexErrorMessage(), 400);
85+
for (String indexName : inexistentIndexNameWithoutWildcard) {
86+
assertErrorMessage(indexName, "Unknown index " + "[" + clusterSpecificIndexName(indexName) + "]", 400);
87+
}
8688
}
8789

8890
public void testExistentIndexWithoutWildcard() throws IOException {
8991
for (String indexName : existentIndexWithoutWildcard) {
90-
assertErrorMessage(indexName, "\"reason\" : \"no such index [inexistent]\"", 404);
92+
assertErrorMessage(indexName, "Unknown index [inexistent]", 400);
9193
}
9294
}
9395

@@ -99,19 +101,13 @@ public void testAlias() throws IOException {
99101
createAlias();
100102

101103
for (String indexName : existentAliasWithoutWildcard) {
102-
assertErrorMessage(indexName, "\"reason\" : \"no such index [inexistent]\"", 404);
104+
assertErrorMessage(indexName, "Unknown index [inexistent]", 400);
103105
}
104106
assertValidRequestOnIndices(existentAliasWithWildcard);
105107

106108
deleteAlias();
107109
}
108110

109-
private void assertErrorMessages(String[] indices, String errorMessage, int statusCode) throws IOException {
110-
for (String indexName : indices) {
111-
assertErrorMessage(indexName, errorMessage + "[" + clusterSpecificIndexName(indexName) + "]", statusCode);
112-
}
113-
}
114-
115111
protected String clusterSpecificIndexName(String indexName) {
116112
return indexName;
117113
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ public void testIndicesDontExist() throws IOException {
212212
assertThat(e.getMessage(), anyOf(containsString("Unknown index [foo*]"), containsString("Unknown index [remote_cluster:foo*]")));
213213

214214
e = expectThrows(ResponseException.class, () -> runEsql(timestampFilter("gte", "2020-01-01").query("FROM foo, test1")));
215-
assertEquals(404, e.getResponse().getStatusLine().getStatusCode());
216-
assertThat(e.getMessage(), containsString("index_not_found_exception"));
217-
assertThat(e.getMessage(), containsString("no such index [foo]"));
215+
assertEquals(400, e.getResponse().getStatusLine().getStatusCode());
216+
assertThat(e.getMessage(), containsString("verification_exception"));
217+
assertThat(e.getMessage(), containsString("Unknown index [foo]"));
218218

219219
// Don't test remote patterns here, we'll test them in the multi-cluster tests
220220
if (EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()) {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/IndexResolver.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package org.elasticsearch.xpack.esql.session;
88

9+
import org.elasticsearch.ElasticsearchSecurityException;
910
import org.elasticsearch.action.ActionListener;
1011
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesIndexResponse;
1112
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest;
@@ -99,6 +100,8 @@ public void resolveAsMergedMapping(
99100
f -> {
100101
if (f instanceof IndexNotFoundException e) {
101102
listener.onResponse(IndexResolution.notFound(e.getIndex().getName()));
103+
} else if (f instanceof ElasticsearchSecurityException e) {
104+
listener.onResponse(IndexResolution.notFound(indexWildcard));
102105
} else {
103106
listener.onFailure(f);
104107
}

0 commit comments

Comments
 (0)