build.gradle 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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/geodistance-aggregation.asciidoc',
  26. 'reference/aggregations/bucket/geohashgrid-aggregation.asciidoc',
  27. 'reference/aggregations/bucket/iprange-aggregation.asciidoc',
  28. 'reference/aggregations/bucket/missing-aggregation.asciidoc',
  29. 'reference/aggregations/bucket/nested-aggregation.asciidoc',
  30. 'reference/aggregations/bucket/range-aggregation.asciidoc',
  31. 'reference/aggregations/bucket/reverse-nested-aggregation.asciidoc',
  32. 'reference/aggregations/bucket/significantterms-aggregation.asciidoc',
  33. 'reference/aggregations/bucket/terms-aggregation.asciidoc',
  34. 'reference/aggregations/matrix/stats-aggregation.asciidoc',
  35. 'reference/aggregations/metrics/cardinality-aggregation.asciidoc',
  36. 'reference/aggregations/metrics/extendedstats-aggregation.asciidoc',
  37. 'reference/aggregations/metrics/geobounds-aggregation.asciidoc',
  38. 'reference/aggregations/metrics/geocentroid-aggregation.asciidoc',
  39. 'reference/aggregations/metrics/percentile-aggregation.asciidoc',
  40. 'reference/aggregations/metrics/percentile-rank-aggregation.asciidoc',
  41. 'reference/aggregations/metrics/scripted-metric-aggregation.asciidoc',
  42. 'reference/aggregations/metrics/stats-aggregation.asciidoc',
  43. 'reference/aggregations/metrics/tophits-aggregation.asciidoc',
  44. 'reference/aggregations/pipeline.asciidoc',
  45. 'reference/aggregations/pipeline/avg-bucket-aggregation.asciidoc',
  46. 'reference/aggregations/pipeline/bucket-script-aggregation.asciidoc',
  47. 'reference/aggregations/pipeline/bucket-selector-aggregation.asciidoc',
  48. 'reference/aggregations/pipeline/cumulative-sum-aggregation.asciidoc',
  49. 'reference/aggregations/pipeline/derivative-aggregation.asciidoc',
  50. 'reference/aggregations/pipeline/extended-stats-bucket-aggregation.asciidoc',
  51. 'reference/aggregations/pipeline/max-bucket-aggregation.asciidoc',
  52. 'reference/aggregations/pipeline/min-bucket-aggregation.asciidoc',
  53. 'reference/aggregations/pipeline/movavg-aggregation.asciidoc',
  54. 'reference/aggregations/pipeline/percentiles-bucket-aggregation.asciidoc',
  55. 'reference/aggregations/pipeline/serial-diff-aggregation.asciidoc',
  56. 'reference/aggregations/pipeline/stats-bucket-aggregation.asciidoc',
  57. 'reference/aggregations/pipeline/sum-bucket-aggregation.asciidoc',
  58. 'reference/analysis/analyzers/lang-analyzer.asciidoc',
  59. 'reference/analysis/analyzers/pattern-analyzer.asciidoc',
  60. 'reference/analysis/charfilters/htmlstrip-charfilter.asciidoc',
  61. 'reference/analysis/charfilters/pattern-replace-charfilter.asciidoc',
  62. 'reference/analysis/tokenfilters/asciifolding-tokenfilter.asciidoc',
  63. 'reference/analysis/tokenfilters/cjk-bigram-tokenfilter.asciidoc',
  64. 'reference/analysis/tokenfilters/common-grams-tokenfilter.asciidoc',
  65. 'reference/analysis/tokenfilters/compound-word-tokenfilter.asciidoc',
  66. 'reference/analysis/tokenfilters/elision-tokenfilter.asciidoc',
  67. 'reference/analysis/tokenfilters/hunspell-tokenfilter.asciidoc',
  68. 'reference/analysis/tokenfilters/keep-types-tokenfilter.asciidoc',
  69. 'reference/analysis/tokenfilters/keep-words-tokenfilter.asciidoc',
  70. 'reference/analysis/tokenfilters/keyword-marker-tokenfilter.asciidoc',
  71. 'reference/analysis/tokenfilters/keyword-repeat-tokenfilter.asciidoc',
  72. 'reference/analysis/tokenfilters/limit-token-count-tokenfilter.asciidoc',
  73. 'reference/analysis/tokenfilters/lowercase-tokenfilter.asciidoc',
  74. 'reference/analysis/tokenfilters/pattern-capture-tokenfilter.asciidoc',
  75. 'reference/analysis/tokenfilters/snowball-tokenfilter.asciidoc',
  76. 'reference/analysis/tokenfilters/stemmer-override-tokenfilter.asciidoc',
  77. 'reference/analysis/tokenfilters/stemmer-tokenfilter.asciidoc',
  78. 'reference/analysis/tokenfilters/stop-tokenfilter.asciidoc',
  79. 'reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc',
  80. 'reference/analysis/tokenfilters/synonym-graph-tokenfilter.asciidoc',
  81. 'reference/analysis/tokenfilters/word-delimiter-tokenfilter.asciidoc',
  82. 'reference/cat/recovery.asciidoc',
  83. 'reference/cat/shards.asciidoc',
  84. 'reference/cat/snapshots.asciidoc',
  85. 'reference/cat/templates.asciidoc',
  86. 'reference/cat/thread_pool.asciidoc',
  87. 'reference/cluster/allocation-explain.asciidoc',
  88. 'reference/cluster/nodes-info.asciidoc',
  89. 'reference/cluster/nodes-stats.asciidoc',
  90. 'reference/cluster/pending.asciidoc',
  91. 'reference/cluster/state.asciidoc',
  92. 'reference/cluster/stats.asciidoc',
  93. 'reference/cluster/tasks.asciidoc',
  94. 'reference/docs/delete-by-query.asciidoc',
  95. 'reference/docs/delete.asciidoc',
  96. 'reference/docs/index_.asciidoc',
  97. 'reference/docs/reindex.asciidoc',
  98. 'reference/docs/update-by-query.asciidoc',
  99. 'reference/docs/update.asciidoc',
  100. 'reference/index-modules/similarity.asciidoc',
  101. 'reference/index-modules/store.asciidoc',
  102. 'reference/index-modules/translog.asciidoc',
  103. 'reference/indices/flush.asciidoc',
  104. 'reference/indices/get-settings.asciidoc',
  105. 'reference/indices/put-mapping.asciidoc',
  106. 'reference/indices/recovery.asciidoc',
  107. 'reference/indices/segments.asciidoc',
  108. 'reference/indices/shard-stores.asciidoc',
  109. 'reference/ingest/ingest-node.asciidoc',
  110. 'reference/mapping/dynamic/templates.asciidoc',
  111. 'reference/mapping/fields/all-field.asciidoc',
  112. 'reference/mapping/params/analyzer.asciidoc',
  113. 'reference/mapping/types/binary.asciidoc',
  114. 'reference/mapping/types/geo-point.asciidoc',
  115. 'reference/mapping/types/geo-shape.asciidoc',
  116. 'reference/mapping/types/ip.asciidoc',
  117. 'reference/mapping/types/nested.asciidoc',
  118. 'reference/mapping/types/object.asciidoc',
  119. 'reference/mapping/types/percolator.asciidoc',
  120. 'reference/modules/scripting/security.asciidoc',
  121. 'reference/modules/scripting/using.asciidoc',
  122. 'reference/modules/cross-cluster-search.asciidoc', // this is hart to test since we need 2 clusters -- maybe we can trick it into referencing itself...
  123. 'reference/query-dsl/exists-query.asciidoc',
  124. 'reference/query-dsl/function-score-query.asciidoc',
  125. 'reference/query-dsl/geo-shape-query.asciidoc',
  126. 'reference/search/field-stats.asciidoc',
  127. 'reference/search/profile.asciidoc',
  128. 'reference/search/request/highlighting.asciidoc',
  129. 'reference/search/request/inner-hits.asciidoc',
  130. ]
  131. integTest {
  132. cluster {
  133. setting 'script.inline', 'true'
  134. setting 'script.stored', 'true'
  135. setting 'script.max_compilations_per_minute', '1000'
  136. /* Enable regexes in painless so our tests don't complain about example
  137. * snippets that use them. */
  138. setting 'script.painless.regex.enabled', 'true'
  139. Closure configFile = {
  140. extraConfigFile it, "src/test/cluster/config/$it"
  141. }
  142. configFile 'scripts/my_script.painless'
  143. configFile 'scripts/my_init_script.painless'
  144. configFile 'scripts/my_map_script.painless'
  145. configFile 'scripts/my_combine_script.painless'
  146. configFile 'scripts/my_reduce_script.painless'
  147. configFile 'userdict_ja.txt'
  148. configFile 'KeywordTokenizer.rbbi'
  149. // Whitelist reindexing from the local node so we can test it.
  150. setting 'reindex.remote.whitelist', '127.0.0.1:*'
  151. }
  152. }
  153. // Build the cluser with all plugins
  154. project.rootProject.subprojects.findAll { it.parent.path == ':plugins' }.each { subproj ->
  155. /* Skip repositories. We just aren't going to be able to test them so it
  156. * doesn't make sense to waste time installing them. */
  157. if (subproj.path.startsWith(':plugins:repository-')) {
  158. return
  159. }
  160. subproj.afterEvaluate { // need to wait until the project has been configured
  161. integTest {
  162. cluster {
  163. plugin subproj.path
  164. }
  165. }
  166. }
  167. }
  168. buildRestTests.docs = fileTree(projectDir) {
  169. // No snippets in here!
  170. exclude 'build.gradle'
  171. // That is where the snippets go, not where they come from!
  172. exclude 'build'
  173. // This file simply doesn't pass yet. We should figure out how to fix it.
  174. exclude 'reference/modules/snapshots.asciidoc'
  175. }
  176. Closure setupTwitter = { String name, int count ->
  177. buildRestTests.setups[name] = '''
  178. - do:
  179. indices.create:
  180. index: twitter
  181. body:
  182. settings:
  183. number_of_shards: 1
  184. number_of_replicas: 1
  185. mappings:
  186. tweet:
  187. properties:
  188. user:
  189. type: keyword
  190. doc_values: true
  191. date:
  192. type: date
  193. likes:
  194. type: long
  195. - do:
  196. bulk:
  197. index: twitter
  198. type: tweet
  199. refresh: true
  200. body: |'''
  201. for (int i = 0; i < count; i++) {
  202. String user, text
  203. if (i == 0) {
  204. user = 'kimchy'
  205. text = 'trying out Elasticsearch'
  206. } else {
  207. user = 'test'
  208. text = "some message with the number $i"
  209. }
  210. buildRestTests.setups[name] += """
  211. {"index":{"_id": "$i"}}
  212. {"user": "$user", "message": "$text", "date": "2009-11-15T14:12:12", "likes": $i}"""
  213. }
  214. }
  215. setupTwitter('twitter', 5)
  216. setupTwitter('big_twitter', 120)
  217. setupTwitter('huge_twitter', 1200)
  218. buildRestTests.setups['host'] = '''
  219. # Fetch the http host. We use the host of the master because we know there will always be a master.
  220. - do:
  221. cluster.state: {}
  222. - set: { master_node: master }
  223. - do:
  224. nodes.info:
  225. metric: [ http ]
  226. - is_true: nodes.$master.http.publish_address
  227. - set: {nodes.$master.http.publish_address: host}
  228. '''
  229. // Used by scripted metric docs
  230. buildRestTests.setups['ledger'] = '''
  231. - do:
  232. indices.create:
  233. index: ledger
  234. body:
  235. settings:
  236. number_of_shards: 2
  237. number_of_replicas: 1
  238. mappings:
  239. sale:
  240. properties:
  241. type:
  242. type: keyword
  243. amount:
  244. type: double
  245. - do:
  246. bulk:
  247. index: ledger
  248. type: item
  249. refresh: true
  250. body: |
  251. {"index":{}}
  252. {"date": "2015/01/01 00:00:00", "amount": 200, "type": "sale", "description": "something"}
  253. {"index":{}}
  254. {"date": "2015/01/01 00:00:00", "amount": 10, "type": "expense", "decription": "another thing"}
  255. {"index":{}}
  256. {"date": "2015/01/01 00:00:00", "amount": 150, "type": "sale", "description": "blah"}
  257. {"index":{}}
  258. {"date": "2015/01/01 00:00:00", "amount": 50, "type": "expense", "description": "cost of blah"}
  259. {"index":{}}
  260. {"date": "2015/01/01 00:00:00", "amount": 50, "type": "expense", "description": "advertisement"}'''
  261. // Used by aggregation docs
  262. buildRestTests.setups['sales'] = '''
  263. - do:
  264. indices.create:
  265. index: sales
  266. body:
  267. settings:
  268. number_of_shards: 2
  269. number_of_replicas: 1
  270. mappings:
  271. sale:
  272. properties:
  273. type:
  274. type: keyword
  275. - do:
  276. bulk:
  277. index: sales
  278. type: sale
  279. refresh: true
  280. body: |
  281. {"index":{}}
  282. {"date": "2015/01/01 00:00:00", "price": 200, "promoted": true, "rating": 1, "type": "hat"}
  283. {"index":{}}
  284. {"date": "2015/01/01 00:00:00", "price": 200, "promoted": true, "rating": 1, "type": "t-shirt"}
  285. {"index":{}}
  286. {"date": "2015/01/01 00:00:00", "price": 150, "promoted": true, "rating": 5, "type": "bag"}
  287. {"index":{}}
  288. {"date": "2015/02/01 00:00:00", "price": 50, "promoted": false, "rating": 1, "type": "hat"}
  289. {"index":{}}
  290. {"date": "2015/02/01 00:00:00", "price": 10, "promoted": true, "rating": 4, "type": "t-shirt"}
  291. {"index":{}}
  292. {"date": "2015/03/01 00:00:00", "price": 200, "promoted": true, "rating": 1, "type": "hat"}
  293. {"index":{}}
  294. {"date": "2015/03/01 00:00:00", "price": 175, "promoted": false, "rating": 2, "type": "t-shirt"}'''
  295. // Dummy bank account data used by getting-started.asciidoc
  296. buildRestTests.setups['bank'] = '''
  297. - do:
  298. bulk:
  299. index: bank
  300. type: account
  301. refresh: true
  302. body: |
  303. #bank_data#
  304. '''
  305. /* Load the actual accounts only if we're going to use them. This complicates
  306. * dependency checking but that is a small price to pay for not building a
  307. * 400kb string every time we start the build. */
  308. File accountsFile = new File("$projectDir/src/test/resources/accounts.json")
  309. buildRestTests.inputs.file(accountsFile)
  310. buildRestTests.doFirst {
  311. String accounts = accountsFile.getText('UTF-8')
  312. // Indent like a yaml test needs
  313. accounts = accounts.replaceAll('(?m)^', ' ')
  314. buildRestTests.setups['bank'] =
  315. buildRestTests.setups['bank'].replace('#bank_data#', accounts)
  316. }
  317. buildRestTests.setups['range_index'] = '''
  318. - do :
  319. indices.create:
  320. index: range_index
  321. body:
  322. settings:
  323. number_of_shards: 2
  324. number_of_replicas: 1
  325. mappings:
  326. my_type:
  327. properties:
  328. expected_attendees:
  329. type: integer_range
  330. time_frame:
  331. type: date_range
  332. format: yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis
  333. - do:
  334. bulk:
  335. index: range_index
  336. type: my_type
  337. refresh: true
  338. body: |
  339. {"index":{"_id": 1}}
  340. {"expected_attendees": {"gte": 10, "lte": 20}, "time_frame": {"gte": "2015-10-31 12:00:00", "lte": "2015-11-01"}}'''
  341. // Used by index boost doc
  342. buildRestTests.setups['index_boost'] = '''
  343. - do:
  344. indices.create:
  345. index: index1
  346. - do:
  347. indices.create:
  348. index: index2
  349. - do:
  350. indices.put_alias:
  351. index: index1
  352. name: alias1
  353. '''
  354. // Used by sampler and diversified-sampler aggregation docs
  355. buildRestTests.setups['stackoverflow'] = '''
  356. - do:
  357. indices.create:
  358. index: stackoverflow
  359. body:
  360. settings:
  361. number_of_shards: 1
  362. number_of_replicas: 1
  363. mappings:
  364. question:
  365. properties:
  366. author:
  367. type: keyword
  368. tags:
  369. type: keyword
  370. - do:
  371. bulk:
  372. index: stackoverflow
  373. type: question
  374. refresh: true
  375. body: |'''
  376. // Make Kibana strongly connected to elasticsearch and logstash
  377. // Make Kibana rarer (and therefore higher-ranking) than Javascript
  378. // Make Javascript strongly connected to jquery and angular
  379. // Make Cabana strongly connected to elasticsearch but only as a result of a single author
  380. for (int i = 0; i < 150; i++) {
  381. buildRestTests.setups['stackoverflow'] += """
  382. {"index":{}}
  383. {"author": "very_relevant_$i", "tags": ["elasticsearch", "kibana"]}"""
  384. }
  385. for (int i = 0; i < 50; i++) {
  386. buildRestTests.setups['stackoverflow'] += """
  387. {"index":{}}
  388. {"author": "very_relevant_$i", "tags": ["logstash", "kibana"]}"""
  389. }
  390. for (int i = 0; i < 200; i++) {
  391. buildRestTests.setups['stackoverflow'] += """
  392. {"index":{}}
  393. {"author": "partially_relevant_$i", "tags": ["javascript", "jquery"]}"""
  394. }
  395. for (int i = 0; i < 200; i++) {
  396. buildRestTests.setups['stackoverflow'] += """
  397. {"index":{}}
  398. {"author": "partially_relevant_$i", "tags": ["javascript", "angular"]}"""
  399. }
  400. for (int i = 0; i < 50; i++) {
  401. buildRestTests.setups['stackoverflow'] += """
  402. {"index":{}}
  403. {"author": "noisy author", "tags": ["elasticsearch", "cabana"]}"""
  404. }
  405. buildRestTests.setups['stackoverflow'] += """
  406. """
  407. // Used by some aggregations
  408. buildRestTests.setups['exams'] = '''
  409. - do:
  410. indices.create:
  411. index: exams
  412. body:
  413. settings:
  414. number_of_shards: 1
  415. number_of_replicas: 1
  416. mappings:
  417. exam:
  418. properties:
  419. grade:
  420. type: byte
  421. - do:
  422. bulk:
  423. index: exams
  424. type: exam
  425. refresh: true
  426. body: |
  427. {"index":{}}
  428. {"grade": 100}
  429. {"index":{}}
  430. {"grade": 50}'''