Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESQL: Support "capabilites" in the csv-spec tests #108464

Merged

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented May 9, 2024

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.

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.
@nik9000 nik9000 added >test Issues or PRs that are addressing/adding tests :Analytics/ES|QL AKA ESQL v8.15.0 labels May 9, 2024
@nik9000 nik9000 requested a review from thecoop May 9, 2024 14:07
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label May 9, 2024
@thecoop thecoop requested a review from a team May 9, 2024 14:12
* Does the cluster on the other side of {@code client} support the set
* of capabilities for specified path and method.
*/
protected static boolean clusterHasCapability(RestClient client, String method, String path, Collection<String> capabilities)
Copy link
Member

Choose a reason for hiding this comment

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

These are general methods, so they should also have a parameter for query params too

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@nik9000
Copy link
Member Author

nik9000 commented May 9, 2024

The failure is quite real and looks like a bug in capabilities. Or something that makes it kind of difficult for us. If I run this one:

./gradlew ':x-pack:plugin:esql:qa:server:mixed-cluster:v8.14.0#javaRestTest' -Dtests.class="org.elasticsearch.xpack.esql.qa.mixed.MixedClusterEsqlSpecIT" -Dtests.method="test {convert.ConvertToInteger ASYNC}" -Dtests.seed=DA25EC54DE5EEA99 -Dtests.bwc=true -Dtests.locale=it-CH -Dtests.timezone=Europe/Amsterdam -Druntime.java=21    --debug-jvm

and drop a breakpoint in clusterHasCapability and then rerun entityAsMap(client.performRequest(request).getEntity()) a bunch of times I get two answers:

  • 400 error
  • 200 ok - and supported

What I really want is an error every time - some of the nodes don't support the request and I'm going to need to fall back to cluster capabilities and/or just say "I can't run this test".

@thecoop
Copy link
Member

thecoop commented May 10, 2024

Yes, the behaviour as-merged doesn't deal well with mixed clusters. This is improved by #108425, which I'm working on today

@thecoop
Copy link
Member

thecoop commented May 10, 2024

@elasticmachine update branch

Copy link
Contributor

@alex-spies alex-spies left a comment

Choose a reason for hiding this comment

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

I think the yaml tests need a quick update, too, no?

Exactly two seem to use cluster features which are not just gte_v8.xxx: 40_tsdb.yml and 100_bug_fix.yml

Copy link
Contributor

@alex-spies alex-spies left a comment

Choose a reason for hiding this comment

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

Thanks a lot @nik9000, this looks good to me (except the bug you're fighting, of course).

@@ -222,8 +221,8 @@ public final void test() throws Throwable {
* The csv tests support all but a few features. The unsupported features
* are tested in integration tests.
*/
assumeFalse("metadata fields aren't supported", testCase.requiredFeatures.contains(EsqlFeatures.METADATA_FIELDS.id()));
assumeFalse("enrich can't load fields in csv tests", testCase.requiredFeatures.contains(EsqlFeatures.ENRICH_LOAD.id()));
assumeFalse("metadata fields aren't supported", testCase.requiredCapabilities.contains("metadata_fields"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: using constants could be more robust to future changes. We could make EsqlCapabilities.cap public, then this could just be

Suggested change
assumeFalse("metadata fields aren't supported", testCase.requiredCapabilities.contains("metadata_fields"));
assumeFalse("metadata fields aren't supported", testCase.requiredCapabilities.contains(cap(EsqlFeatures.METADATA_FIELDS)));

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I probably should do that.

@alex-spies
Copy link
Contributor

I think the yaml tests need a quick update, too, no?

Exactly two seem to use cluster features which are not just gte_v8.xxx: 40_tsdb.yml and 100_bug_fix.yml

Sorry, I realized this is only relevant if we disabled esql's cluster features, which we're not doing here.

@nik9000
Copy link
Member Author

nik9000 commented May 10, 2024

Yes, the behaviour as-merged doesn't deal well with mixed clusters. This is improved by #108425, which I'm working on today

It works! Thanks @thecoop .

@nik9000 nik9000 added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label May 10, 2024
@elasticsearchmachine elasticsearchmachine merged commit 7cc4335 into elastic:main May 10, 2024
15 checks passed
@nik9000 nik9000 deleted the esql_features_are_capabilities branch May 10, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) >test Issues or PRs that are addressing/adding tests v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants