-
Notifications
You must be signed in to change notification settings - Fork 25.3k
ES|QL: Add FORK generative tests #129135
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 FORK generative tests #129135
Changes from all commits
Commits
Show all changes
3 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
50 changes: 50 additions & 0 deletions
50
...e/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/GenerativeForkIT.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,50 @@ | ||
/* | ||
* 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.qa.single_node; | ||
|
||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; | ||
|
||
import org.elasticsearch.test.TestClustersThreadFilter; | ||
import org.elasticsearch.test.cluster.ElasticsearchCluster; | ||
import org.elasticsearch.xpack.esql.CsvSpecReader; | ||
import org.elasticsearch.xpack.esql.qa.rest.generative.GenerativeForkRestTest; | ||
import org.junit.ClassRule; | ||
|
||
@ThreadLeakFilters(filters = TestClustersThreadFilter.class) | ||
public class GenerativeForkIT extends GenerativeForkRestTest { | ||
@ClassRule | ||
public static ElasticsearchCluster cluster = Clusters.testCluster(spec -> spec.plugin("inference-service-test")); | ||
|
||
@Override | ||
protected String getTestRestCluster() { | ||
return cluster.getHttpAddresses(); | ||
} | ||
|
||
public GenerativeForkIT( | ||
String fileName, | ||
String groupName, | ||
String testName, | ||
Integer lineNumber, | ||
CsvSpecReader.CsvTestCase testCase, | ||
String instructions, | ||
Mode mode | ||
) { | ||
super(fileName, groupName, testName, lineNumber, testCase, instructions, mode); | ||
} | ||
|
||
@Override | ||
protected boolean enableRoundingDoubleValuesOnAsserting() { | ||
// This suite runs with more than one node and three shards in serverless | ||
return cluster.getNumNodes() > 1; | ||
} | ||
|
||
@Override | ||
protected boolean supportsSourceFieldMapping() { | ||
return cluster.getNumNodes() == 1; | ||
} | ||
} |
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
65 changes: 65 additions & 0 deletions
65
...src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/GenerativeForkRestTest.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,65 @@ | ||
/* | ||
* 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.qa.rest.generative; | ||
|
||
import org.elasticsearch.xpack.esql.CsvSpecReader; | ||
import org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.*; | ||
|
||
/** | ||
* Tests for FORK. We generate tests for FORK from existing CSV tests. | ||
* We append a `| FORK (WHERE true) (WHERE true) | WHERE _fork == "fork1" | DROP _fork` suffix to existing | ||
* CSV test cases. This will produce a query that executes multiple FORK branches but expects the same results | ||
* as the initial CSV test case. | ||
* For now, we skip tests that already require FORK, since multiple FORK commands are not allowed. | ||
*/ | ||
public abstract class GenerativeForkRestTest extends EsqlSpecTestCase { | ||
public GenerativeForkRestTest( | ||
String fileName, | ||
String groupName, | ||
String testName, | ||
Integer lineNumber, | ||
CsvSpecReader.CsvTestCase testCase, | ||
String instructions, | ||
Mode mode | ||
) { | ||
super(fileName, groupName, testName, lineNumber, testCase, instructions, mode); | ||
} | ||
|
||
@Override | ||
protected void doTest() throws Throwable { | ||
String query = testCase.query + " | FORK (WHERE true) (WHERE true) | WHERE _fork == \"fork1\" | DROP _fork"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
doTest(query); | ||
} | ||
|
||
@Override | ||
protected void shouldSkipTest(String testName) throws IOException { | ||
super.shouldSkipTest(testName); | ||
|
||
assumeFalse( | ||
"Tests using FORK or RRF already are skipped since we don't support multiple FORKs", | ||
testCase.requiredCapabilities.contains(FORK_V7.capabilityName()) || testCase.requiredCapabilities.contains(RRF.capabilityName()) | ||
); | ||
|
||
assumeFalse( | ||
"Tests using INSIST are not supported for now", | ||
testCase.requiredCapabilities.contains(UNMAPPED_FIELDS.capabilityName()) | ||
); | ||
|
||
assumeFalse( | ||
"Tests using implicit_casting_date_and_date_nanos are not supported for now", | ||
testCase.requiredCapabilities.contains(IMPLICIT_CASTING_DATE_AND_DATE_NANOS.capabilityName()) | ||
); | ||
|
||
assumeTrue("Cluster needs to support FORK", hasCapabilities(client(), List.of(FORK_V7.capabilityName()))); | ||
} | ||
} |
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
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
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.
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.
It might be obvious from the query, but maybe add a short description javadoc that summarises the intention.