Browse Source

ESQL: Remove remaining IT_tests_only (#108434)

This moves examples from files marked to run in integration tests only
to the files where they belong and disables this pattern matching. We
now use supported features.
Nik Everett 1 year ago
parent
commit
5a612d4100

+ 8 - 8
docs/reference/esql/processing-commands/enrich.asciidoc

@@ -57,11 +57,11 @@ in this example). `ENRICH` will look for records in the
 
 [source.merge.styled,esql]
 ----
-include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich]
+include::{esql-specs}/enrich.csv-spec[tag=enrich]
 ----
 [%header.monospaced.styled,format=dsv,separator=|]
 |===
-include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich-result]
+include::{esql-specs}/enrich.csv-spec[tag=enrich-result]
 |===
 
 To use a column with a different name than the `match_field` defined in the
@@ -69,11 +69,11 @@ policy as the match field, use `ON <column-name>`:
 
 [source.merge.styled,esql]
 ----
-include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich_on]
+include::{esql-specs}/enrich.csv-spec[tag=enrich_on]
 ----
 [%header.monospaced.styled,format=dsv,separator=|]
 |===
-include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich_on-result]
+include::{esql-specs}/enrich.csv-spec[tag=enrich_on-result]
 |===
 
 By default, each of the enrich fields defined in the policy is added as a
@@ -82,22 +82,22 @@ column. To explicitly select the enrich fields that are added, use
 
 [source.merge.styled,esql]
 ----
-include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich_with]
+include::{esql-specs}/enrich.csv-spec[tag=enrich_with]
 ----
 [%header.monospaced.styled,format=dsv,separator=|]
 |===
-include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich_with-result]
+include::{esql-specs}/enrich.csv-spec[tag=enrich_with-result]
 |===
 
 You can rename the columns that are added using `WITH new_name=<field1>`:
 
 [source.merge.styled,esql]
 ----
-include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich_rename]
+include::{esql-specs}/enrich.csv-spec[tag=enrich_rename]
 ----
 [%header.monospaced.styled,format=dsv,separator=|]
 |===
-include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich_rename-result]
+include::{esql-specs}/enrich.csv-spec[tag=enrich_rename-result]
 |===
 
 In case of name collisions, the newly created columns will override existing

+ 0 - 67
x-pack/plugin/esql/qa/testFixtures/src/main/resources/docs-IT_tests_only.csv-spec

@@ -1,67 +0,0 @@
-// This file contains any ESQL snippets from the docs that don't have a home
-// anywhere else. The Isle of Misfit Toys. When you need to add new examples
-// for the docs you should try to convert an existing test first. Just add
-// the comments in whatever file the test already lives in. If you have to
-// write a new test to make an example in the docs then put it in whatever
-// file matches it's "theme" best. Put it next to similar tests. Not here.
- 
-// Also! When Nik originally extracted examples from the docs to make them
-// testable he didn't spend a lot of time putting the docs into appropriate
-// files. He just made this one. He didn't put his toys away. We'd be better
-// off not adding to this strange toy-pile and instead moving things into
-// the appropriate files.
-
-enrich
-// tag::enrich[]
-ROW language_code = "1"  
-| ENRICH languages_policy
-// end::enrich[]
-;
-
-// tag::enrich-result[]
-language_code:keyword  | language_name:keyword 
-1                      | English 
-// end::enrich-result[]       
-;
-
-
-enrichOn
-// tag::enrich_on[]
-ROW a = "1"  
-| ENRICH languages_policy ON a
-// end::enrich_on[]
-;
-
-// tag::enrich_on-result[]
-a:keyword  | language_name:keyword 
-1          | English 
-// end::enrich_on-result[]       
-;
-
-
-enrichWith
-// tag::enrich_with[]
-ROW a = "1"  
-| ENRICH languages_policy ON a WITH language_name
-// end::enrich_with[]
-;
-
-// tag::enrich_with-result[]
-a:keyword  | language_name:keyword 
-1          | English 
-// end::enrich_with-result[]       
-;
-
-
-enrichRename
-// tag::enrich_rename[]
-ROW a = "1"  
-| ENRICH languages_policy ON a WITH name = language_name
-// end::enrich_rename[]
-;
-
-// tag::enrich_rename-result[]
-a:keyword  | name:keyword 
-1          | English 
-// end::enrich_rename-result[]       
-;

