Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.elasticsearch.action.datastreams.CreateDataStreamAction;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.datastreams.DataStreamsPlugin;
import org.elasticsearch.index.IndexNotFoundException;
Expand Down Expand Up @@ -108,12 +110,44 @@ public void testDoesNotResolveClosedIndex() {
assertAcked(client().admin().indices().prepareCreate("index-1"));
indexRandom(true, "index-1", 10);
assertAcked(client().admin().indices().prepareClose("index-1"));
assertAcked(client().admin().indices().prepareCreate("index-2"));
indexRandom(true, "index-2", 15);

expectThrows(
ClusterBlockException.class,
containsString("index [index-1] blocked by: [FORBIDDEN/4/index closed]"),
() -> run(syncEsqlQueryRequest().query("FROM index-1"))
);
expectThrows(
ClusterBlockException.class,
containsString("index [index-1] blocked by: [FORBIDDEN/4/index closed]"),
() -> run(syncEsqlQueryRequest().query("FROM index-1,index-2"))
);
try (var response = run(syncEsqlQueryRequest().query("FROM index-*"))) {
assertOk(response);
assertResultCount(response, 15);// only index-2 records match
}
}

public void testHiddenIndices() {
assertAcked(client().admin().indices().prepareCreate("my-index-1"));
indexRandom(true, "my-index-1", 10);
assertAcked(
client().admin()
.indices()
.prepareCreate(".hidden-index-1")
.setSettings(Settings.builder().put(IndexMetadata.SETTING_INDEX_HIDDEN, true))
);
indexRandom(true, ".hidden-index-1", 15);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have a test with .hidden-* as well. I guess it's supposed to return 15 as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to FROM *-index-1 it looks like we only matching non-hidden indices.
But with .hidden-* we supply a hidden pattern. Let me add it 👍


try (var response = run(syncEsqlQueryRequest().query("FROM .hidden-index-1"))) {
assertOk(response);
assertResultCount(response, 15);
}
try (var response = run(syncEsqlQueryRequest().query("FROM *-index-1"))) {
assertOk(response);
assertResultCount(response, 10); // only non hidden index matches
}
}

public void testPartialResolution() {
Expand All @@ -134,4 +168,14 @@ public void testPartialResolution() {
private static void assertOk(EsqlQueryResponse response) {
assertThat(response.isPartial(), equalTo(false));
}

private static void assertResultCount(EsqlQueryResponse response, long rows) {
long count = 0;
var iterator = response.column(0);
while (iterator.hasNext()) {
iterator.next();
count++;
}
assertThat(count, equalTo(rows));
}
}