Skip to content

Commit fb7fb6a

Browse files
committed
fix tests
1 parent 7313daf commit fb7fb6a

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void wipeTestData() throws IOException {
7474
}
7575

7676
private String getInexistentIndexErrorMessage() {
77-
return "\"reason\" : \"Found 1 problem\\nline 1:1: Unknown index ";
77+
return "Unknown index ";
7878
}
7979

8080
public void testInexistentIndexNameWithWildcard() throws IOException {

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClusterQueryWithFiltersIT.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ protected void assertClusterMetadataNoShards(EsqlExecutionInfo.Cluster clusterMe
5959
assertThat(clusterMetatata.getFailedShards(), equalTo(0));
6060
}
6161

62-
protected void assertClusterMetadataSkipped(EsqlExecutionInfo.Cluster clusterMetatata, int shards, long took, String indexExpression) {
62+
protected void assertClusterMetadataSkippedShards(
63+
EsqlExecutionInfo.Cluster clusterMetatata,
64+
int shards,
65+
long took,
66+
String indexExpression
67+
) {
6368
assertThat(clusterMetatata.getIndexExpression(), equalTo(indexExpression));
6469
assertThat(clusterMetatata.getStatus(), equalTo(EsqlExecutionInfo.Cluster.Status.SUCCESSFUL));
6570
assertThat(clusterMetatata.getTook().millis(), greaterThanOrEqualTo(0L));
@@ -153,7 +158,7 @@ public void testTimestampFilterFromQuery() {
153158
assertThat(executionInfo.clusterAliases(), equalTo(Set.of(REMOTE_CLUSTER_1, LOCAL_CLUSTER)));
154159

155160
EsqlExecutionInfo.Cluster localCluster = executionInfo.getCluster(LOCAL_CLUSTER);
156-
assertClusterMetadataSkipped(localCluster, localShards, overallTookMillis, "logs-1");
161+
assertClusterMetadataSkippedShards(localCluster, localShards, overallTookMillis, "logs-1");
157162

158163
EsqlExecutionInfo.Cluster remoteCluster = executionInfo.getCluster(REMOTE_CLUSTER_1);
159164
assertClusterMetadataSuccess(remoteCluster, remoteShards, overallTookMillis, "logs-2");
@@ -202,7 +207,7 @@ public void testTimestampFilterFromQuery() {
202207

203208
EsqlExecutionInfo.Cluster localCluster = executionInfo.getCluster(LOCAL_CLUSTER);
204209
// Local cluster can not be filtered out for now
205-
assertClusterMetadataSkipped(localCluster, localShards, overallTookMillis, "logs-1");
210+
assertClusterMetadataSkippedShards(localCluster, localShards, overallTookMillis, "logs-1");
206211
}
207212

208213
// Both indices are filtered out - wildcards
@@ -226,7 +231,7 @@ public void testTimestampFilterFromQuery() {
226231

227232
EsqlExecutionInfo.Cluster localCluster = executionInfo.getCluster(LOCAL_CLUSTER);
228233
// Local cluster can not be filtered out for now
229-
assertClusterMetadataSkipped(localCluster, localShards, overallTookMillis, "logs-*");
234+
assertClusterMetadataSkippedShards(localCluster, localShards, overallTookMillis, "logs-*");
230235
}
231236

232237
}
@@ -274,6 +279,18 @@ public void testFilterWithMissingIndex() {
274279
}
275280
}
276281

282+
public void testFilterWithMissingRemoteIndex() {
283+
// TODO
284+
}
285+
286+
public void testFilterWithUnavailableRemote() {
287+
// TODO
288+
}
289+
290+
public void testFilterWithUnavailableRemoteAndSkipUnavailable() {
291+
// TODO
292+
}
293+
277294
protected void populateDateIndex(String clusterAlias, String indexName, int numShards, int numDocs, String date) {
278295
Client client = client(clusterAlias);
279296
String tag = Strings.isEmpty(clusterAlias) ? "local" : clusterAlias;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ public static class Cluster implements ToXContentFragment, Writeable {
384384
public enum Status {
385385
RUNNING, // still running
386386
SUCCESSFUL, // all shards completed search
387-
FILTERED, // all shards were filtered out
387+
FILTERED, // all shards were filtered out, temporary status for planning
388388
PARTIAL, // only some shards completed the search, partial results from cluster
389389
SKIPPED, // entire cluster was skipped
390390
FAILED; // search was failed due to errors on this cluster

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public void analyzedPlan(
381381
// TODO in follow-PR (for skip_unavailable handling of missing concrete indexes) add some tests for
382382
// invalid index resolution to updateExecutionInfo
383383
// If we run out of clusters to search due to unavailability we can stop the analysis right here
384-
if (allCCSClustersSkipped(executionInfo, result, logicalPlanListener)) return;
384+
if (result.indices.isValid() && allCCSClustersSkipped(executionInfo, result, logicalPlanListener)) return;
385385
// whatever tuple we have here (from CCS-special handling or from the original pre-analysis), pass it on to the next step
386386
l.onResponse(result);
387387
}).<PreAnalysisResult>andThen((l, result) -> {
@@ -397,8 +397,10 @@ public void analyzedPlan(
397397
LOGGER.debug("Analyzing the plan (second attempt, without filter)");
398398
LogicalPlan plan;
399399
try {
400-
EsqlCCSUtils.updateExecutionInfoWithClustersWithNoMatchingIndices(executionInfo, result.indices, null);
400+
// the order here is tricky - if the cluster has been filtered and later became unavailable,
401+
// do we want to declare it successful or skipped? For now, unavailability takes precedence.
401402
EsqlCCSUtils.updateExecutionInfoWithUnavailableClusters(executionInfo, result.indices.unavailableClusters());
403+
EsqlCCSUtils.updateExecutionInfoWithClustersWithNoMatchingIndices(executionInfo, result.indices, null);
402404
plan = analyzeAction.apply(result);
403405
} catch (Exception e) {
404406
l.onFailure(e);
@@ -535,7 +537,10 @@ private static void analyzeAndMaybeRetry(
535537
LOGGER.debug("Analyzing the plan ({} attempt, {} filter)", attemptMessage, filterPresentMessage);
536538

537539
try {
538-
EsqlCCSUtils.updateExecutionInfoWithClustersWithNoMatchingIndices(executionInfo, result.indices, requestFilter);
540+
if (result.indices.isValid() || requestFilter != null) {
541+
// Capture filtered out indices
542+
EsqlCCSUtils.updateExecutionInfoWithClustersWithNoMatchingIndices(executionInfo, result.indices, requestFilter);
543+
}
539544
plan = analyzeAction.apply(result);
540545
} catch (Exception e) {
541546
if (e instanceof VerificationException ve) {

0 commit comments

Comments
 (0)