2021-02-25 04:34:44 +08:00
import org.elasticsearch.gradle.OS
2020-07-07 22:58:07 +08:00
apply plugin: 'elasticsearch.build'
2020-05-15 09:56:59 +08:00
apply plugin: 'elasticsearch.publish'
2020-03-18 22:08:13 +08:00
apply plugin: 'elasticsearch.rest-resources'
2020-04-22 07:18:18 +08:00
apply plugin: 'elasticsearch.validate-rest-spec'
2021-08-31 14:45:52 +08:00
apply plugin: 'elasticsearch.internal-yaml-rest-test'
2021-02-24 02:15:53 +08:00
apply plugin: 'elasticsearch.yaml-rest-compat-test'
2016-04-13 23:26:47 +08:00
2020-07-07 01:13:01 +08:00
restResources {
restTests {
includeCore '*'
}
}
2020-02-26 08:46:32 +08:00
2021-03-27 07:20:14 +08:00
// REST API specifications are published under the Apache 2.0 License
2021-06-01 17:19:30 +08:00
ext . projectLicenses . set ( [ 'The Apache Software License, Version 2.0' : 'http://www.apache.org/licenses/LICENSE-2.0' ] )
2021-03-27 07:20:14 +08:00
ext . licenseFile = rootProject . file ( 'licenses/APACHE-LICENSE-2.0.txt' )
2021-08-31 14:45:52 +08:00
configurations {
// configuration to make use by external yaml rest test plugin in our examples
// easy and efficient
basicRestSpecs {
attributes {
attribute ( org . gradle . api . internal . artifacts . ArtifactAttributes . ARTIFACT_FORMAT , ArtifactTypeDefinition . DIRECTORY_TYPE )
}
}
}
2020-02-26 08:46:32 +08:00
artifacts {
2021-08-31 14:45:52 +08:00
basicRestSpecs ( new File ( projectDir , "src/main/resources" ) )
2020-02-26 08:46:32 +08:00
restSpecs ( new File ( projectDir , "src/main/resources/rest-api-spec/api" ) )
2021-03-27 07:20:14 +08:00
restTests ( new File ( projectDir , "src/yamlRestTest/resources/rest-api-spec/test" ) )
2020-02-26 08:46:32 +08:00
}
2020-07-07 22:58:07 +08:00
2020-10-13 04:57:29 +08:00
testClusters . all {
module ':modules:mapper-extras'
}
2021-03-27 07:20:14 +08:00
tasks . named ( "test" ) . configure { enabled = false }
tasks . named ( "jarHell" ) . configure { enabled = false }
2021-09-04 00:26:11 +08:00
tasks . named ( "yamlRestTestV7CompatTest" ) . configure {
2021-08-19 16:09:46 +08:00
systemProperty 'tests.rest.blacklist' , [
// Cat API are meant to be consumed by humans, so will not be supported by Compatible REST API
'cat*/*/*' ,
// type information about the type is removed and not passed down. The logic to check for this is also removed.
'delete/70_mix_typeless_typeful/DELETE with typeless API on an index that has types' ,
// WILL NOT BE FIXED - failing due to not recognising missing type (the type path param is ignored)
'get/100_mix_typeless_typeful/GET 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.
'indices.create/20_mix_typeless_typeful/Implicitly create a typed index while there is a typeless template' ,
'indices.create/20_mix_typeless_typeful/Implicitly create a typeless index while there is a typed template' ,
//
// This test returns test_index.mappings:{} when {} was expected. difference between 20_missing_field and 21_missing_field_with_types?
'indices.get_field_mapping/21_missing_field_with_types/Return empty object if field doesn\'t exist, but type and index do' ,
// The information about the type is not present in the index. hence it cannot know if the type exist or not.
'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.
'indices.get_mapping/20_missing_type/Existent and non-existent type returns 404 and the existing type' ,
'indices.get_mapping/20_missing_type/Existent and non-existent types returns 404 and the existing type' ,
'indices.get_mapping/20_missing_type/No type matching pattern returns 404' ,
'indices.get_mapping/20_missing_type/Non-existent type returns 404' ,
'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 was already used or not
'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with _doc on an index that has types' ,
'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with typeless API on an index that has types' ,
// 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
'search/160_exists_query/Test exists query on _type field' ,
//type information is not stored, hence the the index will be found
'termvectors/50_mix_typeless_typeful/Term vectors with typeless API on an index that has types' ,
// mget - these use cases are no longer valid, because we always default to _doc.
// This mean test cases where there is assertion on not finging by type won't work
'mget/11_default_index_type/Default index/type' ,
'mget/16_basic_with_types/Basic multi-get' ,
// asserting about type not found won't work as we ignore the type information
'explain/40_mix_typeless_typeful/Explain with typeless API on an index that has types' ,
// translog settings removal is not supported under compatible api
'indices.stats/20_translog/Translog retention settings are deprecated' ,
'indices.stats/20_translog/Translog retention without soft_deletes' ,
'indices.stats/20_translog/Translog stats on closed indices without soft-deletes' ,
2021-07-14 14:37:38 +08:00
2021-08-19 16:09:46 +08:00
// upgrade api will only get a dummy endpoint returning an exception suggesting to use _reindex
'indices.upgrade/*/*' ,
2021-07-14 14:37:38 +08:00
2021-09-04 00:26:11 +08:00
2021-08-19 16:09:46 +08:00
'search.aggregation/20_terms/*profiler*' , // The profiler results aren't backwards compatible.
'search.aggregation/370_doc_count_field/Test filters agg with doc_count' , // Uses profiler for assertions which is not backwards compatible
2021-07-14 14:37:38 +08:00
2021-08-19 16:09:46 +08:00
'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
2021-07-19 19:21:00 +08:00
2021-08-19 16:09:46 +08:00
'field_caps/30_filter/Field caps with index filter' , //behaviour change after #63692 4digits dates are parsed as epoch and in quotes as year
2021-08-03 21:20:34 +08:00
2021-08-19 16:09:46 +08:00
'indices.forcemerge/10_basic/Check deprecation warning when incompatible only_expunge_deletes and max_num_segments values are both set' , //#44761 bug fix,
2021-08-05 21:14:28 +08:00
2021-08-19 16:09:46 +08:00
'search/340_type_query/type query' , //#47207 type query throws exception in compatible mode
'search.aggregation/200_top_hits_metric/top_hits aggregation with sequence numbers' , // #42809 the use nested path and filter sort throws an exception
'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
] . join ( ',' )
2021-02-24 02:15:53 +08:00
}
2021-03-23 17:59:21 +08:00
2021-09-04 00:26:11 +08:00
tasks . named ( "yamlRestTestV7CompatTransform" ) . configure ( { task - >
2021-05-04 21:56:37 +08:00
task . replaceValueInMatch ( "_type" , "_doc" )
2021-03-23 17:59:21 +08:00
task . addAllowedWarningRegex ( "\\[types removal\\].*" )
2021-05-04 21:56:37 +08:00
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" )
2021-04-08 07:40:53 +08:00
task . removeMatch ( "nodes.\$node_id.roles.10" , "node_info role test" )
2021-04-19 21:21:24 +08:00
task . replaceIsTrue ( "test_index.mappings.type_1" , "test_index.mappings._doc" )
2021-05-10 16:25:48 +08:00
//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" )
2021-06-09 21:19:56 +08:00
// 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" )
2021-06-17 20:21:21 +08:00
//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 )
2021-07-15 16:50:42 +08:00
//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" )
2021-07-26 22:42:38 +08:00
// 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/' )
2021-07-28 20:17:49 +08:00
// 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" )
2021-03-23 17:59:21 +08:00
} )
2021-03-27 07:20:14 +08:00
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'
}