build.gradle 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. /*
  2. * Licensed to Elasticsearch under one or more contributor
  3. * license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright
  5. * ownership. Elasticsearch licenses this file to you under
  6. * the Apache License, Version 2.0 (the "License"); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. apply plugin: 'elasticsearch.docs-test'
  20. /* List of files that have snippets that probably should be converted to
  21. * `// CONSOLE` and `// TESTRESPONSE` but have yet to be converted. Try and
  22. * only remove entries from this list. When it is empty we'll remove it
  23. * entirely and have a party! There will be cake and everything.... */
  24. buildRestTests.expectedUnconvertedCandidates = [
  25. 'reference/aggregations/bucket/datehistogram-aggregation.asciidoc',
  26. 'reference/aggregations/bucket/daterange-aggregation.asciidoc',
  27. 'reference/aggregations/bucket/diversified-sampler-aggregation.asciidoc',
  28. 'reference/aggregations/bucket/filter-aggregation.asciidoc',
  29. 'reference/aggregations/bucket/filters-aggregation.asciidoc',
  30. 'reference/aggregations/bucket/geodistance-aggregation.asciidoc',
  31. 'reference/aggregations/bucket/geohashgrid-aggregation.asciidoc',
  32. 'reference/aggregations/bucket/global-aggregation.asciidoc',
  33. 'reference/aggregations/bucket/histogram-aggregation.asciidoc',
  34. 'reference/aggregations/bucket/iprange-aggregation.asciidoc',
  35. 'reference/aggregations/bucket/missing-aggregation.asciidoc',
  36. 'reference/aggregations/bucket/nested-aggregation.asciidoc',
  37. 'reference/aggregations/bucket/range-aggregation.asciidoc',
  38. 'reference/aggregations/bucket/reverse-nested-aggregation.asciidoc',
  39. 'reference/aggregations/bucket/sampler-aggregation.asciidoc',
  40. 'reference/aggregations/bucket/significantterms-aggregation.asciidoc',
  41. 'reference/aggregations/bucket/terms-aggregation.asciidoc',
  42. 'reference/aggregations/matrix/stats-aggregation.asciidoc',
  43. 'reference/aggregations/metrics/avg-aggregation.asciidoc',
  44. 'reference/aggregations/metrics/cardinality-aggregation.asciidoc',
  45. 'reference/aggregations/metrics/extendedstats-aggregation.asciidoc',
  46. 'reference/aggregations/metrics/geobounds-aggregation.asciidoc',
  47. 'reference/aggregations/metrics/geocentroid-aggregation.asciidoc',
  48. 'reference/aggregations/metrics/max-aggregation.asciidoc',
  49. 'reference/aggregations/metrics/min-aggregation.asciidoc',
  50. 'reference/aggregations/metrics/percentile-aggregation.asciidoc',
  51. 'reference/aggregations/metrics/percentile-rank-aggregation.asciidoc',
  52. 'reference/aggregations/metrics/scripted-metric-aggregation.asciidoc',
  53. 'reference/aggregations/metrics/stats-aggregation.asciidoc',
  54. 'reference/aggregations/metrics/sum-aggregation.asciidoc',
  55. 'reference/aggregations/metrics/tophits-aggregation.asciidoc',
  56. 'reference/aggregations/metrics/valuecount-aggregation.asciidoc',
  57. 'reference/aggregations/pipeline.asciidoc',
  58. 'reference/aggregations/pipeline/avg-bucket-aggregation.asciidoc',
  59. 'reference/aggregations/pipeline/bucket-script-aggregation.asciidoc',
  60. 'reference/aggregations/pipeline/bucket-selector-aggregation.asciidoc',
  61. 'reference/aggregations/pipeline/cumulative-sum-aggregation.asciidoc',
  62. 'reference/aggregations/pipeline/derivative-aggregation.asciidoc',
  63. 'reference/aggregations/pipeline/extended-stats-bucket-aggregation.asciidoc',
  64. 'reference/aggregations/pipeline/max-bucket-aggregation.asciidoc',
  65. 'reference/aggregations/pipeline/min-bucket-aggregation.asciidoc',
  66. 'reference/aggregations/pipeline/movavg-aggregation.asciidoc',
  67. 'reference/aggregations/pipeline/percentiles-bucket-aggregation.asciidoc',
  68. 'reference/aggregations/pipeline/serial-diff-aggregation.asciidoc',
  69. 'reference/aggregations/pipeline/stats-bucket-aggregation.asciidoc',
  70. 'reference/aggregations/pipeline/sum-bucket-aggregation.asciidoc',
  71. 'reference/analysis/analyzers/lang-analyzer.asciidoc',
  72. 'reference/analysis/analyzers/pattern-analyzer.asciidoc',
  73. 'reference/analysis/charfilters/htmlstrip-charfilter.asciidoc',
  74. 'reference/analysis/charfilters/pattern-replace-charfilter.asciidoc',
  75. 'reference/analysis/tokenfilters/asciifolding-tokenfilter.asciidoc',
  76. 'reference/analysis/tokenfilters/cjk-bigram-tokenfilter.asciidoc',
  77. 'reference/analysis/tokenfilters/common-grams-tokenfilter.asciidoc',
  78. 'reference/analysis/tokenfilters/compound-word-tokenfilter.asciidoc',
  79. 'reference/analysis/tokenfilters/elision-tokenfilter.asciidoc',
  80. 'reference/analysis/tokenfilters/hunspell-tokenfilter.asciidoc',
  81. 'reference/analysis/tokenfilters/keep-types-tokenfilter.asciidoc',
  82. 'reference/analysis/tokenfilters/keep-words-tokenfilter.asciidoc',
  83. 'reference/analysis/tokenfilters/keyword-marker-tokenfilter.asciidoc',
  84. 'reference/analysis/tokenfilters/keyword-repeat-tokenfilter.asciidoc',
  85. 'reference/analysis/tokenfilters/limit-token-count-tokenfilter.asciidoc',
  86. 'reference/analysis/tokenfilters/lowercase-tokenfilter.asciidoc',
  87. 'reference/analysis/tokenfilters/pattern-capture-tokenfilter.asciidoc',
  88. 'reference/analysis/tokenfilters/snowball-tokenfilter.asciidoc',
  89. 'reference/analysis/tokenfilters/stemmer-override-tokenfilter.asciidoc',
  90. 'reference/analysis/tokenfilters/stemmer-tokenfilter.asciidoc',
  91. 'reference/analysis/tokenfilters/stop-tokenfilter.asciidoc',
  92. 'reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc',
  93. 'reference/analysis/tokenfilters/word-delimiter-tokenfilter.asciidoc',
  94. 'reference/cat/recovery.asciidoc',
  95. 'reference/cat/shards.asciidoc',
  96. 'reference/cat/snapshots.asciidoc',
  97. 'reference/cat/templates.asciidoc',
  98. 'reference/cat/thread_pool.asciidoc',
  99. 'reference/cluster/allocation-explain.asciidoc',
  100. 'reference/cluster/nodes-info.asciidoc',
  101. 'reference/cluster/nodes-stats.asciidoc',
  102. 'reference/cluster/pending.asciidoc',
  103. 'reference/cluster/reroute.asciidoc',
  104. 'reference/cluster/state.asciidoc',
  105. 'reference/cluster/stats.asciidoc',
  106. 'reference/cluster/tasks.asciidoc',
  107. 'reference/cluster/update-settings.asciidoc',
  108. 'reference/docs/bulk.asciidoc',
  109. 'reference/docs/delete-by-query.asciidoc',
  110. 'reference/docs/delete.asciidoc',
  111. 'reference/docs/index_.asciidoc',
  112. 'reference/docs/multi-get.asciidoc',
  113. 'reference/docs/multi-termvectors.asciidoc',
  114. 'reference/docs/reindex.asciidoc',
  115. 'reference/docs/termvectors.asciidoc',
  116. 'reference/docs/update-by-query.asciidoc',
  117. 'reference/docs/update.asciidoc',
  118. 'reference/index-modules/similarity.asciidoc',
  119. 'reference/index-modules/store.asciidoc',
  120. 'reference/index-modules/translog.asciidoc',
  121. 'reference/indices/analyze.asciidoc',
  122. 'reference/indices/flush.asciidoc',
  123. 'reference/indices/get-field-mapping.asciidoc',
  124. 'reference/indices/get-settings.asciidoc',
  125. 'reference/indices/put-mapping.asciidoc',
  126. 'reference/indices/recovery.asciidoc',
  127. 'reference/indices/segments.asciidoc',
  128. 'reference/indices/shadow-replicas.asciidoc',
  129. 'reference/indices/shard-stores.asciidoc',
  130. 'reference/indices/update-settings.asciidoc',
  131. 'reference/ingest/ingest-node.asciidoc',
  132. 'reference/mapping/dynamic/templates.asciidoc',
  133. 'reference/mapping/fields/all-field.asciidoc',
  134. 'reference/mapping/params/analyzer.asciidoc',
  135. 'reference/mapping/types/binary.asciidoc',
  136. 'reference/mapping/types/geo-point.asciidoc',
  137. 'reference/mapping/types/geo-shape.asciidoc',
  138. 'reference/mapping/types/ip.asciidoc',
  139. 'reference/mapping/types/nested.asciidoc',
  140. 'reference/mapping/types/object.asciidoc',
  141. 'reference/mapping/types/percolator.asciidoc',
  142. 'reference/modules/scripting/native.asciidoc',
  143. 'reference/modules/scripting/security.asciidoc',
  144. 'reference/modules/scripting/using.asciidoc',
  145. 'reference/modules/transport.asciidoc',
  146. 'reference/query-dsl/exists-query.asciidoc',
  147. 'reference/query-dsl/function-score-query.asciidoc',
  148. 'reference/query-dsl/geo-shape-query.asciidoc',
  149. 'reference/query-dsl/terms-query.asciidoc',
  150. 'reference/search/field-stats.asciidoc',
  151. 'reference/search/multi-search.asciidoc',
  152. 'reference/search/profile.asciidoc',
  153. 'reference/search/request/highlighting.asciidoc',
  154. 'reference/search/request/inner-hits.asciidoc',
  155. 'reference/search/request/rescore.asciidoc',
  156. 'reference/search/search-template.asciidoc',
  157. ]
  158. integTest {
  159. cluster {
  160. setting 'script.inline', 'true'
  161. setting 'script.stored', 'true'
  162. setting 'script.max_compilations_per_minute', '1000'
  163. /* Enable regexes in painless so our tests don't complain about example
  164. * snippets that use them. */
  165. setting 'script.painless.regex.enabled', 'true'
  166. Closure configFile = {
  167. extraConfigFile it, "src/test/cluster/config/$it"
  168. }
  169. configFile 'scripts/my_script.js'
  170. configFile 'scripts/my_script.py'
  171. configFile 'userdict_ja.txt'
  172. configFile 'KeywordTokenizer.rbbi'
  173. // Whitelist reindexing from the local node so we can test it.
  174. setting 'reindex.remote.whitelist', '127.0.0.1:*'
  175. }
  176. }
  177. // Build the cluser with all plugins
  178. project.rootProject.subprojects.findAll { it.parent.path == ':plugins' }.each { subproj ->
  179. /* Skip repositories. We just aren't going to be able to test them so it
  180. * doesn't make sense to waste time installing them. */
  181. if (subproj.path.startsWith(':plugins:repository-')) {
  182. return
  183. }
  184. subproj.afterEvaluate { // need to wait until the project has been configured
  185. integTest {
  186. cluster {
  187. plugin subproj.path
  188. }
  189. }
  190. }
  191. }
  192. buildRestTests.docs = fileTree(projectDir) {
  193. // No snippets in here!
  194. exclude 'build.gradle'
  195. // That is where the snippets go, not where they come from!
  196. exclude 'build'
  197. // This file simply doesn't pass yet. We should figure out how to fix it.
  198. exclude 'reference/modules/snapshots.asciidoc'
  199. }
  200. Closure setupTwitter = { String name, int count ->
  201. buildRestTests.setups[name] = '''
  202. - do:
  203. indices.create:
  204. index: twitter
  205. body:
  206. settings:
  207. number_of_shards: 1
  208. number_of_replicas: 1
  209. - do:
  210. bulk:
  211. index: twitter
  212. type: tweet
  213. refresh: true
  214. body: |'''
  215. for (int i = 0; i < count; i++) {
  216. String user, text
  217. if (i == 0) {
  218. user = 'kimchy'
  219. text = 'trying out Elasticsearch'
  220. } else {
  221. user = 'test'
  222. text = "some message with the number $i"
  223. }
  224. buildRestTests.setups[name] += """
  225. {"index":{"_id": "$i"}}
  226. {"user": "$user", "message": "$text", "date": "2009-11-15T14:12:12", "likes": $i}"""
  227. }
  228. }
  229. setupTwitter('twitter', 5)
  230. setupTwitter('big_twitter', 120)
  231. setupTwitter('huge_twitter', 1200)
  232. buildRestTests.setups['host'] = '''
  233. # Fetch the http host. We use the host of the master because we know there will always be a master.
  234. - do:
  235. cluster.state: {}
  236. - set: { master_node: master }
  237. - do:
  238. nodes.info:
  239. metric: [ http ]
  240. - is_true: nodes.$master.http.publish_address
  241. - set: {nodes.$master.http.publish_address: host}
  242. '''
  243. // Used by pipeline aggregation docs
  244. buildRestTests.setups['sales'] = '''
  245. - do:
  246. indices.create:
  247. index: sales
  248. body:
  249. settings:
  250. number_of_shards: 2
  251. number_of_replicas: 1
  252. mappings:
  253. sale:
  254. properties:
  255. type:
  256. type: keyword
  257. - do:
  258. bulk:
  259. index: sales
  260. type: sale
  261. refresh: true
  262. body: |
  263. {"index":{}}
  264. {"date": "2015/01/01 00:00:00", "price": 200, "type": "hat"}
  265. {"index":{}}
  266. {"date": "2015/01/01 00:00:00", "price": 200, "type": "t-shirt"}
  267. {"index":{}}
  268. {"date": "2015/01/01 00:00:00", "price": 150, "type": "bag"}
  269. {"index":{}}
  270. {"date": "2015/02/01 00:00:00", "price": 50, "type": "hat"}
  271. {"index":{}}
  272. {"date": "2015/02/01 00:00:00", "price": 10, "type": "t-shirt"}
  273. {"index":{}}
  274. {"date": "2015/03/01 00:00:00", "price": 200, "type": "hat"}
  275. {"index":{}}
  276. {"date": "2015/03/01 00:00:00", "price": 175, "type": "t-shirt"}'''
  277. // Dummy bank account data used by getting-started.asciidoc
  278. buildRestTests.setups['bank'] = '''
  279. - do:
  280. bulk:
  281. index: bank
  282. type: account
  283. refresh: true
  284. body: |
  285. #bank_data#
  286. '''
  287. /* Load the actual accounts only if we're going to use them. This complicates
  288. * dependency checking but that is a small price to pay for not building a
  289. * 400kb string every time we start the build. */
  290. File accountsFile = new File("$projectDir/src/test/resources/accounts.json")
  291. buildRestTests.inputs.file(accountsFile)
  292. buildRestTests.doFirst {
  293. String accounts = accountsFile.getText('UTF-8')
  294. // Indent like a yaml test needs
  295. accounts = accounts.replaceAll('(?m)^', ' ')
  296. buildRestTests.setups['bank'] =
  297. buildRestTests.setups['bank'].replace('#bank_data#', accounts)
  298. }