Skip to content

Commit ef5a1db

Browse files
committed
more test fixes
1 parent 15d0f9a commit ef5a1db

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
import java.util.List;
3232
import java.util.Map;
3333

34+
import static org.elasticsearch.test.ListMatcher.matchesList;
3435
import static org.elasticsearch.test.MapMatcher.assertMap;
3536
import static org.elasticsearch.test.MapMatcher.matchesMap;
3637
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
38+
import static org.hamcrest.Matchers.hasSize;
3739
import static org.hamcrest.Matchers.instanceOf;
3840

3941
@ThreadLeakFilters(filters = TestClustersThreadFilter.class)
@@ -138,4 +140,25 @@ protected void assertQueryResult(Map<String, Object> result, Matcher<?> columnMa
138140
assertMap(result, matcher);
139141
}
140142

143+
// We need a separate test since remote missing indices and local missing indices now work differently
144+
public void testIndicesDontExistRemote() throws IOException {
145+
int docsTest1 = randomIntBetween(1, 5);
146+
indexTimestampData(docsTest1, "test1", "2024-11-26", "id1");
147+
148+
Map<String, Object> result = runEsql(
149+
timestampFilter("gte", "2020-01-01").query("FROM *:foo,*:test1 METADATA _index | SORT id1 | KEEP _index, id*")
150+
);
151+
@SuppressWarnings("unchecked")
152+
var columns = (List<List<Object>>) result.get("columns");
153+
assertThat(
154+
columns,
155+
matchesList().item(matchesMap().entry("name", "_index").entry("type", "keyword"))
156+
.item(matchesMap().entry("name", "id1").entry("type", "integer"))
157+
);
158+
@SuppressWarnings("unchecked")
159+
var values = (List<List<Object>>) result.get("values");
160+
// TODO: for now, we return empty result, but eventually it should return records from test1
161+
assertThat(values, hasSize(0));
162+
163+
}
141164
}

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

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -208,21 +208,10 @@ public void testIndicesDontExist() throws IOException {
208208
assertThat(e.getMessage(), containsString("verification_exception"));
209209
assertThat(e.getMessage(), anyOf(containsString("Unknown index [foo*]"), containsString("Unknown index [remote_cluster:foo*]")));
210210

211-
// FIXME: this test now behaves differently on local & remote cluster, because local is not skippable, we need to fix it
212-
// Map<String, Object> result = runEsql(
213-
// timestampFilter("gte", "2020-01-01").query(from("foo", "test1") + " METADATA _index | SORT id1 | KEEP _index, id*")
214-
// );
215-
// @SuppressWarnings("unchecked")
216-
// var columns = (List<List<Object>>) result.get("columns");
217-
// assertThat(
218-
// columns,
219-
// matchesList().item(matchesMap().entry("name", "_index").entry("type", "keyword"))
220-
// .item(matchesMap().entry("name", "id1").entry("type", "integer"))
221-
// );
222-
// @SuppressWarnings("unchecked")
223-
// var values = (List<List<Object>>) result.get("values");
224-
// // TODO: for now, we return empty result, but eventually it should return records from test1
225-
// assertThat(values, hasSize(0));
211+
e = expectThrows(ResponseException.class, () -> runEsql(timestampFilter("gte", "2020-01-01").query("FROM foo, test1")));
212+
assertEquals(404, e.getResponse().getStatusLine().getStatusCode());
213+
assertThat(e.getMessage(), containsString("index_not_found_exception"));
214+
assertThat(e.getMessage(), anyOf(containsString("no such index [foo]"), containsString("no such index [remote_cluster:foo]")));
226215

227216
if (EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()) {
228217
var pattern = from("test1");
@@ -242,7 +231,7 @@ public void testIndicesDontExist() throws IOException {
242231
}
243232
}
244233

245-
private static RestEsqlTestCase.RequestObjectBuilder timestampFilter(String op, String date) throws IOException {
234+
protected static RestEsqlTestCase.RequestObjectBuilder timestampFilter(String op, String date) throws IOException {
246235
return requestObjectBuilder().filter(b -> {
247236
b.startObject("range");
248237
{

0 commit comments

Comments
 (0)