Skip to content

Commit 58c8230

Browse files
committed
assert original index expression in error
1 parent 3029bfb commit 58c8230

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ public void testIndicesDontExist() throws IOException {
204204
ResponseException e = expectThrows(ResponseException.class, () -> runEsql(timestampFilter("gte", "2020-01-01").query(from("foo"))));
205205
assertEquals(400, e.getResponse().getStatusLine().getStatusCode());
206206
assertThat(e.getMessage(), containsString("verification_exception"));
207-
assertThat(e.getMessage(), anyOf(containsString("Unknown index [foo]"), containsString("Unknown index [remote_cluster:foo]")));
207+
assertThat(e.getMessage(), anyOf(containsString("Unknown index [foo]"), containsString("Unknown index [*:foo]")));
208208

209209
e = expectThrows(ResponseException.class, () -> runEsql(timestampFilter("gte", "2020-01-01").query(from("foo*"))));
210210
assertEquals(400, e.getResponse().getStatusLine().getStatusCode());
211211
assertThat(e.getMessage(), containsString("verification_exception"));
212-
assertThat(e.getMessage(), anyOf(containsString("Unknown index [foo*]"), containsString("Unknown index [remote_cluster:foo*]")));
212+
assertThat(e.getMessage(), anyOf(containsString("Unknown index [foo*]"), containsString("Unknown index [*:foo*]")));
213213

214214
e = expectThrows(ResponseException.class, () -> runEsql(timestampFilter("gte", "2020-01-01").query("FROM foo, test1")));
215215
assertEquals(404, e.getResponse().getStatusLine().getStatusCode());

x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityEsqlIT.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,9 @@
4242
import java.util.Collections;
4343
import java.util.List;
4444
import java.util.Map;
45-
import java.util.Set;
4645
import java.util.concurrent.atomic.AtomicBoolean;
4746
import java.util.concurrent.atomic.AtomicInteger;
4847
import java.util.concurrent.atomic.AtomicReference;
49-
import java.util.regex.Matcher;
50-
import java.util.regex.Pattern;
5148
import java.util.stream.Collectors;
5249
import java.util.stream.Stream;
5350

@@ -986,16 +983,7 @@ public void testAlias() throws Exception {
986983
Request request = esqlRequest("FROM " + index + " | KEEP emp_id | SORT emp_id | LIMIT 100");
987984
ResponseException error = expectThrows(ResponseException.class, () -> performRequestWithRemoteSearchUser(request));
988985
assertThat(error.getResponse().getStatusLine().getStatusCode(), equalTo(400));
989-
String expectedIndexExpressionInError = index.replace("*", "my_remote_cluster");
990-
Pattern p = Pattern.compile("Unknown index \\[([^\\]]+)\\]");
991-
Matcher m = p.matcher(error.getMessage());
992-
assertTrue("Pattern matcher to parse error message did not find matching string: " + error.getMessage(), m.find());
993-
String unknownIndexExpressionInErrorMessage = m.group(1);
994-
Set<String> actualUnknownIndexes = org.elasticsearch.common.Strings.commaDelimitedListToSet(
995-
unknownIndexExpressionInErrorMessage
996-
);
997-
Set<String> expectedUnknownIndexes = org.elasticsearch.common.Strings.commaDelimitedListToSet(expectedIndexExpressionInError);
998-
assertThat(actualUnknownIndexes, equalTo(expectedUnknownIndexes));
986+
assertThat(error.getMessage(), containsString("Unknown index [" + index + "]"));
999987
}
1000988

1001989
for (var index : List.of(

0 commit comments

Comments
 (0)