build.gradle 17 KB

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