diff --git a/TESTING.asciidoc b/TESTING.asciidoc index f574633a90ec..305e0f637183 100644 --- a/TESTING.asciidoc +++ b/TESTING.asciidoc @@ -446,13 +446,15 @@ A specific test case can be run with the following command: -Dtests.method="test {yaml=cat.segments/10_basic/Help}" --------------------------------------------------------------------------- +You can run a group of YAML test by using wildcards: + +--------------------------------------------------------------------------- +./gradlew :rest-api-spec:yamlRestTest \ + --tests "org.elasticsearch.test.rest.ClientYamlTestSuiteIT.test {yaml=index/*/*}" +--------------------------------------------------------------------------- + The YAML REST tests support all the options provided by the randomized runner, plus the following: -* `tests.rest.suite`: comma separated paths of the test suites to be run -(by default loaded from /rest-api-spec/test). It is possible to run only a subset -of the tests providing a sub-folder or even a single yaml file (the default -/rest-api-spec/test prefix is optional when files are loaded from classpath) -e.g. -Dtests.rest.suite=index,get,create/10_with_id * `tests.rest.blacklist`: comma separated globs that identify tests that are blacklisted and need to be skipped e.g. -Dtests.rest.blacklist=index/*/Index document,get/10_basic/* diff --git a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java index 001ed5eb7f94..cb60cb2758dd 100644 --- a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java +++ b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java @@ -220,7 +220,32 @@ public abstract class ESClientYamlSuiteTestCase extends ESRestTestCase { * Create parameters for this parameterized test. */ public static Iterable createParameters(NamedXContentRegistry executeableSectionRegistry) throws Exception { - String[] paths = resolvePathsProperty(REST_TESTS_SUITE, ""); // default to all tests under the test root + return createParameters(executeableSectionRegistry, null); + } + + /** + * Create parameters for this parameterized test. + */ + public static Iterable createParameters(String[] testPaths) throws Exception { + return createParameters(ExecutableSection.XCONTENT_REGISTRY, testPaths); + } + + /** + * Create parameters for this parameterized test. + * + * @param executeableSectionRegistry registry of executable sections + * @param testPaths list of paths to explicitly search for tests. If null then include all tests in root path. + * @return list of test candidates. + * @throws Exception + */ + public static Iterable createParameters(NamedXContentRegistry executeableSectionRegistry, String[] testPaths) + throws Exception { + if (testPaths != null && System.getProperty(REST_TESTS_SUITE) != null) { + throw new IllegalArgumentException("The '" + REST_TESTS_SUITE + "' system property is not supported with explicit test paths."); + } + + // default to all tests under the test root + String[] paths = testPaths == null ? resolvePathsProperty(REST_TESTS_SUITE, "") : testPaths; Map> yamlSuites = loadSuites(paths); List suites = new ArrayList<>(); IllegalArgumentException validationException = null; @@ -283,7 +308,7 @@ public abstract class ESClientYamlSuiteTestCase extends ESRestTestCase { }); } else { path = root.resolve(strPath + ".yml"); - assert Files.exists(path); + assert Files.exists(path) : "Path " + path + " does not exist in YAML test root"; addSuite(root, path, files); } }