build.gradle 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. import org.elasticsearch.gradle.OS
  2. apply plugin: 'elasticsearch.build'
  3. apply plugin: 'elasticsearch.publish'
  4. apply plugin: 'elasticsearch.rest-resources'
  5. apply plugin: 'elasticsearch.validate-rest-spec'
  6. apply plugin: 'elasticsearch.yaml-rest-test'
  7. apply plugin: 'elasticsearch.yaml-rest-compat-test'
  8. restResources {
  9. restTests {
  10. includeCore '*'
  11. }
  12. }
  13. // REST API specifications are published under the Apache 2.0 License
  14. ext.projectLicenses.set(['The Apache Software License, Version 2.0': 'http://www.apache.org/licenses/LICENSE-2.0'])
  15. ext.licenseFile = rootProject.file('licenses/APACHE-LICENSE-2.0.txt')
  16. artifacts {
  17. restSpecs(new File(projectDir, "src/main/resources/rest-api-spec/api"))
  18. restTests(new File(projectDir, "src/yamlRestTest/resources/rest-api-spec/test"))
  19. }
  20. testClusters.all {
  21. module ':modules:mapper-extras'
  22. }
  23. tasks.named("test").configure { enabled = false }
  24. tasks.named("jarHell").configure { enabled = false }
  25. def v7compatiblityNotSupportedTests = {
  26. return [
  27. // Cat API are meant to be consumed by humans, so will not be supported by Compatible REST API
  28. 'cat*/*/*',
  29. // type information about the type is removed and not passed down. The logic to check for this is also removed.
  30. 'delete/70_mix_typeless_typeful/DELETE with typeless API on an index that has types',
  31. // WILL NOT BE FIXED - failing due to not recognising missing type (the type path param is ignored)
  32. 'get/100_mix_typeless_typeful/GET with typeless API on an index that has types',
  33. // type information about the type is removed and not passed down. The logic to check for this is also removed.
  34. 'indices.create/20_mix_typeless_typeful/Implicitly create a typed index while there is a typeless template',
  35. 'indices.create/20_mix_typeless_typeful/Implicitly create a typeless index while there is a typed template',
  36. //
  37. // This test returns test_index.mappings:{} when {} was expected. difference between 20_missing_field and 21_missing_field_with_types?
  38. 'indices.get_field_mapping/21_missing_field_with_types/Return empty object if field doesn\'t exist, but type and index do',
  39. // The information about the type is not present in the index. hence it cannot know if the type exist or not.
  40. 'indices.get_field_mapping/30_missing_type/Raise 404 when type doesn\'t exist',
  41. // The information about the type is not present in the index. hence it cannot know if the type exist or not.
  42. 'indices.get_mapping/20_missing_type/Existent and non-existent type returns 404 and the existing type',
  43. 'indices.get_mapping/20_missing_type/Existent and non-existent types returns 404 and the existing type',
  44. 'indices.get_mapping/20_missing_type/No type matching pattern returns 404',
  45. 'indices.get_mapping/20_missing_type/Non-existent type returns 404',
  46. 'indices.get_mapping/20_missing_type/Type missing when no types exist',
  47. //
  48. // The information about the type is not present in the index. hence it cannot know if the type was already used or not
  49. 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with _doc on an index that has types',
  50. 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with typeless API on an index that has types',
  51. // there is a small distinction between empty mappings and no mappings at all. The code to implement this test was refactored #54003
  52. // field search on _type field- not implementing. The data for _type is considered incorrect in this search
  53. 'search/160_exists_query/Test exists query on _type field',
  54. //type information is not stored, hence the the index will be found
  55. 'termvectors/50_mix_typeless_typeful/Term vectors with typeless API on an index that has types',
  56. // mget - these use cases are no longer valid, because we always default to _doc.
  57. // This mean test cases where there is assertion on not finging by type won't work
  58. 'mget/11_default_index_type/Default index/type',
  59. 'mget/16_basic_with_types/Basic multi-get',
  60. // asserting about type not found won't work as we ignore the type information
  61. 'explain/40_mix_typeless_typeful/Explain with typeless API on an index that has types',
  62. // translog settings removal is not supported under compatible api
  63. 'indices.stats/20_translog/Translog retention settings are deprecated',
  64. 'indices.stats/20_translog/Translog retention without soft_deletes',
  65. 'indices.stats/20_translog/Translog stats on closed indices without soft-deletes'
  66. ]
  67. }
  68. tasks.named("yamlRestCompatTest").configure {
  69. onlyIf {
  70. // Skip these tests on Windows since the blacklist exceeds Windows CLI limits
  71. OS.current() != OS.WINDOWS
  72. }
  73. systemProperty 'tests.rest.blacklist', ([
  74. 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion and specifying both node_ids and node_names',
  75. 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion without specifying nodes',
  76. 'field_caps/30_filter/Field caps with index filter',
  77. 'indices.create/10_basic/Create index without soft deletes',
  78. 'indices.flush/10_basic/Index synced flush rest test',
  79. 'indices.forcemerge/10_basic/Check deprecation warning when incompatible only_expunge_deletes and max_num_segments values are both set',
  80. 'indices.open/10_basic/?wait_for_active_shards default is deprecated',
  81. 'indices.open/10_basic/?wait_for_active_shards=index-setting',
  82. // not fixing this in #70966
  83. 'indices.put_template/11_basic_with_types/Put template with empty mappings',
  84. 'indices.shrink/30_copy_settings/Copy settings during shrink index',
  85. 'indices.split/30_copy_settings/Copy settings during split index',
  86. 'indices.upgrade/10_basic/Basic test for upgrade indices',
  87. 'indices.upgrade/10_basic/Upgrade indices allow no indices',
  88. 'indices.upgrade/10_basic/Upgrade indices disallow no indices',
  89. 'indices.upgrade/10_basic/Upgrade indices disallow unavailable',
  90. 'indices.upgrade/10_basic/Upgrade indices ignore unavailable',
  91. 'mlt/20_docs/Basic mlt query with docs',
  92. 'mlt/30_unlike/Basic mlt query with unlike',
  93. 'search.aggregation/200_top_hits_metric/top_hits aggregation with sequence numbers',
  94. 'search.aggregation/20_terms/*profiler*', // The profiler results aren't backwards compatible.
  95. 'search.aggregation/51_filter_with_types/Filter aggs with terms lookup and ensure it\'s cached',
  96. 'search.aggregation/370_doc_count_field/Test filters agg with doc_count', // Uses profiler for assertions which is not backwards compatible
  97. 'mtermvectors/11_basic_with_types/Basic tests for multi termvector get',
  98. 'mtermvectors/21_deprecated_with_types/Deprecated camel case and _ parameters should fail in Term Vectors query',
  99. 'mtermvectors/30_mix_typeless_typeful/mtermvectors without types on an index that has types',
  100. 'search/150_rewrite_on_coordinator/Ensure that we fetch the document only once', //terms_lookup
  101. 'search/171_terms_query_with_types/Terms Query with No.of terms exceeding index.max_terms_count should FAIL', //bulk
  102. 'search/260_parameter_validation/test size=-1 is deprecated', //size=-1 change
  103. 'search/310_match_bool_prefix/multi_match multiple fields with cutoff_frequency throws exception', //cutoff_frequency
  104. 'search/340_type_query/type query', // type_query - probably should behave like match_all
  105. 'search_shards/10_basic/Search shards aliases with and without filters',
  106. ] + v7compatiblityNotSupportedTests())
  107. .join(',')
  108. }
  109. tasks.named("transformV7RestTests").configure({ task ->
  110. task.replaceValueInMatch("_type", "_doc")
  111. task.addAllowedWarningRegex("\\[types removal\\].*")
  112. task.replaceValueInMatch("nodes.\$node_id.roles.8", "ml", "node_info role test")
  113. task.replaceValueInMatch("nodes.\$node_id.roles.9", "remote_cluster_client", "node_info role test")
  114. task.removeMatch("nodes.\$node_id.roles.10", "node_info role test")
  115. task.replaceIsTrue("test_index.mappings.type_1", "test_index.mappings._doc")
  116. //override for indices.get and indices.create
  117. //task.replaceIsFalse("test_index.mappings.type_1", "test_index.mappings._doc")
  118. //overrides for indices.create/20_mix_typeless_typeful
  119. task.replaceIsFalse("test-1.mappings._doc","false", "Create a typed index while there is a typeless template")
  120. task.replaceIsFalse("test-1.mappings._doc","false", "Create a typeless index while there is a typed template")
  121. task.replaceIsTrue("test-1.mappings.my_type", "test-1.mappings._doc")
  122. task.replaceIsTrue("test-1.mappings.my_type.properties.foo", "test-1.mappings._doc.properties.foo")
  123. task.replaceIsTrue("test-1.mappings.my_type.properties.bar", "test-1.mappings._doc.properties.bar")
  124. // overrides for indices.get_field_mapping
  125. task.replaceKeyInLength("test_index.mappings.test_type.text.mapping.text.type",
  126. "test_index.mappings._doc.text.mapping.text.type"
  127. )
  128. task.replaceKeyInMatch("test_index.mappings.test_type.text.mapping.text.analyzer",
  129. "test_index.mappings._doc.text.mapping.text.analyzer"
  130. )
  131. task.replaceKeyInMatch("test_index.mappings.test_type.t1.full_name",
  132. "test_index.mappings._doc.t1.full_name"
  133. )
  134. task.replaceKeyInMatch("test_index.mappings.test_type.t2.full_name",
  135. "test_index.mappings._doc.t2.full_name"
  136. )
  137. task.replaceKeyInMatch("test_index.mappings.test_type.obj\\.t1.full_name",
  138. "test_index.mappings._doc.obj\\.t1.full_name"
  139. )
  140. task.replaceKeyInMatch("test_index.mappings.test_type.obj\\.i_t1.full_name",
  141. "test_index.mappings._doc.obj\\.i_t1.full_name"
  142. )
  143. task.replaceKeyInMatch("test_index.mappings.test_type.obj\\.i_t3.full_name",
  144. "test_index.mappings._doc.obj\\.i_t3.full_name"
  145. )
  146. task.replaceKeyInLength("test_index.mappings.test_type",
  147. "test_index.mappings._doc"
  148. )
  149. task.replaceKeyInMatch("test_index_2.mappings.test_type_2.t1.full_name",
  150. "test_index.mappings._doc.t1.full_name"
  151. )
  152. task.replaceKeyInMatch("test_index_2.mappings.test_type_2.t2.full_name",
  153. "test_index.mappings._doc.t2.full_name"
  154. )
  155. task.replaceKeyInLength("test_index_2.mappings.test_type_2",
  156. "test_index.mappings._doc"
  157. )
  158. task.replaceKeyInMatch("test_index.mappings.test_type.text.mapping.text.type",
  159. "test_index.mappings._doc.text.mapping.text.type"
  160. )
  161. // overrides for indices.put_mapping/11_basic_with_types
  162. task.replaceKeyInMatch("test_index.mappings.test_type.properties.text1.type",
  163. "test_index.mappings._doc.properties.text1.type"
  164. )
  165. task.replaceKeyInMatch("test_index.mappings.test_type.properties.text1.analyzer",
  166. "test_index.mappings._doc.properties.text1.analyzer"
  167. )
  168. task.replaceKeyInMatch("test_index.mappings.test_type.properties.text2.type",
  169. "test_index.mappings._doc.properties.text2.type"
  170. )
  171. task.replaceKeyInMatch("test_index.mappings.test_type.properties.text2.analyzer",
  172. "test_index.mappings._doc.properties.text2.analyzer"
  173. )
  174. task.replaceKeyInMatch("test_index.mappings.test_type.properties.subfield.properties.text3.type",
  175. "test_index.mappings._doc.properties.subfield.properties.text3.type"
  176. )
  177. task.replaceKeyInMatch("test_index.mappings.test_type.properties.text1.fields.text_raw.type",
  178. "test_index.mappings._doc.properties.text1.fields.text_raw.type"
  179. )
  180. // overrides for indices.put_mapping/all_path_options_with_types
  181. task.replaceKeyInMatch("test_index1.mappings.test_type.properties.text.type",
  182. "test_index1.mappings._doc.properties.text.type"
  183. )
  184. task.replaceKeyInMatch("test_index1.mappings.test_type.properties.text.analyzer",
  185. "test_index1.mappings._doc.properties.text.analyzer"
  186. )
  187. task.replaceKeyInMatch("test_index2.mappings.test_type.properties.text.type",
  188. "test_index2.mappings._doc.properties.text.type"
  189. )
  190. task.replaceKeyInMatch("test_index2.mappings.test_type.properties.text.analyzer",
  191. "test_index2.mappings._doc.properties.text.analyzer"
  192. )
  193. task.replaceKeyInMatch("foo.mappings.test_type.properties.text.type",
  194. "foo.mappings._doc.properties.text.type"
  195. )
  196. task.replaceKeyInMatch("foo.mappings.test_type.properties.text.analyzer",
  197. "foo.mappings._doc.properties.text.analyzer"
  198. )
  199. // overrides for indices.get_mapping
  200. task.replaceIsTrue("test_1.mappings.doc", "test_1.mappings._doc")
  201. task.replaceIsTrue("test_2.mappings.doc", "test_2.mappings._doc")
  202. // overrides for mget
  203. task.replaceValueInMatch("docs.0._type", "_doc" , "Basic multi-get") // index found, but no doc
  204. task.replaceValueInMatch("docs.0._type", "_doc", "Default index/type")
  205. task.replaceValueInMatch("docs.0._type", "_doc", "Non-existent index")
  206. task.replaceValueInMatch("docs.0._type", "_doc", "Missing metadata")
  207. task.replaceValueInMatch("docs.0._type", "_doc", "Multi Get with alias that resolves to multiple indices")
  208. task.replaceValueInMatch("docs.1._type", "_doc", "Multi Get with alias that resolves to multiple indices")
  209. task.replaceValueInMatch("docs.2._type", "_doc", "Multi Get with alias that resolves to multiple indices")
  210. task.replaceValueInMatch("docs.0._type", "_doc", "IDs")
  211. task.replaceValueInMatch("docs.1._type", "_doc", "IDs")
  212. task.replaceValueInMatch("docs.2._type", "_doc", "Routing")
  213. //overrides for indices.stats
  214. //TODO fix to remove the below match
  215. task.replaceKeyInMatch("_all.primaries.indexing.types.baz.index_total",
  216. "_all.primaries.indexing.types._doc.index_total"
  217. )
  218. task.replaceKeyInMatch("_all.primaries.indexing.types.bar.index_total",
  219. "_all.primaries.indexing.types._doc.index_total"
  220. )
  221. task.replaceValueInMatch("_all.primaries.indexing.types._doc.index_total", 2)
  222. })
  223. tasks.register('enforceYamlTestConvention').configure {
  224. doLast {
  225. if (fileTree('src/main/resources/rest-api-spec/test').files) {
  226. throw new GradleException("There are YAML tests in src/main source set. These should be moved to src/yamlRestTest.")
  227. }
  228. }
  229. }
  230. tasks.named("precommit").configure {
  231. dependsOn 'enforceYamlTestConvention'
  232. }