build.gradle 47 KB

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