elasticsearch/rest-api-spec/build.gradle

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

240 lines
16 KiB
Groovy
Raw Normal View History

apply plugin: 'elasticsearch.build'
apply plugin: 'elasticsearch.publish'
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.validate-rest-spec'
apply plugin: 'elasticsearch.internal-yaml-rest-test'
apply plugin: 'elasticsearch.yaml-rest-compat-test'
apply plugin: 'elasticsearch.internal-test-artifact'
Create plugin for yamlTest task (#56841) This commit creates a new Gradle plugin to provide a separate task name and source set for running YAML based REST tests. The only project converted to use the new plugin in this PR is distribution/archives/integ-test-zip. For which the testing has been moved to :rest-api-spec since it makes the most sense and it avoids a small but awkward change to the distribution plugin. The remaining cases in modules, plugins, and x-pack will be handled in followups. This plugin is distinctly different from the plugin introduced in #55896 since the YAML REST tests are intended to be black box tests over HTTP. As such they should not (by default) have access to the classpath for that which they are testing. The YAML based REST tests will be moved to separate source sets (yamlRestTest). The which source is the target for the test resources is dependent on if this new plugin is applied. If it is not applied, it will default to the test source set. Further, this introduces a breaking change for plugin developers that use the YAML testing framework. They will now need to either use the new source set and matching task, or configure the rest resources to use the old "test" source set that matches the old integTest task. (The former should be preferred). As part of this change (which is also breaking for plugin developers) the rest resources plugin has been removed from the build plugin and now requires either explicit application or application via the new YAML REST test plugin. Plugin developers should be able to fix the breaking changes to the YAML tests by adding apply plugin: 'elasticsearch.yaml-rest-test' and moving the YAML tests under a yamlRestTest folder (instead of test)
2020-07-07 01:13:01 +08:00
restResources {
restTests {
includeCore '*'
}
}
Smarter copying of the rest specs and tests (#52114) This PR addresses the unnecessary copying of the rest specs and allows for better semantics for which specs and tests are copied. By default the rest specs will get copied if the project applies `elasticsearch.standalone-rest-test` or `esplugin` and the project has rest tests or you configure the custom extension `restResources`. This PR also removes the need for dozens of places where the x-pack specs were copied by supporting copying of the x-pack rest specs too. The plugin/task introduced here can also copy the rest tests to the local project through a similar configuration. The new plugin/task allows a user to minimize the surface area of which rest specs are copied. Per project can be configured to include only a subset of the specs (or tests). Configuring a project to only copy the specs when actually needed should help with build cache hit rates since we can better define what is actually in use. However, project level optimizations for build cache hit rates are not included with this PR. Also, with this PR you can no longer use the includePackaged flag on integTest task. The following items are included in this PR: * new plugin: `elasticsearch.rest-resources` * new tasks: CopyRestApiTask and CopyRestTestsTask - performs the copy * new extension 'restResources' ``` restResources { restApi { includeCore 'foo' , 'bar' //will include the core specs that start with foo and bar includeXpack 'baz' //will include x-pack specs that start with baz } restTests { includeCore 'foo', 'bar' //will include the core tests that start with foo and bar includeXpack 'baz' //will include the x-pack tests that start with baz } } ```
2020-02-26 08:46:32 +08:00
// REST API specifications are published under the Apache 2.0 License
ext.projectLicenses.set(['The Apache Software License, Version 2.0': 'http://www.apache.org/licenses/LICENSE-2.0'])
licenseFile.set(rootProject.file('licenses/APACHE-LICENSE-2.0.txt'))
configurations {
// configuration to make use by external yaml rest test plugin in our examples
// easy and efficient
basicRestSpecs {
attributes {
attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE)
}
}
}
Smarter copying of the rest specs and tests (#52114) This PR addresses the unnecessary copying of the rest specs and allows for better semantics for which specs and tests are copied. By default the rest specs will get copied if the project applies `elasticsearch.standalone-rest-test` or `esplugin` and the project has rest tests or you configure the custom extension `restResources`. This PR also removes the need for dozens of places where the x-pack specs were copied by supporting copying of the x-pack rest specs too. The plugin/task introduced here can also copy the rest tests to the local project through a similar configuration. The new plugin/task allows a user to minimize the surface area of which rest specs are copied. Per project can be configured to include only a subset of the specs (or tests). Configuring a project to only copy the specs when actually needed should help with build cache hit rates since we can better define what is actually in use. However, project level optimizations for build cache hit rates are not included with this PR. Also, with this PR you can no longer use the includePackaged flag on integTest task. The following items are included in this PR: * new plugin: `elasticsearch.rest-resources` * new tasks: CopyRestApiTask and CopyRestTestsTask - performs the copy * new extension 'restResources' ``` restResources { restApi { includeCore 'foo' , 'bar' //will include the core specs that start with foo and bar includeXpack 'baz' //will include x-pack specs that start with baz } restTests { includeCore 'foo', 'bar' //will include the core tests that start with foo and bar includeXpack 'baz' //will include the x-pack tests that start with baz } } ```
2020-02-26 08:46:32 +08:00
artifacts {
basicRestSpecs(new File(projectDir, "src/main/resources"))
Smarter copying of the rest specs and tests (#52114) This PR addresses the unnecessary copying of the rest specs and allows for better semantics for which specs and tests are copied. By default the rest specs will get copied if the project applies `elasticsearch.standalone-rest-test` or `esplugin` and the project has rest tests or you configure the custom extension `restResources`. This PR also removes the need for dozens of places where the x-pack specs were copied by supporting copying of the x-pack rest specs too. The plugin/task introduced here can also copy the rest tests to the local project through a similar configuration. The new plugin/task allows a user to minimize the surface area of which rest specs are copied. Per project can be configured to include only a subset of the specs (or tests). Configuring a project to only copy the specs when actually needed should help with build cache hit rates since we can better define what is actually in use. However, project level optimizations for build cache hit rates are not included with this PR. Also, with this PR you can no longer use the includePackaged flag on integTest task. The following items are included in this PR: * new plugin: `elasticsearch.rest-resources` * new tasks: CopyRestApiTask and CopyRestTestsTask - performs the copy * new extension 'restResources' ``` restResources { restApi { includeCore 'foo' , 'bar' //will include the core specs that start with foo and bar includeXpack 'baz' //will include x-pack specs that start with baz } restTests { includeCore 'foo', 'bar' //will include the core tests that start with foo and bar includeXpack 'baz' //will include the x-pack tests that start with baz } } ```
2020-02-26 08:46:32 +08:00
restSpecs(new File(projectDir, "src/main/resources/rest-api-spec/api"))
restTests(new File(projectDir, "src/yamlRestTest/resources/rest-api-spec/test"))
Smarter copying of the rest specs and tests (#52114) This PR addresses the unnecessary copying of the rest specs and allows for better semantics for which specs and tests are copied. By default the rest specs will get copied if the project applies `elasticsearch.standalone-rest-test` or `esplugin` and the project has rest tests or you configure the custom extension `restResources`. This PR also removes the need for dozens of places where the x-pack specs were copied by supporting copying of the x-pack rest specs too. The plugin/task introduced here can also copy the rest tests to the local project through a similar configuration. The new plugin/task allows a user to minimize the surface area of which rest specs are copied. Per project can be configured to include only a subset of the specs (or tests). Configuring a project to only copy the specs when actually needed should help with build cache hit rates since we can better define what is actually in use. However, project level optimizations for build cache hit rates are not included with this PR. Also, with this PR you can no longer use the includePackaged flag on integTest task. The following items are included in this PR: * new plugin: `elasticsearch.rest-resources` * new tasks: CopyRestApiTask and CopyRestTestsTask - performs the copy * new extension 'restResources' ``` restResources { restApi { includeCore 'foo' , 'bar' //will include the core specs that start with foo and bar includeXpack 'baz' //will include x-pack specs that start with baz } restTests { includeCore 'foo', 'bar' //will include the core tests that start with foo and bar includeXpack 'baz' //will include the x-pack tests that start with baz } } ```
2020-02-26 08:46:32 +08:00
}
dependencies {
clusterModules project(":modules:mapper-extras")
clusterModules project(":modules:rest-root")
clusterModules project(":modules:reindex")
clusterModules project(':modules:analysis-common')
}
tasks.named("yamlRestTestV7CompatTransform").configure { task ->
task.skipTestsByFilePattern("**/cat*/*.yml", "Cat API are meant to be consumed by humans, so will not be supported by Compatible REST API")
task.skipTestsByFilePattern("**/indices.upgrade/*.yml", "upgrade api will only get a dummy endpoint returning an exception suggesting to use _reindex")
task.skipTestsByFilePattern("**/indices.stats/60_field_usage/*/*.yml", "field usage results will be different between lucene versions")
task.skipTestsByFilePattern("**/search.aggregation/*.yml", "run by the aggregation module")
task.skipTest("bulk/11_dynamic_templates/Dynamic templates", "Error message has changed")
task.skipTest("index/80_date_nanos/date_nanos requires dates after 1970 and before 2262", "Error message has changed")
task.skipTest("indices.create/20_mix_typeless_typeful/Implicitly create a typed index while there is a typeless template", "Type information about the type is removed and not passed down. The logic to check for this is also removed.")
task.skipTest("indices.create/20_mix_typeless_typeful/Implicitly create a typeless index while there is a typed template", "Type information about the type is removed and not passed down. The logic to check for this is also removed.")
task.skipTest("delete/70_mix_typeless_typeful/DELETE with typeless API on an index that has types", "Type information about the type is removed and not passed down. The logic to check for this is also removed.");
task.skipTest("get/100_mix_typeless_typeful/GET with typeless API on an index that has types", "Failing due to not recognising missing type (the type path param is ignored, will no be fixed");
task.skipTest("indices.get_field_mapping/21_missing_field_with_types/Return empty object if field doesn't exist, but type and index do", "This test returns test_index.mappings:{} when {} was expected. difference between 20_missing_field and 21_missing_field_with_types?")
task.skipTest("indices.get_field_mapping/30_missing_type/Raise 404 when type doesn't exist", "The information about the type is not present in the index. hence it cannot know if the type exist or not.")
task.skipTest("indices.get_mapping/20_missing_type/Existent and non-existent type returns 404 and the existing type", " The information about the type is not present in the index. hence it cannot know if the type exist or not")
task.skipTest("indices.get_mapping/20_missing_type/Existent and non-existent types returns 404 and the existing type", "The information about the type is not present in the index. hence it cannot know if the type exist or not.")
task.skipTest("indices.get_mapping/20_missing_type/No type matching pattern returns 404", "The information about the type is not present in the index. hence it cannot know if the type exist or not.")
task.skipTest("indices.get_mapping/20_missing_type/Non-existent type returns 404", "The information about the type is not present in the index. hence it cannot know if the type exist or not.")
task.skipTest("indices.get_mapping/20_missing_type/Type missing when no types exist", "The information about the type is not present in the index. hence it cannot know if the type exist or not.")
task.skipTest("indices.put_mapping/20_mix_typeless_typeful/PUT mapping with _doc on an index that has types", "The information about the type is not present in the index. hence it cannot know if the type was already used or not")
task.skipTest("indices.put_mapping/20_mix_typeless_typeful/PUT mapping with typeless API on an index that has types", "The information about the type is not present in the index. hence it cannot know if the type was already used or not")
task.skipTest("search/160_exists_query/Test exists query on _type field", "There is a small distinction between empty mappings and no mappings at all. The code to implement this test was refactored #54003; field search on _type field- not implementing. The data for _type is considered incorrect in this search")
task.skipTest("termvectors/50_mix_typeless_typeful/Term vectors with typeless API on an index that has types", "type information is not stored, hence the the index will be found")
task.skipTest("mget/11_default_index_type/Default index/type", "mget - these use cases are no longer valid because we always default to _doc.; This mean test cases where there is assertion on not finding by type won't work")
task.skipTest("mget/16_basic_with_types/Basic multi-get", "mget - these use cases are no longer valid, because we always default to _doc.; This mean test cases where there is assertion on not finding by type won't work")
task.skipTest("explain/40_mix_typeless_typeful/Explain with typeless API on an index that has types", "asserting about type not found won't work as we ignore the type information")
task.skipTest("indices.stats/20_translog/Translog retention settings are deprecated", "translog settings removal is not supported under compatible api")
task.skipTest("indices.stats/20_translog/Translog retention without soft_deletes", "translog settings removal is not supported under compatible api")
task.skipTest("indices.stats/20_translog/Translog stats on closed indices without soft-deletes", "translog settings removal is not supported under compatible api")
task.skipTest("indices.create/10_basic/Create index without soft deletes", "Make soft-deletes mandatory in 8.0 #51122 - settings changes are note supported in Rest Api compatibility")
task.skipTest("field_caps/30_filter/Field caps with index filter", "behaviour change after #63692 4digits dates are parsed as epoch and in quotes as year")
task.skipTest("indices.forcemerge/10_basic/Check deprecation warning when incompatible only_expunge_deletes and max_num_segments values are both set", "#44761 bug fix")
task.skipTest("search/340_type_query/type query", "#47207 type query throws exception in compatible mode")
task.skipTest("search/310_match_bool_prefix/multi_match multiple fields with cutoff_frequency throws exception", "#42654 cutoff_frequency, common terms are not supported. Throwing an exception")
task.skipTest("search_shards/10_basic/Search shards aliases with and without filters", "Filter representation no longer outputs default boosts")
task.skipTest("migration/10_get_feature_upgrade_status/Get feature upgrade status", "Awaits backport")
task.skipTest("search/330_fetch_fields/Test disable source", "Error no longer thrown")
task.skipTest("search/370_profile/fetch fields", "profile output has changed")
task.skipTest("search/370_profile/fetch source", "profile output has changed")
task.skipTest("search/370_profile/fetch nested source", "profile output has changed")
task.skipTest("search/240_date_nanos/doc value fields are working as expected across date and date_nanos fields", "Fetching docvalues field multiple times is no longer allowed")
task.replaceValueInMatch("_type", "_doc")
task.addAllowedWarningRegex("\\[types removal\\].*")
task.replaceValueInMatch("nodes.\$node_id.roles.8", "ml", "node_info role test")
task.replaceValueInMatch("nodes.\$node_id.roles.9", "remote_cluster_client", "node_info role test")
task.removeMatch("nodes.\$node_id.roles.10", "node_info role test")
task.replaceIsTrue("test_index.mappings.type_1", "test_index.mappings._doc")
//override for indices.get and indices.create
//task.replaceIsFalse("test_index.mappings.type_1", "test_index.mappings._doc")
//overrides for indices.create/20_mix_typeless_typeful
task.replaceIsFalse("test-1.mappings._doc","false", "Create a typed index while there is a typeless template")
task.replaceIsFalse("test-1.mappings._doc","false", "Create a typeless index while there is a typed template")
task.replaceIsTrue("test-1.mappings.my_type", "test-1.mappings._doc")
task.replaceIsTrue("test-1.mappings.my_type.properties.foo", "test-1.mappings._doc.properties.foo")
task.replaceIsTrue("test-1.mappings.my_type.properties.bar", "test-1.mappings._doc.properties.bar")
// overrides for indices.get_field_mapping
task.replaceKeyInLength("test_index.mappings.test_type.text.mapping.text.type",
"test_index.mappings._doc.text.mapping.text.type"
)
task.replaceKeyInMatch("test_index.mappings.test_type.text.mapping.text.analyzer",
"test_index.mappings._doc.text.mapping.text.analyzer"
)
task.replaceKeyInMatch("test_index.mappings.test_type.t1.full_name",
"test_index.mappings._doc.t1.full_name"
)
task.replaceKeyInMatch("test_index.mappings.test_type.t2.full_name",
"test_index.mappings._doc.t2.full_name"
)
task.replaceKeyInMatch("test_index.mappings.test_type.obj\\.t1.full_name",
"test_index.mappings._doc.obj\\.t1.full_name"
)
task.replaceKeyInMatch("test_index.mappings.test_type.obj\\.i_t1.full_name",
"test_index.mappings._doc.obj\\.i_t1.full_name"
)
task.replaceKeyInMatch("test_index.mappings.test_type.obj\\.i_t3.full_name",
"test_index.mappings._doc.obj\\.i_t3.full_name"
)
task.replaceKeyInLength("test_index.mappings.test_type",
"test_index.mappings._doc"
)
task.replaceKeyInMatch("test_index_2.mappings.test_type_2.t1.full_name",
"test_index.mappings._doc.t1.full_name"
)
task.replaceKeyInMatch("test_index_2.mappings.test_type_2.t2.full_name",
"test_index.mappings._doc.t2.full_name"
)
task.replaceKeyInLength("test_index_2.mappings.test_type_2",
"test_index.mappings._doc"
)
task.replaceKeyInMatch("test_index.mappings.test_type.text.mapping.text.type",
"test_index.mappings._doc.text.mapping.text.type"
)
// overrides for indices.put_mapping/11_basic_with_types
task.replaceKeyInMatch("test_index.mappings.test_type.properties.text1.type",
"test_index.mappings._doc.properties.text1.type"
)
task.replaceKeyInMatch("test_index.mappings.test_type.properties.text1.analyzer",
"test_index.mappings._doc.properties.text1.analyzer"
)
task.replaceKeyInMatch("test_index.mappings.test_type.properties.text2.type",
"test_index.mappings._doc.properties.text2.type"
)
task.replaceKeyInMatch("test_index.mappings.test_type.properties.text2.analyzer",
"test_index.mappings._doc.properties.text2.analyzer"
)
task.replaceKeyInMatch("test_index.mappings.test_type.properties.subfield.properties.text3.type",
"test_index.mappings._doc.properties.subfield.properties.text3.type"
)
task.replaceKeyInMatch("test_index.mappings.test_type.properties.text1.fields.text_raw.type",
"test_index.mappings._doc.properties.text1.fields.text_raw.type"
)
// overrides for indices.put_mapping/all_path_options_with_types
task.replaceKeyInMatch("test_index1.mappings.test_type.properties.text.type",
"test_index1.mappings._doc.properties.text.type"
)
task.replaceKeyInMatch("test_index1.mappings.test_type.properties.text.analyzer",
"test_index1.mappings._doc.properties.text.analyzer"
)
task.replaceKeyInMatch("test_index2.mappings.test_type.properties.text.type",
"test_index2.mappings._doc.properties.text.type"
)
task.replaceKeyInMatch("test_index2.mappings.test_type.properties.text.analyzer",
"test_index2.mappings._doc.properties.text.analyzer"
)
task.replaceKeyInMatch("foo.mappings.test_type.properties.text.type",
"foo.mappings._doc.properties.text.type"
)
task.replaceKeyInMatch("foo.mappings.test_type.properties.text.analyzer",
"foo.mappings._doc.properties.text.analyzer"
)
// overrides for indices.get_mapping
task.replaceIsTrue("test_1.mappings.doc", "test_1.mappings._doc")
task.replaceIsTrue("test_2.mappings.doc", "test_2.mappings._doc")
// overrides for mget
task.replaceValueInMatch("docs.0._type", "_doc" , "Basic multi-get") // index found, but no doc
task.replaceValueInMatch("docs.0._type", "_doc", "Default index/type")
task.replaceValueInMatch("docs.0._type", "_doc", "Non-existent index")
task.replaceValueInMatch("docs.0._type", "_doc", "Missing metadata")
task.replaceValueInMatch("docs.0._type", "_doc", "Multi Get with alias that resolves to multiple indices")
task.replaceValueInMatch("docs.1._type", "_doc", "Multi Get with alias that resolves to multiple indices")
task.replaceValueInMatch("docs.2._type", "_doc", "Multi Get with alias that resolves to multiple indices")
task.replaceValueInMatch("docs.0._type", "_doc", "IDs")
task.replaceValueInMatch("docs.1._type", "_doc", "IDs")
task.replaceValueInMatch("docs.2._type", "_doc", "Routing")
//overrides for indices.stats
//TODO fix to remove the below match
task.replaceKeyInMatch("_all.primaries.indexing.types.baz.index_total",
"_all.primaries.indexing.types._doc.index_total"
)
task.replaceKeyInMatch("_all.primaries.indexing.types.bar.index_total",
"_all.primaries.indexing.types._doc.index_total"
)
task.replaceValueInMatch("_all.primaries.indexing.types._doc.index_total", 2)
// points get touched by sorting in ES 8
task.replaceValueInMatch("testindex.shards.0.stats.fields.price.points", 1)
//override for "indices.open/10_basic/?wait_for_active_shards default is deprecated" and "indices.open/10_basic/?wait_for_active_shards=index-setting"
task.addAllowedWarningRegexForTest("\\?wait_for_active_shards=index-setting is now the default behaviour.*", "?wait_for_active_shards=index-setting")
task.removeWarningForTest("the default value for the ?wait_for_active_shards parameter will change from '0' to 'index-setting' in version 8; " +
"specify '?wait_for_active_shards=index-setting' to adopt the future default behaviour, or '?wait_for_active_shards=0' to preserve today's behaviour"
, "?wait_for_active_shards default is deprecated")
// override for exception message change in #55291 tests cluster.voting_config_exclusions/10_basic/
// 'Throw exception when adding voting config exclusion and specifying both node_ids and node_names',
// 'Throw exception when adding voting config exclusion without specifying nodes',
task.replaceValueTextByKeyValue("catch",
'/Please set node identifiers correctly. One and only one of \\[node_name\\], \\[node_names\\] and \\[node_ids\\] has to be set/',
'/You must set \\[node_names\\] or \\[node_ids\\] but not both/')
// sync_id is no longer available in SegmentInfos.userData // "indices.flush/10_basic/Index synced flush rest test"
task.replaceIsTrue("indices.testing.shards.0.0.commit.user_data.sync_id", "indices.testing.shards.0.0.commit.user_data")
// we can now search using doc values only
task.replaceValueInMatch("fields.object\\.nested1.long.searchable", true)
//client.type no longer exists #101214
task.replaceKeyInMatch("nodes.\$node_id.settings.client.type", "nodes.\$node_id.settings.node.attr.testattr")
task.replaceValueInMatch("nodes.\$node_id.settings.node.attr.testattr", "test")
task.replaceKeyInMatch("nodes.\$node_id.settings.client\\.type", "nodes.\$node_id.settings.node\\.attr\\.testattr")
task.replaceValueInMatch("nodes.\$node_id.settings.node\\.attr\\.testattr", "test")
}
tasks.register('enforceYamlTestConvention').configure {
doLast {
if (fileTree('src/main/resources/rest-api-spec/test').files) {
throw new GradleException("There are YAML tests in src/main source set. These should be moved to src/yamlRestTest.")
}
}
}
tasks.named("precommit").configure {
dependsOn 'enforceYamlTestConvention'
}