-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ES|QL: Add license check for RRF #125225
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
Merged
Merged
ES|QL: Add license check for RRF #125225
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
77 changes: 77 additions & 0 deletions
77
...k/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/RrfIT.java
This file contains hidden or 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,77 @@ | ||
| /* | ||
| * 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.action.index.IndexRequest; | ||
| import org.elasticsearch.action.support.WriteRequest; | ||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.plugins.Plugin; | ||
| import org.junit.Before; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.List; | ||
|
|
||
| import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; | ||
| import static org.elasticsearch.xpack.esql.EsqlTestUtils.getValuesList; | ||
| import static org.hamcrest.Matchers.equalTo; | ||
|
|
||
| public class RrfIT extends AbstractEsqlIntegTestCase { | ||
| @Override | ||
| protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
| return List.of(EsqlPluginWithEnterpriseOrTrialLicense.class); | ||
| } | ||
|
|
||
| @Before | ||
| public void setupIndex() { | ||
| assumeTrue("requires RRF capability", EsqlCapabilities.Cap.RRF.isEnabled()); | ||
| createAndPopulateIndex(); | ||
| } | ||
|
|
||
| public void testRrf() { | ||
| var query = """ | ||
| FROM test METADATA _score, _id, _index | ||
| | WHERE id > 2 | ||
| | FORK | ||
| ( WHERE content:"fox" | SORT _score, _id DESC ) | ||
| ( WHERE content:"dog" | SORT _score, _id DESC ) | ||
| | RRF | ||
| | EVAL _score = round(_score, 4) | ||
| | KEEP id, content, _score, _fork | ||
| """; | ||
| try (var resp = run(query)) { | ||
| assertColumnNames(resp.columns(), List.of("id", "content", "_score", "_fork")); | ||
| assertColumnTypes(resp.columns(), List.of("integer", "keyword", "double", "keyword")); | ||
| assertThat(getValuesList(resp.values()).size(), equalTo(3)); | ||
| Iterable<Iterable<Object>> expectedValues = List.of( | ||
| List.of(6, "The quick brown fox jumps over the lazy dog", 0.0325, List.of("fork1", "fork2")), | ||
| List.of(4, "The dog is brown but this document is very very long", 0.0164, "fork2"), | ||
| List.of(3, "This dog is really brown", 0.0159, "fork2") | ||
| ); | ||
| assertValues(resp.values(), expectedValues); | ||
| } | ||
| } | ||
|
|
||
| private void createAndPopulateIndex() { | ||
| var indexName = "test"; | ||
| var client = client().admin().indices(); | ||
| var CreateRequest = client.prepareCreate(indexName) | ||
| .setSettings(Settings.builder().put("index.number_of_shards", 1)) | ||
| .setMapping("id", "type=integer", "content", "type=text"); | ||
| assertAcked(CreateRequest); | ||
| client().prepareBulk() | ||
| .add(new IndexRequest(indexName).id("1").source("id", 1, "content", "This is a brown fox")) | ||
| .add(new IndexRequest(indexName).id("2").source("id", 2, "content", "This is a brown dog")) | ||
| .add(new IndexRequest(indexName).id("3").source("id", 3, "content", "This dog is really brown")) | ||
| .add(new IndexRequest(indexName).id("4").source("id", 4, "content", "The dog is brown but this document is very very long")) | ||
| .add(new IndexRequest(indexName).id("5").source("id", 5, "content", "There is also a white cat")) | ||
| .add(new IndexRequest(indexName).id("6").source("id", 6, "content", "The quick brown fox jumps over the lazy dog")) | ||
| .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) | ||
| .get(); | ||
| ensureYellow(indexName); | ||
| } | ||
| } |
62 changes: 62 additions & 0 deletions
62
...internalClusterTest/java/org/elasticsearch/xpack/esql/action/RrfWithInvalidLicenseIT.java
This file contains hidden or 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,62 @@ | ||
| /* | ||
| * 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.ElasticsearchException; | ||
| import org.elasticsearch.action.index.IndexRequestBuilder; | ||
| import org.elasticsearch.action.support.WriteRequest; | ||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.plugins.Plugin; | ||
| import org.elasticsearch.xpack.esql.VerificationException; | ||
| import org.junit.Before; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.List; | ||
|
|
||
| import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; | ||
| import static org.hamcrest.Matchers.containsString; | ||
|
|
||
| public class RrfWithInvalidLicenseIT extends AbstractEsqlIntegTestCase { | ||
| private static final String LICENSE_ERROR_MESSAGE = "current license is non-compliant for [RRF]"; | ||
|
|
||
| @Override | ||
| protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
| return List.of(EsqlPluginWithNonEnterpriseOrExpiredLicense.class); | ||
| } | ||
|
|
||
| @Before | ||
| public void setupIndex() { | ||
| assumeTrue("requires RRF capability", EsqlCapabilities.Cap.RRF.isEnabled()); | ||
| var indexName = "test"; | ||
| var client = client().admin().indices(); | ||
| var CreateRequest = client.prepareCreate(indexName) | ||
| .setSettings(Settings.builder().put("index.number_of_shards", 1)) | ||
| .setMapping("id", "type=integer", "content", "type=text"); | ||
| assertAcked(CreateRequest); | ||
| client().prepareBulk() | ||
| .add(new IndexRequestBuilder(client, indexName).setId("1").setSource("id", 1, "content", "This is a brown fox")) | ||
| .add(new IndexRequestBuilder(client, indexName).setId("2").setSource("id", 2, "content", "This is a brown dog")) | ||
| .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) | ||
| .get(); | ||
| ensureYellow(indexName); | ||
| } | ||
|
|
||
| public void testRrf() { | ||
| var query = """ | ||
| FROM test METADATA _score, _id, _index | ||
| | FORK | ||
| ( WHERE content:"fox" ) | ||
| ( WHERE content:"dog" ) | ||
| | RRF | ||
| """; | ||
|
|
||
| ElasticsearchException e = expectThrows(VerificationException.class, () -> run(query)); | ||
|
|
||
| assertThat(e.getMessage(), containsString(LICENSE_ERROR_MESSAGE)); | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test failed because we don't load the
EsqlPluginWithEnterpriseOrTrialLicensetest plugin.I did not see a need to load this plugin for the FORK tests so I took this test out in its own
RrfITsince it was primarily aimed at testing RRF and not FORK.