+ 52 - 2
x-pack/plugin/esql/qa/testFixtures/src/main/resources/enrich.csv-spec

@@ -34,12 +34,31 @@ median_duration:double | env:keyword
 simple
 required_feature: esql.enrich_load
 
-row language_code = "1"  
-| enrich languages_policy
+// tag::enrich[]
+ROW language_code = "1"  
+| ENRICH languages_policy
+// end::enrich[]
 ;
 
+// tag::enrich-result[]
 language_code:keyword  | language_name:keyword 
 1                      | English 
+// end::enrich-result[]       
+;
+
+enrichOnSimple
+required_feature: esql.enrich_load
+
+// tag::enrich_on[]
+ROW a = "1"  
+| ENRICH languages_policy ON a
+// end::enrich_on[]
+;
+
+// tag::enrich_on-result[]
+a:keyword  | language_name:keyword 
+1          | English 
+// end::enrich_on-result[]       
 ;
 
 
@@ -83,6 +102,22 @@ emp_no:integer | x:keyword | language_name:keyword
 ;
 
 
+withSimple
+required_feature: esql.enrich_load
+
+// tag::enrich_with[]
+ROW a = "1"  
+| ENRICH languages_policy ON a WITH language_name
+// end::enrich_with[]
+;
+
+// tag::enrich_with-result[]
+a:keyword  | language_name:keyword 
+1          | English 
+// end::enrich_with-result[]       
+;
+
+
 withAlias
 required_feature: esql.enrich_load
 
@@ -95,6 +130,21 @@ emp_no:integer | x:keyword | lang:keyword
 10003          | 4         | German
 ;
 
+withAliasSimple
+required_feature: esql.enrich_load
+
+// tag::enrich_rename[]
+ROW a = "1"  
+| ENRICH languages_policy ON a WITH name = language_name
+// end::enrich_rename[]
+;
+
+// tag::enrich_rename-result[]
+a:keyword  | name:keyword 
+1          | English 
+// end::enrich_rename-result[]       
+;
+
 
 withAliasSort
 required_feature: esql.enrich_load

+ 4 - 5
x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java

@@ -110,6 +110,8 @@ import static org.elasticsearch.xpack.esql.EsqlTestUtils.loadMapping;
 import static org.elasticsearch.xpack.ql.CsvSpecReader.specParser;
 import static org.elasticsearch.xpack.ql.TestUtils.classpathResources;
 import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.notNullValue;
 
@@ -144,7 +146,6 @@ import static org.hamcrest.Matchers.notNullValue;
 public class CsvTests extends ESTestCase {
 
     private static final Logger LOGGER = LogManager.getLogger(CsvTests.class);
-    private static final String IGNORED_CSV_FILE_NAMES_PATTERN = "-IT_tests_only";
 
     private final String fileName;
     private final String groupName;
@@ -164,10 +165,8 @@ public class CsvTests extends ESTestCase {
 
     @ParametersFactory(argumentFormatting = "%2$s.%3$s")
     public static List<Object[]> readScriptSpec() throws Exception {
-        List<URL> urls = classpathResources("/*.csv-spec").stream()
-            .filter(x -> x.toString().contains(IGNORED_CSV_FILE_NAMES_PATTERN) == false)
-            .toList();
-        assertTrue("Not enough specs found " + urls, urls.size() > 0);
+        List<URL> urls = classpathResources("/*.csv-spec");
+        assertThat("Not enough specs found " + urls, urls, hasSize(greaterThan(0)));
         return SpecReader.readScriptSpec(urls, specParser());
     }