build.gradle 47 KB

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