build.gradle 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. import static org.elasticsearch.gradle.testclusters.TestDistribution.DEFAULT
  2. /*
  3. * Licensed to Elasticsearch under one or more contributor
  4. * license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright
  6. * ownership. Elasticsearch licenses this file to you under
  7. * the Apache License, Version 2.0 (the "License"); you may
  8. * not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. apply plugin: 'elasticsearch.docs-test'
  21. /* List of files that have snippets that will not work until platinum tests can occur ... */
  22. buildRestTests.expectedUnconvertedCandidates = [
  23. 'reference/ml/anomaly-detection/transforms.asciidoc',
  24. 'reference/ml/anomaly-detection/apis/delete-calendar-event.asciidoc',
  25. 'reference/ml/anomaly-detection/apis/get-bucket.asciidoc',
  26. 'reference/ml/anomaly-detection/apis/get-category.asciidoc',
  27. 'reference/ml/anomaly-detection/apis/get-influencer.asciidoc',
  28. 'reference/ml/anomaly-detection/apis/get-job-stats.asciidoc',
  29. 'reference/ml/anomaly-detection/apis/get-job.asciidoc',
  30. 'reference/ml/anomaly-detection/apis/get-overall-buckets.asciidoc',
  31. 'reference/ml/anomaly-detection/apis/get-record.asciidoc',
  32. 'reference/ml/anomaly-detection/apis/get-snapshot.asciidoc',
  33. 'reference/ml/anomaly-detection/apis/post-data.asciidoc',
  34. 'reference/ml/anomaly-detection/apis/revert-snapshot.asciidoc',
  35. 'reference/ml/anomaly-detection/apis/update-snapshot.asciidoc',
  36. ]
  37. testClusters.integTest {
  38. if (singleNode().testDistribution == DEFAULT) {
  39. setting 'xpack.license.self_generated.type', 'trial'
  40. }
  41. // enable regexes in painless so our tests don't complain about example snippets that use them
  42. setting 'script.painless.regex.enabled', 'true'
  43. setting 'path.repo', "${buildDir}/cluster/shared/repo"
  44. Closure configFile = {
  45. extraConfigFile it, file("src/test/cluster/config/$it")
  46. }
  47. configFile 'analysis/example_word_list.txt'
  48. configFile 'analysis/hyphenation_patterns.xml'
  49. configFile 'analysis/synonym.txt'
  50. configFile 'analysis/stemmer_override.txt'
  51. configFile 'userdict_ja.txt'
  52. configFile 'userdict_ko.txt'
  53. configFile 'KeywordTokenizer.rbbi'
  54. extraConfigFile 'hunspell/en_US/en_US.aff', project(":server").file('src/test/resources/indices/analyze/conf_dir/hunspell/en_US/en_US.aff')
  55. extraConfigFile 'hunspell/en_US/en_US.dic', project(":server").file('src/test/resources/indices/analyze/conf_dir/hunspell/en_US/en_US.dic')
  56. // Whitelist reindexing from the local node so we can test it.
  57. setting 'reindex.remote.whitelist', '127.0.0.1:*'
  58. setting 'index.lifecycle.history_index_enabled', 'false'
  59. // TODO: remove this once cname is prepended to transport.publish_address by default in 8.0
  60. systemProperty 'es.transport.cname_in_publish_address', 'true'
  61. }
  62. // build the cluster with all plugins
  63. project.rootProject.subprojects.findAll { it.parent.path == ':plugins' }.each { subproj ->
  64. /* Skip repositories. We just aren't going to be able to test them so it
  65. * doesn't make sense to waste time installing them. */
  66. if (subproj.path.startsWith(':plugins:repository-')) {
  67. return
  68. }
  69. // Do not install ingest-attachment in a FIPS 140 JVM as this is not supported
  70. if (subproj.path.startsWith(':plugins:ingest-attachment') && Boolean.parseBoolean(System.getProperty("tests.fips.enabled"))) {
  71. return
  72. }
  73. // FIXME
  74. subproj.afterEvaluate { // need to wait until the project has been configured
  75. testClusters.integTest {
  76. plugin file(subproj.bundlePlugin.archiveFile)
  77. }
  78. tasks.integTest.dependsOn subproj.bundlePlugin
  79. }
  80. }
  81. buildRestTests.docs = fileTree(projectDir) {
  82. // No snippets in here!
  83. exclude 'build.gradle'
  84. // That is where the snippets go, not where they come from!
  85. exclude 'build'
  86. exclude 'build-idea'
  87. exclude 'build-eclipse'
  88. // Just syntax examples
  89. exclude 'README.asciidoc'
  90. // Broken code snippet tests
  91. exclude 'reference/graph/explore.asciidoc'
  92. if (Boolean.parseBoolean(System.getProperty("tests.fips.enabled"))) {
  93. // We don't install/support this plugin in FIPS 140
  94. exclude 'plugins/ingest-attachment.asciidoc'
  95. // We can't conditionally control output, this would be missing the ingest-attachment plugin
  96. exclude 'reference/cat/plugins.asciidoc'
  97. }
  98. }
  99. listSnippets.docs = buildRestTests.docs
  100. listConsoleCandidates.docs = buildRestTests.docs
  101. Closure setupTwitter = { String name, int count ->
  102. buildRestTests.setups[name] = '''
  103. - do:
  104. indices.create:
  105. index: twitter
  106. body:
  107. settings:
  108. number_of_shards: 1
  109. number_of_replicas: 1
  110. mappings:
  111. properties:
  112. user:
  113. type: keyword
  114. doc_values: true
  115. date:
  116. type: date
  117. likes:
  118. type: long
  119. - do:
  120. bulk:
  121. index: twitter
  122. refresh: true
  123. body: |'''
  124. for (int i = 0; i < count; i++) {
  125. String user, text
  126. if (i == 0) {
  127. user = 'kimchy'
  128. text = 'trying out Elasticsearch'
  129. } else {
  130. user = 'test'
  131. text = "some message with the number $i"
  132. }
  133. buildRestTests.setups[name] += """
  134. {"index":{"_id": "$i"}}
  135. {"user": "$user", "message": "$text", "date": "2009-11-15T14:12:12", "likes": $i}"""
  136. }
  137. }
  138. setupTwitter('twitter', 5)
  139. setupTwitter('big_twitter', 120)
  140. setupTwitter('huge_twitter', 1200)
  141. buildRestTests.setups['host'] = '''
  142. # Fetch the http host. We use the host of the master because we know there will always be a master.
  143. - do:
  144. cluster.state: {}
  145. - set: { master_node: master }
  146. - do:
  147. nodes.info:
  148. metric: [ http, transport ]
  149. - set: {nodes.$master.http.publish_address: host}
  150. - set: {nodes.$master.transport.publish_address: transport_host}
  151. '''
  152. buildRestTests.setups['node'] = '''
  153. # Fetch the node name. We use the host of the master because we know there will always be a master.
  154. - do:
  155. cluster.state: {}
  156. - is_true: master_node
  157. - set: { master_node: node_name }
  158. '''
  159. // Used by scripted metric docs
  160. buildRestTests.setups['ledger'] = '''
  161. - do:
  162. indices.create:
  163. index: ledger
  164. body:
  165. settings:
  166. number_of_shards: 2
  167. number_of_replicas: 1
  168. mappings:
  169. properties:
  170. type:
  171. type: keyword
  172. amount:
  173. type: double
  174. - do:
  175. bulk:
  176. index: ledger
  177. refresh: true
  178. body: |
  179. {"index":{}}
  180. {"date": "2015/01/01 00:00:00", "amount": 200, "type": "sale", "description": "something"}
  181. {"index":{}}
  182. {"date": "2015/01/01 00:00:00", "amount": 10, "type": "expense", "description": "another thing"}
  183. {"index":{}}
  184. {"date": "2015/01/01 00:00:00", "amount": 150, "type": "sale", "description": "blah"}
  185. {"index":{}}
  186. {"date": "2015/01/01 00:00:00", "amount": 50, "type": "expense", "description": "cost of blah"}
  187. {"index":{}}
  188. {"date": "2015/01/01 00:00:00", "amount": 50, "type": "expense", "description": "advertisement"}'''
  189. // Used by aggregation docs
  190. buildRestTests.setups['sales'] = '''
  191. - do:
  192. indices.create:
  193. index: sales
  194. body:
  195. settings:
  196. number_of_shards: 2
  197. number_of_replicas: 1
  198. mappings:
  199. properties:
  200. type:
  201. type: keyword
  202. - do:
  203. bulk:
  204. index: sales
  205. refresh: true
  206. body: |
  207. {"index":{}}
  208. {"date": "2015/01/01 00:00:00", "price": 200, "promoted": true, "rating": 1, "type": "hat"}
  209. {"index":{}}
  210. {"date": "2015/01/01 00:00:00", "price": 200, "promoted": true, "rating": 1, "type": "t-shirt"}
  211. {"index":{}}
  212. {"date": "2015/01/01 00:00:00", "price": 150, "promoted": true, "rating": 5, "type": "bag"}
  213. {"index":{}}
  214. {"date": "2015/02/01 00:00:00", "price": 50, "promoted": false, "rating": 1, "type": "hat"}
  215. {"index":{}}
  216. {"date": "2015/02/01 00:00:00", "price": 10, "promoted": true, "rating": 4, "type": "t-shirt"}
  217. {"index":{}}
  218. {"date": "2015/03/01 00:00:00", "price": 200, "promoted": true, "rating": 1, "type": "hat"}
  219. {"index":{}}
  220. {"date": "2015/03/01 00:00:00", "price": 175, "promoted": false, "rating": 2, "type": "t-shirt"}'''
  221. // Used by cumulative cardinality aggregation docs
  222. buildRestTests.setups['user_hits'] = '''
  223. - do:
  224. indices.create:
  225. index: user_hits
  226. body:
  227. settings:
  228. number_of_shards: 1
  229. number_of_replicas: 0
  230. mappings:
  231. properties:
  232. user_id:
  233. type: keyword
  234. timestamp:
  235. type: date
  236. - do:
  237. bulk:
  238. index: user_hits
  239. refresh: true
  240. body: |
  241. {"index":{}}
  242. {"timestamp": "2019-01-01T13:00:00", "user_id": "1"}
  243. {"index":{}}
  244. {"timestamp": "2019-01-01T13:00:00", "user_id": "2"}
  245. {"index":{}}
  246. {"timestamp": "2019-01-02T13:00:00", "user_id": "1"}
  247. {"index":{}}
  248. {"timestamp": "2019-01-02T13:00:00", "user_id": "3"}
  249. {"index":{}}
  250. {"timestamp": "2019-01-03T13:00:00", "user_id": "1"}
  251. {"index":{}}
  252. {"timestamp": "2019-01-03T13:00:00", "user_id": "2"}
  253. {"index":{}}
  254. {"timestamp": "2019-01-03T13:00:00", "user_id": "4"}'''
  255. // Dummy bank account data used by getting-started.asciidoc
  256. buildRestTests.setups['bank'] = '''
  257. - do:
  258. indices.create:
  259. index: bank
  260. body:
  261. settings:
  262. number_of_shards: 5
  263. number_of_routing_shards: 5
  264. - do:
  265. bulk:
  266. index: bank
  267. refresh: true
  268. body: |
  269. #bank_data#
  270. '''
  271. /* Load the actual accounts only if we're going to use them. This complicates
  272. * dependency checking but that is a small price to pay for not building a
  273. * 400kb string every time we start the build. */
  274. File accountsFile = new File("$projectDir/src/test/resources/accounts.json")
  275. buildRestTests.inputs.file(accountsFile)
  276. buildRestTests.doFirst {
  277. String accounts = accountsFile.getText('UTF-8')
  278. // Indent like a yaml test needs
  279. accounts = accounts.replaceAll('(?m)^', ' ')
  280. buildRestTests.setups['bank'] =
  281. buildRestTests.setups['bank'].replace('#bank_data#', accounts)
  282. }
  283. // Used by index boost doc
  284. buildRestTests.setups['index_boost'] = '''
  285. - do:
  286. indices.create:
  287. index: index1
  288. - do:
  289. indices.create:
  290. index: index2
  291. - do:
  292. indices.put_alias:
  293. index: index1
  294. name: alias1
  295. '''
  296. // Used by sampler and diversified-sampler aggregation docs
  297. buildRestTests.setups['stackoverflow'] = '''
  298. - do:
  299. indices.create:
  300. index: stackoverflow
  301. body:
  302. settings:
  303. number_of_shards: 1
  304. number_of_replicas: 1
  305. mappings:
  306. properties:
  307. author:
  308. type: keyword
  309. tags:
  310. type: keyword
  311. - do:
  312. bulk:
  313. index: stackoverflow
  314. refresh: true
  315. body: |'''
  316. // Make Kibana strongly connected to elasticsearch and logstash
  317. // Make Kibana rarer (and therefore higher-ranking) than JavaScript
  318. // Make JavaScript strongly connected to jquery and angular
  319. // Make Cabana strongly connected to elasticsearch but only as a result of a single author
  320. for (int i = 0; i < 150; i++) {
  321. buildRestTests.setups['stackoverflow'] += """
  322. {"index":{}}
  323. {"author": "very_relevant_$i", "tags": ["elasticsearch", "kibana"]}"""
  324. }
  325. for (int i = 0; i < 50; i++) {
  326. buildRestTests.setups['stackoverflow'] += """
  327. {"index":{}}
  328. {"author": "very_relevant_$i", "tags": ["logstash", "kibana"]}"""
  329. }
  330. for (int i = 0; i < 200; i++) {
  331. buildRestTests.setups['stackoverflow'] += """
  332. {"index":{}}
  333. {"author": "partially_relevant_$i", "tags": ["javascript", "jquery"]}"""
  334. }
  335. for (int i = 0; i < 200; i++) {
  336. buildRestTests.setups['stackoverflow'] += """
  337. {"index":{}}
  338. {"author": "partially_relevant_$i", "tags": ["javascript", "angular"]}"""
  339. }
  340. for (int i = 0; i < 50; i++) {
  341. buildRestTests.setups['stackoverflow'] += """
  342. {"index":{}}
  343. {"author": "noisy author", "tags": ["elasticsearch", "cabana"]}"""
  344. }
  345. buildRestTests.setups['stackoverflow'] += """
  346. """
  347. // Used by significant_text aggregation docs
  348. buildRestTests.setups['news'] = '''
  349. - do:
  350. indices.create:
  351. index: news
  352. body:
  353. settings:
  354. number_of_shards: 1
  355. number_of_replicas: 1
  356. mappings:
  357. properties:
  358. source:
  359. type: keyword
  360. content:
  361. type: text
  362. - do:
  363. bulk:
  364. index: news
  365. refresh: true
  366. body: |'''
  367. // Make h5n1 strongly connected to bird flu
  368. for (int i = 0; i < 100; i++) {
  369. buildRestTests.setups['news'] += """
  370. {"index":{}}
  371. {"source": "very_relevant_$i", "content": "bird flu h5n1"}"""
  372. }
  373. for (int i = 0; i < 100; i++) {
  374. buildRestTests.setups['news'] += """
  375. {"index":{}}
  376. {"source": "filler_$i", "content": "bird dupFiller "}"""
  377. }
  378. for (int i = 0; i < 100; i++) {
  379. buildRestTests.setups['news'] += """
  380. {"index":{}}
  381. {"source": "filler_$i", "content": "flu dupFiller "}"""
  382. }
  383. for (int i = 0; i < 20; i++) {
  384. buildRestTests.setups['news'] += """
  385. {"index":{}}
  386. {"source": "partially_relevant_$i", "content": "elasticsearch dupFiller dupFiller dupFiller dupFiller pozmantier"}"""
  387. }
  388. for (int i = 0; i < 10; i++) {
  389. buildRestTests.setups['news'] += """
  390. {"index":{}}
  391. {"source": "partially_relevant_$i", "content": "elasticsearch logstash kibana"}"""
  392. }
  393. buildRestTests.setups['news'] += """
  394. """
  395. // Used by some aggregations
  396. buildRestTests.setups['exams'] = '''
  397. - do:
  398. indices.create:
  399. index: exams
  400. body:
  401. settings:
  402. number_of_shards: 1
  403. number_of_replicas: 1
  404. mappings:
  405. properties:
  406. grade:
  407. type: byte
  408. - do:
  409. bulk:
  410. index: exams
  411. refresh: true
  412. body: |
  413. {"index":{}}
  414. {"grade": 100, "weight": 2}
  415. {"index":{}}
  416. {"grade": 50, "weight": 3}'''
  417. buildRestTests.setups['stored_example_script'] = '''
  418. # Simple script to load a field. Not really a good example, but a simple one.
  419. - do:
  420. put_script:
  421. id: "my_script"
  422. body: { "script": { "lang": "painless", "source": "doc[params.field].value" } }
  423. - match: { acknowledged: true }
  424. '''
  425. buildRestTests.setups['stored_scripted_metric_script'] = '''
  426. - do:
  427. put_script:
  428. id: "my_init_script"
  429. body: { "script": { "lang": "painless", "source": "state.transactions = []" } }
  430. - match: { acknowledged: true }
  431. - do:
  432. put_script:
  433. id: "my_map_script"
  434. body: { "script": { "lang": "painless", "source": "state.transactions.add(doc.type.value == 'sale' ? doc.amount.value : -1 * doc.amount.value)" } }
  435. - match: { acknowledged: true }
  436. - do:
  437. put_script:
  438. id: "my_combine_script"
  439. body: { "script": { "lang": "painless", "source": "double profit = 0;for (t in state.transactions) { profit += t; } return profit" } }
  440. - match: { acknowledged: true }
  441. - do:
  442. put_script:
  443. id: "my_reduce_script"
  444. body: { "script": { "lang": "painless", "source": "double profit = 0;for (a in states) { profit += a; } return profit" } }
  445. - match: { acknowledged: true }
  446. '''
  447. // Used by analyze api
  448. buildRestTests.setups['analyze_sample'] = '''
  449. - do:
  450. indices.create:
  451. index: analyze_sample
  452. body:
  453. settings:
  454. number_of_shards: 1
  455. number_of_replicas: 0
  456. analysis:
  457. normalizer:
  458. my_normalizer:
  459. type: custom
  460. filter: [lowercase]
  461. mappings:
  462. properties:
  463. obj1.field1:
  464. type: text'''
  465. // Used by percentile/percentile-rank aggregations
  466. buildRestTests.setups['latency'] = '''
  467. - do:
  468. indices.create:
  469. index: latency
  470. body:
  471. settings:
  472. number_of_shards: 1
  473. number_of_replicas: 1
  474. mappings:
  475. properties:
  476. load_time:
  477. type: long
  478. - do:
  479. bulk:
  480. index: latency
  481. refresh: true
  482. body: |'''
  483. for (int i = 0; i < 100; i++) {
  484. def value = i
  485. if (i % 10) {
  486. value = i * 10
  487. }
  488. buildRestTests.setups['latency'] += """
  489. {"index":{}}
  490. {"load_time": "$value"}"""
  491. }
  492. // Used by iprange agg
  493. buildRestTests.setups['iprange'] = '''
  494. - do:
  495. indices.create:
  496. index: ip_addresses
  497. body:
  498. settings:
  499. number_of_shards: 1
  500. number_of_replicas: 1
  501. mappings:
  502. properties:
  503. ip:
  504. type: ip
  505. - do:
  506. bulk:
  507. index: ip_addresses
  508. refresh: true
  509. body: |'''
  510. for (int i = 0; i < 255; i++) {
  511. buildRestTests.setups['iprange'] += """
  512. {"index":{}}
  513. {"ip": "10.0.0.$i"}"""
  514. }
  515. for (int i = 0; i < 5; i++) {
  516. buildRestTests.setups['iprange'] += """
  517. {"index":{}}
  518. {"ip": "9.0.0.$i"}"""
  519. buildRestTests.setups['iprange'] += """
  520. {"index":{}}
  521. {"ip": "11.0.0.$i"}"""
  522. buildRestTests.setups['iprange'] += """
  523. {"index":{}}
  524. {"ip": "12.0.0.$i"}"""
  525. }
  526. // Used by SQL because it looks SQL-ish
  527. buildRestTests.setups['library'] = '''
  528. - do:
  529. indices.create:
  530. index: library
  531. body:
  532. settings:
  533. number_of_shards: 1
  534. number_of_replicas: 1
  535. mappings:
  536. properties:
  537. name:
  538. type: text
  539. fields:
  540. keyword:
  541. type: keyword
  542. author:
  543. type: text
  544. fields:
  545. keyword:
  546. type: keyword
  547. release_date:
  548. type: date
  549. page_count:
  550. type: short
  551. - do:
  552. bulk:
  553. index: library
  554. refresh: true
  555. body: |
  556. {"index":{"_id": "Leviathan Wakes"}}
  557. {"name": "Leviathan Wakes", "author": "James S.A. Corey", "release_date": "2011-06-02", "page_count": 561}
  558. {"index":{"_id": "Hyperion"}}
  559. {"name": "Hyperion", "author": "Dan Simmons", "release_date": "1989-05-26", "page_count": 482}
  560. {"index":{"_id": "Dune"}}
  561. {"name": "Dune", "author": "Frank Herbert", "release_date": "1965-06-01", "page_count": 604}
  562. {"index":{"_id": "Dune Messiah"}}
  563. {"name": "Dune Messiah", "author": "Frank Herbert", "release_date": "1969-10-15", "page_count": 331}
  564. {"index":{"_id": "Children of Dune"}}
  565. {"name": "Children of Dune", "author": "Frank Herbert", "release_date": "1976-04-21", "page_count": 408}
  566. {"index":{"_id": "God Emperor of Dune"}}
  567. {"name": "God Emperor of Dune", "author": "Frank Herbert", "release_date": "1981-05-28", "page_count": 454}
  568. {"index":{"_id": "Consider Phlebas"}}
  569. {"name": "Consider Phlebas", "author": "Iain M. Banks", "release_date": "1987-04-23", "page_count": 471}
  570. {"index":{"_id": "Pandora's Star"}}
  571. {"name": "Pandora's Star", "author": "Peter F. Hamilton", "release_date": "2004-03-02", "page_count": 768}
  572. {"index":{"_id": "Revelation Space"}}
  573. {"name": "Revelation Space", "author": "Alastair Reynolds", "release_date": "2000-03-15", "page_count": 585}
  574. {"index":{"_id": "A Fire Upon the Deep"}}
  575. {"name": "A Fire Upon the Deep", "author": "Vernor Vinge", "release_date": "1992-06-01", "page_count": 613}
  576. {"index":{"_id": "Ender's Game"}}
  577. {"name": "Ender's Game", "author": "Orson Scott Card", "release_date": "1985-06-01", "page_count": 324}
  578. {"index":{"_id": "1984"}}
  579. {"name": "1984", "author": "George Orwell", "release_date": "1985-06-01", "page_count": 328}
  580. {"index":{"_id": "Fahrenheit 451"}}
  581. {"name": "Fahrenheit 451", "author": "Ray Bradbury", "release_date": "1953-10-15", "page_count": 227}
  582. {"index":{"_id": "Brave New World"}}
  583. {"name": "Brave New World", "author": "Aldous Huxley", "release_date": "1932-06-01", "page_count": 268}
  584. {"index":{"_id": "Foundation"}}
  585. {"name": "Foundation", "author": "Isaac Asimov", "release_date": "1951-06-01", "page_count": 224}
  586. {"index":{"_id": "The Giver"}}
  587. {"name": "The Giver", "author": "Lois Lowry", "release_date": "1993-04-26", "page_count": 208}
  588. {"index":{"_id": "Slaughterhouse-Five"}}
  589. {"name": "Slaughterhouse-Five", "author": "Kurt Vonnegut", "release_date": "1969-06-01", "page_count": 275}
  590. {"index":{"_id": "The Hitchhiker's Guide to the Galaxy"}}
  591. {"name": "The Hitchhiker's Guide to the Galaxy", "author": "Douglas Adams", "release_date": "1979-10-12", "page_count": 180}
  592. {"index":{"_id": "Snow Crash"}}
  593. {"name": "Snow Crash", "author": "Neal Stephenson", "release_date": "1992-06-01", "page_count": 470}
  594. {"index":{"_id": "Neuromancer"}}
  595. {"name": "Neuromancer", "author": "William Gibson", "release_date": "1984-07-01", "page_count": 271}
  596. {"index":{"_id": "The Handmaid's Tale"}}
  597. {"name": "The Handmaid's Tale", "author": "Margaret Atwood", "release_date": "1985-06-01", "page_count": 311}
  598. {"index":{"_id": "Starship Troopers"}}
  599. {"name": "Starship Troopers", "author": "Robert A. Heinlein", "release_date": "1959-12-01", "page_count": 335}
  600. {"index":{"_id": "The Left Hand of Darkness"}}
  601. {"name": "The Left Hand of Darkness", "author": "Ursula K. Le Guin", "release_date": "1969-06-01", "page_count": 304}
  602. {"index":{"_id": "The Moon is a Harsh Mistress"}}
  603. {"name": "The Moon is a Harsh Mistress", "author": "Robert A. Heinlein", "release_date": "1966-04-01", "page_count": 288}
  604. '''
  605. buildRestTests.setups['sensor_rollup_job'] = '''
  606. - do:
  607. indices.create:
  608. index: sensor-1
  609. body:
  610. settings:
  611. number_of_shards: 1
  612. number_of_replicas: 0
  613. mappings:
  614. properties:
  615. timestamp:
  616. type: date
  617. temperature:
  618. type: long
  619. voltage:
  620. type: float
  621. node:
  622. type: keyword
  623. - do:
  624. raw:
  625. method: PUT
  626. path: _rollup/job/sensor
  627. body: >
  628. {
  629. "index_pattern": "sensor-*",
  630. "rollup_index": "sensor_rollup",
  631. "cron": "*/30 * * * * ?",
  632. "page_size" :1000,
  633. "groups" : {
  634. "date_histogram": {
  635. "field": "timestamp",
  636. "fixed_interval": "1h",
  637. "delay": "7d"
  638. },
  639. "terms": {
  640. "fields": ["node"]
  641. }
  642. },
  643. "metrics": [
  644. {
  645. "field": "temperature",
  646. "metrics": ["min", "max", "sum"]
  647. },
  648. {
  649. "field": "voltage",
  650. "metrics": ["avg"]
  651. }
  652. ]
  653. }
  654. '''
  655. buildRestTests.setups['sensor_started_rollup_job'] = '''
  656. - do:
  657. indices.create:
  658. index: sensor-1
  659. body:
  660. settings:
  661. number_of_shards: 1
  662. number_of_replicas: 0
  663. mappings:
  664. properties:
  665. timestamp:
  666. type: date
  667. temperature:
  668. type: long
  669. voltage:
  670. type: float
  671. node:
  672. type: keyword
  673. - do:
  674. bulk:
  675. index: sensor-1
  676. refresh: true
  677. body: |
  678. {"index":{}}
  679. {"timestamp": 1516729294000, "temperature": 200, "voltage": 5.2, "node": "a"}
  680. {"index":{}}
  681. {"timestamp": 1516642894000, "temperature": 201, "voltage": 5.8, "node": "b"}
  682. {"index":{}}
  683. {"timestamp": 1516556494000, "temperature": 202, "voltage": 5.1, "node": "a"}
  684. {"index":{}}
  685. {"timestamp": 1516470094000, "temperature": 198, "voltage": 5.6, "node": "b"}
  686. {"index":{}}
  687. {"timestamp": 1516383694000, "temperature": 200, "voltage": 4.2, "node": "c"}
  688. {"index":{}}
  689. {"timestamp": 1516297294000, "temperature": 202, "voltage": 4.0, "node": "c"}
  690. - do:
  691. raw:
  692. method: PUT
  693. path: _rollup/job/sensor
  694. body: >
  695. {
  696. "index_pattern": "sensor-*",
  697. "rollup_index": "sensor_rollup",
  698. "cron": "* * * * * ?",
  699. "page_size" :1000,
  700. "groups" : {
  701. "date_histogram": {
  702. "field": "timestamp",
  703. "fixed_interval": "1h",
  704. "delay": "7d"
  705. },
  706. "terms": {
  707. "fields": ["node"]
  708. }
  709. },
  710. "metrics": [
  711. {
  712. "field": "temperature",
  713. "metrics": ["min", "max", "sum"]
  714. },
  715. {
  716. "field": "voltage",
  717. "metrics": ["avg"]
  718. }
  719. ]
  720. }
  721. - do:
  722. raw:
  723. method: POST
  724. path: _rollup/job/sensor/_start
  725. '''
  726. buildRestTests.setups['sensor_index'] = '''
  727. - do:
  728. indices.create:
  729. index: sensor-1
  730. body:
  731. settings:
  732. number_of_shards: 1
  733. number_of_replicas: 0
  734. mappings:
  735. properties:
  736. timestamp:
  737. type: date
  738. temperature:
  739. type: long
  740. voltage:
  741. type: float
  742. node:
  743. type: keyword
  744. load:
  745. type: double
  746. net_in:
  747. type: long
  748. net_out:
  749. type: long
  750. hostname:
  751. type: keyword
  752. datacenter:
  753. type: keyword
  754. '''
  755. buildRestTests.setups['sensor_prefab_data'] = '''
  756. - do:
  757. indices.create:
  758. index: sensor-1
  759. body:
  760. settings:
  761. number_of_shards: 1
  762. number_of_replicas: 0
  763. mappings:
  764. properties:
  765. timestamp:
  766. type: date
  767. temperature:
  768. type: long
  769. voltage:
  770. type: float
  771. node:
  772. type: keyword
  773. - do:
  774. indices.create:
  775. index: sensor_rollup
  776. body:
  777. settings:
  778. number_of_shards: 1
  779. number_of_replicas: 0
  780. mappings:
  781. properties:
  782. node.terms.value:
  783. type: keyword
  784. temperature.sum.value:
  785. type: double
  786. temperature.max.value:
  787. type: double
  788. temperature.min.value:
  789. type: double
  790. timestamp.date_histogram.time_zone:
  791. type: keyword
  792. timestamp.date_histogram.interval:
  793. type: keyword
  794. timestamp.date_histogram.timestamp:
  795. type: date
  796. timestamp.date_histogram._count:
  797. type: long
  798. voltage.avg.value:
  799. type: double
  800. voltage.avg._count:
  801. type: long
  802. _rollup.id:
  803. type: keyword
  804. _rollup.version:
  805. type: long
  806. _meta:
  807. _rollup:
  808. sensor:
  809. cron: "* * * * * ?"
  810. rollup_index: "sensor_rollup"
  811. index_pattern: "sensor-*"
  812. timeout: "20s"
  813. page_size: 1000
  814. groups:
  815. date_histogram:
  816. delay: "7d"
  817. field: "timestamp"
  818. fixed_interval: "60m"
  819. time_zone: "UTC"
  820. terms:
  821. fields:
  822. - "node"
  823. id: sensor
  824. metrics:
  825. - field: "temperature"
  826. metrics:
  827. - min
  828. - max
  829. - sum
  830. - field: "voltage"
  831. metrics:
  832. - avg
  833. - do:
  834. bulk:
  835. index: sensor_rollup
  836. refresh: true
  837. body: |
  838. {"index":{}}
  839. {"node.terms.value":"b","temperature.sum.value":201.0,"temperature.max.value":201.0,"timestamp.date_histogram.time_zone":"UTC","temperature.min.value":201.0,"timestamp.date_histogram._count":1,"timestamp.date_histogram.interval":"1h","_rollup.computed":["temperature.sum","temperature.min","voltage.avg","temperature.max","node.terms","timestamp.date_histogram"],"voltage.avg.value":5.800000190734863,"node.terms._count":1,"_rollup.version":1,"timestamp.date_histogram.timestamp":1516640400000,"voltage.avg._count":1.0,"_rollup.id":"sensor"}
  840. {"index":{}}
  841. {"node.terms.value":"c","temperature.sum.value":200.0,"temperature.max.value":200.0,"timestamp.date_histogram.time_zone":"UTC","temperature.min.value":200.0,"timestamp.date_histogram._count":1,"timestamp.date_histogram.interval":"1h","_rollup.computed":["temperature.sum","temperature.min","voltage.avg","temperature.max","node.terms","timestamp.date_histogram"],"voltage.avg.value":4.199999809265137,"node.terms._count":1,"_rollup.version":1,"timestamp.date_histogram.timestamp":1516381200000,"voltage.avg._count":1.0,"_rollup.id":"sensor"}
  842. {"index":{}}
  843. {"node.terms.value":"a","temperature.sum.value":202.0,"temperature.max.value":202.0,"timestamp.date_histogram.time_zone":"UTC","temperature.min.value":202.0,"timestamp.date_histogram._count":1,"timestamp.date_histogram.interval":"1h","_rollup.computed":["temperature.sum","temperature.min","voltage.avg","temperature.max","node.terms","timestamp.date_histogram"],"voltage.avg.value":5.099999904632568,"node.terms._count":1,"_rollup.version":1,"timestamp.date_histogram.timestamp":1516554000000,"voltage.avg._count":1.0,"_rollup.id":"sensor"}
  844. {"index":{}}
  845. {"node.terms.value":"a","temperature.sum.value":200.0,"temperature.max.value":200.0,"timestamp.date_histogram.time_zone":"UTC","temperature.min.value":200.0,"timestamp.date_histogram._count":1,"timestamp.date_histogram.interval":"1h","_rollup.computed":["temperature.sum","temperature.min","voltage.avg","temperature.max","node.terms","timestamp.date_histogram"],"voltage.avg.value":5.199999809265137,"node.terms._count":1,"_rollup.version":1,"timestamp.date_histogram.timestamp":1516726800000,"voltage.avg._count":1.0,"_rollup.id":"sensor"}
  846. {"index":{}}
  847. {"node.terms.value":"b","temperature.sum.value":198.0,"temperature.max.value":198.0,"timestamp.date_histogram.time_zone":"UTC","temperature.min.value":198.0,"timestamp.date_histogram._count":1,"timestamp.date_histogram.interval":"1h","_rollup.computed":["temperature.sum","temperature.min","voltage.avg","temperature.max","node.terms","timestamp.date_histogram"],"voltage.avg.value":5.599999904632568,"node.terms._count":1,"_rollup.version":1,"timestamp.date_histogram.timestamp":1516467600000,"voltage.avg._count":1.0,"_rollup.id":"sensor"}
  848. {"index":{}}
  849. {"node.terms.value":"c","temperature.sum.value":202.0,"temperature.max.value":202.0,"timestamp.date_histogram.time_zone":"UTC","temperature.min.value":202.0,"timestamp.date_histogram._count":1,"timestamp.date_histogram.interval":"1h","_rollup.computed":["temperature.sum","temperature.min","voltage.avg","temperature.max","node.terms","timestamp.date_histogram"],"voltage.avg.value":4.0,"node.terms._count":1,"_rollup.version":1,"timestamp.date_histogram.timestamp":1516294800000,"voltage.avg._count":1.0,"_rollup.id":"sensor"}
  850. '''
  851. buildRestTests.setups['sample_job'] = '''
  852. - do:
  853. ml.put_job:
  854. job_id: "sample_job"
  855. body: >
  856. {
  857. "description" : "Very basic job",
  858. "analysis_config" : {
  859. "bucket_span":"10m",
  860. "detectors" :[
  861. {
  862. "function": "count"
  863. }
  864. ]},
  865. "data_description" : {
  866. "time_field":"timestamp",
  867. "time_format": "epoch_ms"
  868. }
  869. }
  870. '''
  871. buildRestTests.setups['farequote_index'] = '''
  872. - do:
  873. indices.create:
  874. index: farequote
  875. body:
  876. settings:
  877. number_of_shards: 1
  878. number_of_replicas: 0
  879. mappings:
  880. metric:
  881. properties:
  882. time:
  883. type: date
  884. responsetime:
  885. type: float
  886. airline:
  887. type: keyword
  888. doc_count:
  889. type: integer
  890. '''
  891. buildRestTests.setups['farequote_data'] = buildRestTests.setups['farequote_index'] + '''
  892. - do:
  893. bulk:
  894. index: farequote
  895. refresh: true
  896. body: |
  897. {"index": {"_id":"1"}}
  898. {"airline":"JZA","responsetime":990.4628,"time":"2016-02-07T00:00:00+0000", "doc_count": 5}
  899. {"index": {"_id":"2"}}
  900. {"airline":"JBU","responsetime":877.5927,"time":"2016-02-07T00:00:00+0000", "doc_count": 23}
  901. {"index": {"_id":"3"}}
  902. {"airline":"KLM","responsetime":1355.4812,"time":"2016-02-07T00:00:00+0000", "doc_count": 42}
  903. '''
  904. buildRestTests.setups['farequote_job'] = buildRestTests.setups['farequote_data'] + '''
  905. - do:
  906. ml.put_job:
  907. job_id: "farequote"
  908. body: >
  909. {
  910. "analysis_config": {
  911. "bucket_span": "60m",
  912. "detectors": [{
  913. "function": "mean",
  914. "field_name": "responsetime",
  915. "by_field_name": "airline"
  916. }],
  917. "summary_count_field_name": "doc_count"
  918. },
  919. "data_description": {
  920. "time_field": "time"
  921. }
  922. }
  923. '''
  924. buildRestTests.setups['farequote_datafeed'] = buildRestTests.setups['farequote_job'] + '''
  925. - do:
  926. ml.put_datafeed:
  927. datafeed_id: "datafeed-farequote"
  928. body: >
  929. {
  930. "job_id":"farequote",
  931. "indexes":"farequote"
  932. }
  933. '''
  934. buildRestTests.setups['server_metrics_index'] = '''
  935. - do:
  936. indices.create:
  937. index: server-metrics
  938. body:
  939. settings:
  940. number_of_shards: 1
  941. number_of_replicas: 0
  942. mappings:
  943. properties:
  944. timestamp:
  945. type: date
  946. total:
  947. type: long
  948. '''
  949. buildRestTests.setups['server_metrics_data'] = buildRestTests.setups['server_metrics_index'] + '''
  950. - do:
  951. bulk:
  952. index: server-metrics
  953. refresh: true
  954. body: |
  955. {"index": {"_id":"1177"}}
  956. {"timestamp":"2017-03-23T13:00:00","total":40476}
  957. {"index": {"_id":"1178"}}
  958. {"timestamp":"2017-03-23T13:00:00","total":15287}
  959. {"index": {"_id":"1179"}}
  960. {"timestamp":"2017-03-23T13:00:00","total":-776}
  961. {"index": {"_id":"1180"}}
  962. {"timestamp":"2017-03-23T13:00:00","total":11366}
  963. {"index": {"_id":"1181"}}
  964. {"timestamp":"2017-03-23T13:00:00","total":3606}
  965. {"index": {"_id":"1182"}}
  966. {"timestamp":"2017-03-23T13:00:00","total":19006}
  967. {"index": {"_id":"1183"}}
  968. {"timestamp":"2017-03-23T13:00:00","total":38613}
  969. {"index": {"_id":"1184"}}
  970. {"timestamp":"2017-03-23T13:00:00","total":19516}
  971. {"index": {"_id":"1185"}}
  972. {"timestamp":"2017-03-23T13:00:00","total":-258}
  973. {"index": {"_id":"1186"}}
  974. {"timestamp":"2017-03-23T13:00:00","total":9551}
  975. {"index": {"_id":"1187"}}
  976. {"timestamp":"2017-03-23T13:00:00","total":11217}
  977. {"index": {"_id":"1188"}}
  978. {"timestamp":"2017-03-23T13:00:00","total":22557}
  979. {"index": {"_id":"1189"}}
  980. {"timestamp":"2017-03-23T13:00:00","total":40508}
  981. {"index": {"_id":"1190"}}
  982. {"timestamp":"2017-03-23T13:00:00","total":11887}
  983. {"index": {"_id":"1191"}}
  984. {"timestamp":"2017-03-23T13:00:00","total":31659}
  985. '''
  986. buildRestTests.setups['server_metrics_job'] = buildRestTests.setups['server_metrics_data'] + '''
  987. - do:
  988. ml.put_job:
  989. job_id: "total-requests"
  990. body: >
  991. {
  992. "description" : "Total sum of requests",
  993. "analysis_config" : {
  994. "bucket_span":"10m",
  995. "detectors" :[
  996. {
  997. "detector_description": "Sum of total",
  998. "function": "sum",
  999. "field_name": "total"
  1000. }
  1001. ]},
  1002. "data_description" : {
  1003. "time_field":"timestamp",
  1004. "time_format": "epoch_ms"
  1005. }
  1006. }
  1007. '''
  1008. buildRestTests.setups['server_metrics_job-raw'] = buildRestTests.setups['server_metrics_data'] + '''
  1009. - do:
  1010. raw:
  1011. method: PUT
  1012. path: _ml/anomaly_detectors/total-requests
  1013. body: >
  1014. {
  1015. "description" : "Total sum of requests",
  1016. "analysis_config" : {
  1017. "bucket_span":"10m",
  1018. "detectors" :[
  1019. {
  1020. "detector_description": "Sum of total",
  1021. "function": "sum",
  1022. "field_name": "total"
  1023. }
  1024. ]},
  1025. "data_description" : {
  1026. "time_field":"timestamp",
  1027. "time_format": "epoch_ms"
  1028. }
  1029. }
  1030. '''
  1031. buildRestTests.setups['server_metrics_datafeed'] = buildRestTests.setups['server_metrics_job'] + '''
  1032. - do:
  1033. ml.put_datafeed:
  1034. datafeed_id: "datafeed-total-requests"
  1035. body: >
  1036. {
  1037. "job_id":"total-requests",
  1038. "indexes":"server-metrics"
  1039. }
  1040. '''
  1041. buildRestTests.setups['server_metrics_datafeed-raw'] = buildRestTests.setups['server_metrics_job-raw'] + '''
  1042. - do:
  1043. raw:
  1044. method: PUT
  1045. path: _ml/datafeeds/datafeed-total-requests
  1046. body: >
  1047. {
  1048. "job_id":"total-requests",
  1049. "indexes":"server-metrics"
  1050. }
  1051. '''
  1052. buildRestTests.setups['server_metrics_openjob'] = buildRestTests.setups['server_metrics_datafeed'] + '''
  1053. - do:
  1054. ml.open_job:
  1055. job_id: "total-requests"
  1056. '''
  1057. buildRestTests.setups['server_metrics_openjob-raw'] = buildRestTests.setups['server_metrics_datafeed-raw'] + '''
  1058. - do:
  1059. raw:
  1060. method: POST
  1061. path: _ml/anomaly_detectors/total-requests/_open
  1062. '''
  1063. buildRestTests.setups['server_metrics_startdf'] = buildRestTests.setups['server_metrics_openjob'] + '''
  1064. - do:
  1065. ml.start_datafeed:
  1066. datafeed_id: "datafeed-total-requests"
  1067. '''
  1068. buildRestTests.setups['calendar_outages'] = '''
  1069. - do:
  1070. ml.put_calendar:
  1071. calendar_id: "planned-outages"
  1072. '''
  1073. buildRestTests.setups['calendar_outages_addevent'] = buildRestTests.setups['calendar_outages'] + '''
  1074. - do:
  1075. ml.post_calendar_events:
  1076. calendar_id: "planned-outages"
  1077. body: >
  1078. { "description": "event 1", "start_time": "2017-12-01T00:00:00Z", "end_time": "2017-12-02T00:00:00Z", "calendar_id": "planned-outages" }
  1079. '''
  1080. buildRestTests.setups['calendar_outages_openjob'] = buildRestTests.setups['server_metrics_openjob'] + '''
  1081. - do:
  1082. ml.put_calendar:
  1083. calendar_id: "planned-outages"
  1084. '''
  1085. buildRestTests.setups['calendar_outages_addjob'] = buildRestTests.setups['server_metrics_openjob'] + '''
  1086. - do:
  1087. ml.put_calendar:
  1088. calendar_id: "planned-outages"
  1089. body: >
  1090. {
  1091. "job_ids": ["total-requests"]
  1092. }
  1093. '''
  1094. buildRestTests.setups['calendar_outages_addevent'] = buildRestTests.setups['calendar_outages_addjob'] + '''
  1095. - do:
  1096. ml.post_calendar_events:
  1097. calendar_id: "planned-outages"
  1098. body: >
  1099. { "events" : [
  1100. { "description": "event 1", "start_time": "1513641600000", "end_time": "1513728000000"},
  1101. { "description": "event 2", "start_time": "1513814400000", "end_time": "1513900800000"},
  1102. { "description": "event 3", "start_time": "1514160000000", "end_time": "1514246400000"}
  1103. ]}
  1104. '''
  1105. // used by median absolute deviation aggregation
  1106. buildRestTests.setups['reviews'] = '''
  1107. - do:
  1108. indices.create:
  1109. index: reviews
  1110. body:
  1111. settings:
  1112. number_of_shards: 1
  1113. number_of_replicas: 0
  1114. mappings:
  1115. properties:
  1116. product:
  1117. type: keyword
  1118. rating:
  1119. type: long
  1120. - do:
  1121. bulk:
  1122. index: reviews
  1123. refresh: true
  1124. body: |
  1125. {"index": {"_id": "1"}}
  1126. {"product": "widget-foo", "rating": 1}
  1127. {"index": {"_id": "2"}}
  1128. {"product": "widget-foo", "rating": 5}
  1129. '''
  1130. buildRestTests.setups['remote_cluster'] = buildRestTests.setups['host'] + '''
  1131. - do:
  1132. cluster.put_settings:
  1133. body:
  1134. persistent:
  1135. cluster.remote.remote_cluster.seeds: $transport_host
  1136. '''
  1137. buildRestTests.setups['remote_cluster_and_leader_index'] = buildRestTests.setups['remote_cluster'] + '''
  1138. - do:
  1139. indices.create:
  1140. index: leader_index
  1141. body:
  1142. settings:
  1143. index.number_of_replicas: 0
  1144. index.number_of_shards: 1
  1145. index.soft_deletes.enabled: true
  1146. '''
  1147. buildRestTests.setups['seats'] = '''
  1148. - do:
  1149. indices.create:
  1150. index: seats
  1151. body:
  1152. settings:
  1153. number_of_shards: 1
  1154. number_of_replicas: 0
  1155. mappings:
  1156. properties:
  1157. theatre:
  1158. type: keyword
  1159. cost:
  1160. type: long
  1161. row:
  1162. type: long
  1163. number:
  1164. type: long
  1165. sold:
  1166. type: boolean
  1167. - do:
  1168. bulk:
  1169. index: seats
  1170. refresh: true
  1171. body: |
  1172. {"index":{"_id": "1"}}
  1173. {"theatre": "Skyline", "cost": 37, "row": 1, "number": 7, "sold": false}
  1174. {"index":{"_id": "2"}}
  1175. {"theatre": "Graye", "cost": 30, "row": 3, "number": 5, "sold": false}
  1176. {"index":{"_id": "3"}}
  1177. {"theatre": "Graye", "cost": 33, "row": 2, "number": 6, "sold": false}
  1178. {"index":{"_id": "4"}}
  1179. {"theatre": "Skyline", "cost": 20, "row": 5, "number": 2, "sold": false}'''
  1180. buildRestTests.setups['kibana_sample_data_ecommerce'] = '''
  1181. - do:
  1182. indices.create:
  1183. index: kibana_sample_data_ecommerce
  1184. body:
  1185. settings:
  1186. number_of_shards: 1
  1187. number_of_replicas: 0
  1188. '''
  1189. buildRestTests.setups['simple_kibana_continuous_pivot'] = buildRestTests.setups['kibana_sample_data_ecommerce'] + '''
  1190. - do:
  1191. raw:
  1192. method: PUT
  1193. path: _transform/simple-kibana-ecomm-pivot
  1194. body: >
  1195. {
  1196. "source": {
  1197. "index": "kibana_sample_data_ecommerce",
  1198. "query": {
  1199. "term": {
  1200. "geoip.continent_name": {
  1201. "value": "Asia"
  1202. }
  1203. }
  1204. }
  1205. },
  1206. "pivot": {
  1207. "group_by": {
  1208. "customer_id": {
  1209. "terms": {
  1210. "field": "customer_id"
  1211. }
  1212. }
  1213. },
  1214. "aggregations": {
  1215. "max_price": {
  1216. "max": {
  1217. "field": "taxful_total_price"
  1218. }
  1219. }
  1220. }
  1221. },
  1222. "description": "Maximum priced ecommerce data",
  1223. "dest": {
  1224. "index": "kibana_sample_data_ecommerce_transform",
  1225. "pipeline": "add_timestamp_pipeline"
  1226. },
  1227. "frequency": "5m",
  1228. "sync": {
  1229. "time": {
  1230. "field": "order_date",
  1231. "delay": "60s"
  1232. }
  1233. }
  1234. }
  1235. '''
  1236. buildRestTests.setups['setup_logdata'] = '''
  1237. - do:
  1238. indices.create:
  1239. index: logdata
  1240. body:
  1241. settings:
  1242. number_of_shards: 1
  1243. number_of_replicas: 1
  1244. mappings:
  1245. properties:
  1246. grade:
  1247. type: byte
  1248. - do:
  1249. bulk:
  1250. index: logdata
  1251. refresh: true
  1252. body: |
  1253. {"index":{}}
  1254. {"grade": 100, "weight": 2}
  1255. {"index":{}}
  1256. {"grade": 50, "weight": 3}
  1257. '''
  1258. buildRestTests.setups['logdata_job'] = buildRestTests.setups['setup_logdata'] + '''
  1259. - do:
  1260. ml.put_data_frame_analytics:
  1261. id: "loganalytics"
  1262. body: >
  1263. {
  1264. "source": {
  1265. "index": "logdata"
  1266. },
  1267. "dest": {
  1268. "index": "logdata_out"
  1269. },
  1270. "analysis": {
  1271. "outlier_detection": {}
  1272. }
  1273. }
  1274. '''
  1275. // Used by snapshot lifecycle management docs
  1276. buildRestTests.setups['setup-repository'] = '''
  1277. - do:
  1278. snapshot.create_repository:
  1279. repository: my_repository
  1280. body:
  1281. type: fs
  1282. settings:
  1283. location: buildDir/cluster/shared/repo
  1284. '''