Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ESQL: Support "capabilites" in the csv-spec tests (#108464)
This flips the csv-spec construct called `required_feature:` from using "cluster features" to using "cluster capabilities". "Features" are a "heavy" concept that live in the cluster state and should be used for quickly checking things on the local node. "Capabilities" are fairly fluid list of strings that live on each node and are calculated on the fly so much nicer for testing. This adds all existing "cluster features" for esql as "cluster capabilities" for the ESQL `_query` and `_query/async` actions. The tests just check that. In a follow-up change I'll replace the syntax `required_feature:` with `required_capability:`. Our esql capabilities all starts with `esql.` - but capabilities are naturally scoped to the endpoint. So I've removed the `esql.` from the capabilities we add.
- Loading branch information
Showing
7 changed files
with
113 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.esql.action; | ||
|
||
import org.elasticsearch.features.NodeFeature; | ||
import org.elasticsearch.rest.action.admin.cluster.RestNodesCapabilitiesAction; | ||
import org.elasticsearch.xpack.esql.plugin.EsqlFeatures; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* A {@link Set} of "capabilities" supported by the {@link RestEsqlQueryAction} | ||
* and {@link RestEsqlAsyncQueryAction} APIs. These are exposed over the | ||
* {@link RestNodesCapabilitiesAction} and we use them to enable tests. | ||
*/ | ||
public class EsqlCapabilities { | ||
static final Set<String> CAPABILITIES = capabilities(); | ||
|
||
private static Set<String> capabilities() { | ||
/* | ||
* Add all of our cluster features without the leading "esql." | ||
*/ | ||
List<String> caps = new ArrayList<>(); | ||
for (NodeFeature feature : new EsqlFeatures().getFeatures()) { | ||
caps.add(cap(feature)); | ||
} | ||
for (NodeFeature feature : new EsqlFeatures().getHistoricalFeatures().keySet()) { | ||
caps.add(cap(feature)); | ||
} | ||
return Set.copyOf(caps); | ||
} | ||
|
||
/** | ||
* Convert a {@link NodeFeature} from {@link EsqlFeatures} into a | ||
* capability. | ||
*/ | ||
public static String cap(NodeFeature feature) { | ||
assert feature.id().startsWith("esql."); | ||
return feature.id().substring("esql.".length()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters