Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class RepositoryS3ClientYamlTestSuiteIT extends AbstractRepositoryS3Clien

@ParametersFactory
public static Iterable<Object[]> parameters() throws Exception {
return createParameters(new String[] { "repository_s3/10_basic", "repository_s3/20_repository_permanent_credentials" });
return createParameters("repository_s3/10_basic", "repository_s3/20_repository_permanent_credentials");
}

public RepositoryS3ClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static Iterable<Object[]> parameters() throws Exception {
// Run just the basic sanity test to make sure ES starts up and loads the S3 repository with a regional endpoint without an error.
// It would be great to make actual requests against a test fixture, but setting the region means using a production endpoint.
// See #102230 for more details.
return createParameters(new String[] { "repository_s3/10_basic" });
return createParameters("repository_s3/10_basic");
}

public RepositoryS3RegionalStsClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ protected String getTestRestCluster() {

@ParametersFactory
public static Iterable<Object[]> parameters() throws Exception {
return createParameters(new String[] { "hdfs_repository" }, Map.of("hdfs_port", hdfsFixture.getPort()));
return createParameters(Map.of("hdfs_port", hdfsFixture.getPort()), "hdfs_repository");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ protected String getTestRestCluster() {

@ParametersFactory
public static Iterable<Object[]> parameters() throws Exception {
return createParameters(new String[] { "secure_hdfs_repository" }, Map.of("secure_hdfs_port", hdfsFixture.getPort()));
return createParameters(Map.of("secure_hdfs_port", hdfsFixture.getPort()), "secure_hdfs_repository");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@
/**
* Runs a suite of yaml tests shared with all the official Elasticsearch
* clients against an elasticsearch cluster.
*
* <p>
* The suite timeout is extended to account for projects with a large number of tests.
* </p>
*/
@TimeoutSuite(millis = 30 * TimeUnits.MINUTE)
public abstract class ESClientYamlSuiteTestCase extends ESRestTestCase {
Expand Down Expand Up @@ -91,11 +92,11 @@ public abstract class ESClientYamlSuiteTestCase extends ESRestTestCase {
/**
* This separator pattern matches ',' except it is preceded by a '\'.
* This allows us to support ',' within paths when it is escaped with a slash.
*
* <p>
* For example, the path string "/a/b/c\,d/e/f,/foo/bar,/baz" is separated to "/a/b/c\,d/e/f", "/foo/bar" and "/baz".
*
* </p><p>
* For reference, this regular expression feature is known as zero-width negative look-behind.
*
* </p>
*/
private static final String PATHS_SEPARATOR = "(?<!\\\\),";

Expand Down Expand Up @@ -226,57 +227,74 @@ public static Iterable<Object[]> createParameters() throws Exception {
* Create parameters for this parameterized test.
*/
public static Iterable<Object[]> createParameters(NamedXContentRegistry executeableSectionRegistry) throws Exception {
return createParameters(executeableSectionRegistry, null);
return createParameters(executeableSectionRegistry, Map.of(), resolvePathsProperty(REST_TESTS_SUITE, ""));
}

/**
* Create parameters for this parameterized test.
* @param yamlParameters map or parameters used within the yaml specs to be replaced at parsing time.
*/
public static Iterable<Object[]> createParameters(String[] testPaths, Map<String, Object> yamlParameters) throws Exception {
return createParameters(ExecutableSection.XCONTENT_REGISTRY, testPaths, yamlParameters);
public static Iterable<Object[]> createParameters(Map<String, Object> yamlParameters) throws Exception {
return createParameters(ExecutableSection.XCONTENT_REGISTRY, yamlParameters, resolvePathsProperty(REST_TESTS_SUITE, ""));
}

/**
* Create parameters for this parameterized test.
* @param yamlParameters map or parameters used within the yaml specs to be replaced at parsing time.
* @param testPaths list of paths to explicitly search for tests.
*/
public static Iterable<Object[]> createParameters(String[] testPaths) throws Exception {
return createParameters(testPaths, Collections.emptyMap());
public static Iterable<Object[]> createParameters(Map<String, Object> yamlParameters, String... testPaths) throws Exception {
if (System.getProperty(REST_TESTS_SUITE) != null) {
throw new IllegalArgumentException("The '" + REST_TESTS_SUITE + "' system property is not supported with explicit test paths.");
}
return createParameters(ExecutableSection.XCONTENT_REGISTRY, yamlParameters, testPaths);
}

/**
* Create parameters for this parameterized test.
* @param testPaths list of paths to explicitly search for tests.
*/
public static Iterable<Object[]> createParameters(String... testPaths) throws Exception {
if (System.getProperty(REST_TESTS_SUITE) != null) {
throw new IllegalArgumentException("The '" + REST_TESTS_SUITE + "' system property is not supported with explicit test paths.");
}
return createParameters(ExecutableSection.XCONTENT_REGISTRY, Map.of(), testPaths);
}

/**
* Create parameters for this parameterized test.
*
* @param executeableSectionRegistry registry of executable sections
* @param testPaths list of paths to explicitly search for tests. If <code>null</code> then include all tests in root path.
* @param testPaths list of paths to explicitly search for tests.
* @return list of test candidates.
* @throws Exception
*/
public static Iterable<Object[]> createParameters(NamedXContentRegistry executeableSectionRegistry, String[] testPaths)
public static Iterable<Object[]> createParameters(NamedXContentRegistry executeableSectionRegistry, String... testPaths)
throws Exception {
return createParameters(executeableSectionRegistry, testPaths, Collections.emptyMap());
if (System.getProperty(REST_TESTS_SUITE) != null) {
throw new IllegalArgumentException("The '" + REST_TESTS_SUITE + "' system property is not supported with explicit test paths.");
}
return createParameters(executeableSectionRegistry, Map.of(), testPaths);
}

/**
* Create parameters for this parameterized test.
*
* @param executeableSectionRegistry registry of executable sections
* @param testPaths list of paths to explicitly search for tests. If <code>null</code> then include all tests in root path.
* @param yamlParameters map or parameters used within the yaml specs to be replaced at parsing time.
* @param yamlParameters map or parameters used within the yaml specs to be replaced at parsing time.
* @param testPaths list of paths to explicitly search for tests. If {@code null} then include all tests in root path.
* @return list of test candidates.
* @throws Exception
*/
public static Iterable<Object[]> createParameters(
NamedXContentRegistry executeableSectionRegistry,
String[] testPaths,
Map<String, ?> yamlParameters
Map<String, ?> yamlParameters,
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.");

if (testPaths == null) {
throw new IllegalArgumentException("testPaths cannot be null");
}

// default to all tests under the test root
String[] paths = testPaths == null ? resolvePathsProperty(REST_TESTS_SUITE, "") : testPaths;
Map<String, Set<Path>> yamlSuites = loadSuites(paths);
Map<String, Set<Path>> yamlSuites = loadSuites(testPaths);
List<ClientYamlTestSuite> suites = new ArrayList<>();
IllegalArgumentException validationException = null;
// yaml suites are grouped by directory (effectively by api)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public DownsampleRestIT(final ClientYamlTestCandidate testCandidate) {

@ParametersFactory
public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters(new String[] { "downsample" });
return ESClientYamlSuiteTestCase.createParameters("downsample");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public DownsampleWithBasicRestIT(final ClientYamlTestCandidate testCandidate) {

@ParametersFactory
public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters(new String[] { "downsample" });
return ESClientYamlSuiteTestCase.createParameters("downsample");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ protected Settings restClientSettings() {

@ParametersFactory
public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters(new String[] { "downsample-with-security" });
return ESClientYamlSuiteTestCase.createParameters("downsample-with-security");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public LicenseClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCa

@ParametersFactory
public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters(new String[] { "license" });
return ESClientYamlSuiteTestCase.createParameters("license");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public LinearRankClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate tes

@ParametersFactory
public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters(new String[] { "linear" });
return ESClientYamlSuiteTestCase.createParameters("linear");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public RRFRankClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCa

@ParametersFactory
public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters(new String[] { "rrf" });
return ESClientYamlSuiteTestCase.createParameters("rrf");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public SearchBusinessRulesClientYamlTestSuiteIT(final ClientYamlTestCandidate te

@ParametersFactory
public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters(new String[] { "search-business-rules/10_pinned_retriever" });
return ESClientYamlSuiteTestCase.createParameters("search-business-rules/10_pinned_retriever");
}

@Override
Expand Down