build.gradle 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. import java.nio.charset.StandardCharsets
  2. apply plugin: 'elasticsearch.docs-test'
  3. /* List of files that have snippets that probably should be converted to
  4. * `// CONSOLE` and `// TESTRESPONSE` but have yet to be converted. Try and
  5. * only remove entries from this list. When it is empty we'll remove it
  6. * entirely and have a party! There will be cake and everything.... */
  7. buildRestTests.expectedUnconvertedCandidates = [
  8. 'en/rest-api/watcher/put-watch.asciidoc',
  9. 'en/security/authentication/user-cache.asciidoc',
  10. 'en/security/authorization/run-as-privilege.asciidoc',
  11. 'en/security/ccs-clients-integrations/http.asciidoc',
  12. 'en/rest-api/watcher/stats.asciidoc',
  13. 'en/watcher/example-watches/watching-time-series-data.asciidoc',
  14. ]
  15. dependencies {
  16. testCompile project(path: xpackModule('core'), configuration: 'default')
  17. testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
  18. testCompile project(path: xpackProject('plugin').path, configuration: 'testArtifacts')
  19. }
  20. // copy xpack rest api
  21. File xpackResources = new File(xpackProject('plugin').projectDir, 'src/test/resources')
  22. project.copyRestSpec.from(xpackResources) {
  23. include 'rest-api-spec/api/**'
  24. }
  25. testClusters.integTest {
  26. extraConfigFile 'op-jwks.json', xpackProject('test:idp-fixture').file("oidc/op-jwks.json")
  27. extraConfigFile 'idp-docs-metadata.xml', xpackProject('test:idp-fixture').file("idp/shibboleth-idp/metadata/idp-docs-metadata.xml")
  28. extraConfigFile 'testClient.crt', xpackProject('plugin:security').file("src/test/resources/org/elasticsearch/xpack/security/action/pki_delegation/testClient.crt")
  29. setting 'xpack.security.enabled', 'true'
  30. setting 'xpack.security.authc.api_key.enabled', 'true'
  31. setting 'xpack.security.authc.token.enabled', 'true'
  32. // Disable monitoring exporters for the docs tests
  33. setting 'xpack.monitoring.exporters._local.type', 'local'
  34. setting 'xpack.monitoring.exporters._local.enabled', 'false'
  35. setting 'xpack.license.self_generated.type', 'trial'
  36. setting 'xpack.security.authc.realms.file.file.order', '0'
  37. setting 'xpack.security.authc.realms.native.native.order', '1'
  38. setting 'xpack.security.authc.realms.oidc.oidc1.order', '2'
  39. setting 'xpack.security.authc.realms.oidc.oidc1.op.issuer', 'http://127.0.0.1:8080'
  40. setting 'xpack.security.authc.realms.oidc.oidc1.op.authorization_endpoint', "http://127.0.0.1:8080/c2id-login"
  41. setting 'xpack.security.authc.realms.oidc.oidc1.op.token_endpoint', "http://127.0.0.1:8080/c2id/token"
  42. setting 'xpack.security.authc.realms.oidc.oidc1.op.jwkset_path', 'op-jwks.json'
  43. setting 'xpack.security.authc.realms.oidc.oidc1.rp.redirect_uri', 'https://my.fantastic.rp/cb'
  44. setting 'xpack.security.authc.realms.oidc.oidc1.rp.client_id', 'elasticsearch-rp'
  45. keystore 'xpack.security.authc.realms.oidc.oidc1.rp.client_secret', 'b07efb7a1cf6ec9462afe7b6d3ab55c6c7880262aa61ac28dded292aca47c9a2'
  46. setting 'xpack.security.authc.realms.oidc.oidc1.rp.response_type', 'id_token'
  47. setting 'xpack.security.authc.realms.oidc.oidc1.claims.principal', 'sub'
  48. setting 'xpack.security.authc.realms.pki.pki1.order', '3'
  49. setting 'xpack.security.authc.realms.pki.pki1.certificate_authorities', '[ "testClient.crt" ]'
  50. setting 'xpack.security.authc.realms.pki.pki1.delegation.enabled', 'true'
  51. setting 'xpack.security.authc.realms.saml.saml1.order', '4'
  52. setting 'xpack.security.authc.realms.saml.saml1.idp.entity_id', 'https://my-idp.org'
  53. setting 'xpack.security.authc.realms.saml.saml1.idp.metadata.path', 'idp-docs-metadata.xml'
  54. setting 'xpack.security.authc.realms.saml.saml1.sp.entity_id', 'https://kibana.org'
  55. setting 'xpack.security.authc.realms.saml.saml1.sp.acs', 'https://kibana.org/api/security/v1/saml'
  56. setting 'xpack.security.authc.realms.saml.saml1.attributes.principal', 'uid'
  57. setting 'xpack.security.authc.realms.saml.saml1.attributes.name', 'urn:oid:2.5.4.3'
  58. user username: 'test_admin'
  59. }
  60. buildRestTests.docs = fileTree(projectDir) {
  61. // No snippets in here!
  62. exclude 'build.gradle'
  63. // That is where the snippets go, not where they come from!
  64. exclude 'build'
  65. // These file simply doesn't pass yet. We should figure out how to fix them.
  66. exclude 'en/watcher/reference/actions.asciidoc'
  67. exclude 'en/rest-api/security/ssl.asciidoc'
  68. }
  69. Map<String, String> setups = buildRestTests.setups
  70. setups['my_inactive_watch'] = '''
  71. - do:
  72. watcher.put_watch:
  73. id: "my_watch"
  74. active: false
  75. body: >
  76. {
  77. "trigger": {
  78. "schedule": {
  79. "hourly": {
  80. "minute": [ 0, 5 ]
  81. }
  82. }
  83. },
  84. "input": {
  85. "simple": {
  86. "payload": {
  87. "send": "yes"
  88. }
  89. }
  90. },
  91. "condition": {
  92. "always": {}
  93. },
  94. "actions": {
  95. "test_index": {
  96. "index": {
  97. "index": "test"
  98. }
  99. }
  100. }
  101. }
  102. - match: { _id: "my_watch" }
  103. '''
  104. setups['my_active_watch'] = setups['my_inactive_watch'].replace(
  105. 'active: false', 'active: true')
  106. // Used by SQL because it looks SQL-ish
  107. setups['library'] = '''
  108. - do:
  109. indices.create:
  110. index: library
  111. body:
  112. settings:
  113. number_of_shards: 1
  114. number_of_replicas: 1
  115. mappings:
  116. book:
  117. properties:
  118. name:
  119. type: text
  120. fields:
  121. keyword:
  122. type: keyword
  123. author:
  124. type: text
  125. fields:
  126. keyword:
  127. type: keyword
  128. release_date:
  129. type: date
  130. page_count:
  131. type: short
  132. - do:
  133. bulk:
  134. index: library
  135. type: book
  136. refresh: true
  137. body: |
  138. {"index":{"_id": "Leviathan Wakes"}}
  139. {"name": "Leviathan Wakes", "author": "James S.A. Corey", "release_date": "2011-06-02", "page_count": 561}
  140. {"index":{"_id": "Hyperion"}}
  141. {"name": "Hyperion", "author": "Dan Simmons", "release_date": "1989-05-26", "page_count": 482}
  142. {"index":{"_id": "Dune"}}
  143. {"name": "Dune", "author": "Frank Herbert", "release_date": "1965-06-01", "page_count": 604}
  144. {"index":{"_id": "Dune Messiah"}}
  145. {"name": "Dune Messiah", "author": "Frank Herbert", "release_date": "1969-10-15", "page_count": 331}
  146. {"index":{"_id": "Children of Dune"}}
  147. {"name": "Children of Dune", "author": "Frank Herbert", "release_date": "1976-04-21", "page_count": 408}
  148. {"index":{"_id": "God Emperor of Dune"}}
  149. {"name": "God Emperor of Dune", "author": "Frank Herbert", "release_date": "1981-05-28", "page_count": 454}
  150. {"index":{"_id": "Consider Phlebas"}}
  151. {"name": "Consider Phlebas", "author": "Iain M. Banks", "release_date": "1987-04-23", "page_count": 471}
  152. {"index":{"_id": "Pandora's Star"}}
  153. {"name": "Pandora's Star", "author": "Peter F. Hamilton", "release_date": "2004-03-02", "page_count": 768}
  154. {"index":{"_id": "Revelation Space"}}
  155. {"name": "Revelation Space", "author": "Alastair Reynolds", "release_date": "2000-03-15", "page_count": 585}
  156. {"index":{"_id": "A Fire Upon the Deep"}}
  157. {"name": "A Fire Upon the Deep", "author": "Vernor Vinge", "release_date": "1992-06-01", "page_count": 613}
  158. {"index":{"_id": "Ender's Game"}}
  159. {"name": "Ender's Game", "author": "Orson Scott Card", "release_date": "1985-06-01", "page_count": 324}
  160. {"index":{"_id": "1984"}}
  161. {"name": "1984", "author": "George Orwell", "release_date": "1985-06-01", "page_count": 328}
  162. {"index":{"_id": "Fahrenheit 451"}}
  163. {"name": "Fahrenheit 451", "author": "Ray Bradbury", "release_date": "1953-10-15", "page_count": 227}
  164. {"index":{"_id": "Brave New World"}}
  165. {"name": "Brave New World", "author": "Aldous Huxley", "release_date": "1932-06-01", "page_count": 268}
  166. {"index":{"_id": "Foundation"}}
  167. {"name": "Foundation", "author": "Isaac Asimov", "release_date": "1951-06-01", "page_count": 224}
  168. {"index":{"_id": "The Giver"}}
  169. {"name": "The Giver", "author": "Lois Lowry", "release_date": "1993-04-26", "page_count": 208}
  170. {"index":{"_id": "Slaughterhouse-Five"}}
  171. {"name": "Slaughterhouse-Five", "author": "Kurt Vonnegut", "release_date": "1969-06-01", "page_count": 275}
  172. {"index":{"_id": "The Hitchhiker's Guide to the Galaxy"}}
  173. {"name": "The Hitchhiker's Guide to the Galaxy", "author": "Douglas Adams", "release_date": "1979-10-12", "page_count": 180}
  174. {"index":{"_id": "Snow Crash"}}
  175. {"name": "Snow Crash", "author": "Neal Stephenson", "release_date": "1992-06-01", "page_count": 470}
  176. {"index":{"_id": "Neuromancer"}}
  177. {"name": "Neuromancer", "author": "William Gibson", "release_date": "1984-07-01", "page_count": 271}
  178. {"index":{"_id": "The Handmaid's Tale"}}
  179. {"name": "The Handmaid's Tale", "author": "Margaret Atwood", "release_date": "1985-06-01", "page_count": 311}
  180. {"index":{"_id": "Starship Troopers"}}
  181. {"name": "Starship Troopers", "author": "Robert A. Heinlein", "release_date": "1959-12-01", "page_count": 335}
  182. {"index":{"_id": "The Left Hand of Darkness"}}
  183. {"name": "The Left Hand of Darkness", "author": "Ursula K. Le Guin", "release_date": "1969-06-01", "page_count": 304}
  184. {"index":{"_id": "The Moon is a Harsh Mistress"}}
  185. {"name": "The Moon is a Harsh Mistress", "author": "Robert A. Heinlein", "release_date": "1966-04-01", "page_count": 288}
  186. '''
  187. setups['sample_job'] = '''
  188. - do:
  189. ml.put_job:
  190. job_id: "sample_job"
  191. body: >
  192. {
  193. "description" : "Very basic job",
  194. "analysis_config" : {
  195. "bucket_span":"10m",
  196. "detectors" :[
  197. {
  198. "function": "count"
  199. }
  200. ]},
  201. "data_description" : {
  202. "time_field":"timestamp",
  203. "time_format": "epoch_ms"
  204. }
  205. }
  206. '''
  207. setups['farequote_index'] = '''
  208. - do:
  209. indices.create:
  210. index: farequote
  211. body:
  212. settings:
  213. number_of_shards: 1
  214. number_of_replicas: 0
  215. mappings:
  216. metric:
  217. properties:
  218. time:
  219. type: date
  220. responsetime:
  221. type: float
  222. airline:
  223. type: keyword
  224. doc_count:
  225. type: integer
  226. '''
  227. setups['farequote_data'] = setups['farequote_index'] + '''
  228. - do:
  229. bulk:
  230. index: farequote
  231. type: metric
  232. refresh: true
  233. body: |
  234. {"index": {"_id":"1"}}
  235. {"airline":"JZA","responsetime":990.4628,"time":"2016-02-07T00:00:00+0000", "doc_count": 5}
  236. {"index": {"_id":"2"}}
  237. {"airline":"JBU","responsetime":877.5927,"time":"2016-02-07T00:00:00+0000", "doc_count": 23}
  238. {"index": {"_id":"3"}}
  239. {"airline":"KLM","responsetime":1355.4812,"time":"2016-02-07T00:00:00+0000", "doc_count": 42}
  240. '''
  241. setups['farequote_job'] = setups['farequote_data'] + '''
  242. - do:
  243. ml.put_job:
  244. job_id: "farequote"
  245. body: >
  246. {
  247. "analysis_config": {
  248. "bucket_span": "60m",
  249. "detectors": [{
  250. "function": "mean",
  251. "field_name": "responsetime",
  252. "by_field_name": "airline"
  253. }],
  254. "summary_count_field_name": "doc_count"
  255. },
  256. "data_description": {
  257. "time_field": "time"
  258. }
  259. }
  260. '''
  261. setups['farequote_datafeed'] = setups['farequote_job'] + '''
  262. - do:
  263. ml.put_datafeed:
  264. datafeed_id: "datafeed-farequote"
  265. body: >
  266. {
  267. "job_id":"farequote",
  268. "indexes":"farequote"
  269. }
  270. '''
  271. setups['ml_filter_safe_domains'] = '''
  272. - do:
  273. ml.put_filter:
  274. filter_id: "safe_domains"
  275. body: >
  276. {
  277. "description": "A list of safe domains",
  278. "items": ["*.google.com", "wikipedia.org"]
  279. }
  280. '''
  281. setups['server_metrics_index'] = '''
  282. - do:
  283. indices.create:
  284. index: server-metrics
  285. body:
  286. settings:
  287. number_of_shards: 1
  288. number_of_replicas: 0
  289. mappings:
  290. metric:
  291. properties:
  292. timestamp:
  293. type: date
  294. total:
  295. type: long
  296. '''
  297. setups['server_metrics_data'] = setups['server_metrics_index'] + '''
  298. - do:
  299. bulk:
  300. index: server-metrics
  301. type: metric
  302. refresh: true
  303. body: |
  304. {"index": {"_id":"1177"}}
  305. {"timestamp":"2017-03-23T13:00:00","total":40476}
  306. {"index": {"_id":"1178"}}
  307. {"timestamp":"2017-03-23T13:00:00","total":15287}
  308. {"index": {"_id":"1179"}}
  309. {"timestamp":"2017-03-23T13:00:00","total":-776}
  310. {"index": {"_id":"1180"}}
  311. {"timestamp":"2017-03-23T13:00:00","total":11366}
  312. {"index": {"_id":"1181"}}
  313. {"timestamp":"2017-03-23T13:00:00","total":3606}
  314. {"index": {"_id":"1182"}}
  315. {"timestamp":"2017-03-23T13:00:00","total":19006}
  316. {"index": {"_id":"1183"}}
  317. {"timestamp":"2017-03-23T13:00:00","total":38613}
  318. {"index": {"_id":"1184"}}
  319. {"timestamp":"2017-03-23T13:00:00","total":19516}
  320. {"index": {"_id":"1185"}}
  321. {"timestamp":"2017-03-23T13:00:00","total":-258}
  322. {"index": {"_id":"1186"}}
  323. {"timestamp":"2017-03-23T13:00:00","total":9551}
  324. {"index": {"_id":"1187"}}
  325. {"timestamp":"2017-03-23T13:00:00","total":11217}
  326. {"index": {"_id":"1188"}}
  327. {"timestamp":"2017-03-23T13:00:00","total":22557}
  328. {"index": {"_id":"1189"}}
  329. {"timestamp":"2017-03-23T13:00:00","total":40508}
  330. {"index": {"_id":"1190"}}
  331. {"timestamp":"2017-03-23T13:00:00","total":11887}
  332. {"index": {"_id":"1191"}}
  333. {"timestamp":"2017-03-23T13:00:00","total":31659}
  334. '''
  335. setups['server_metrics_job'] = setups['server_metrics_data'] + '''
  336. - do:
  337. ml.put_job:
  338. job_id: "total-requests"
  339. body: >
  340. {
  341. "description" : "Total sum of requests",
  342. "analysis_config" : {
  343. "bucket_span":"10m",
  344. "detectors" :[
  345. {
  346. "detector_description": "Sum of total",
  347. "function": "sum",
  348. "field_name": "total"
  349. }
  350. ]},
  351. "data_description" : {
  352. "time_field":"timestamp",
  353. "time_format": "epoch_ms"
  354. }
  355. }
  356. '''
  357. setups['server_metrics_datafeed'] = setups['server_metrics_job'] + '''
  358. - do:
  359. ml.put_datafeed:
  360. datafeed_id: "datafeed-total-requests"
  361. body: >
  362. {
  363. "job_id":"total-requests",
  364. "indexes":"server-metrics"
  365. }
  366. '''
  367. setups['server_metrics_openjob'] = setups['server_metrics_datafeed'] + '''
  368. - do:
  369. ml.open_job:
  370. job_id: "total-requests"
  371. '''
  372. setups['server_metrics_startdf'] = setups['server_metrics_openjob'] + '''
  373. - do:
  374. ml.start_datafeed:
  375. datafeed_id: "datafeed-total-requests"
  376. '''
  377. setups['calendar_outages'] = '''
  378. - do:
  379. ml.put_calendar:
  380. calendar_id: "planned-outages"
  381. '''
  382. setups['calendar_outages_addevent'] = setups['calendar_outages'] + '''
  383. - do:
  384. ml.post_calendar_events:
  385. calendar_id: "planned-outages"
  386. body: >
  387. { "description": "event 1", "start_time": "2017-12-01T00:00:00Z", "end_time": "2017-12-02T00:00:00Z", "calendar_id": "planned-outages" }
  388. '''
  389. setups['calendar_outages_openjob'] = setups['server_metrics_openjob'] + '''
  390. - do:
  391. ml.put_calendar:
  392. calendar_id: "planned-outages"
  393. '''
  394. setups['calendar_outages_addjob'] = setups['server_metrics_openjob'] + '''
  395. - do:
  396. ml.put_calendar:
  397. calendar_id: "planned-outages"
  398. body: >
  399. {
  400. "job_ids": ["total-requests"]
  401. }
  402. '''
  403. setups['calendar_outages_addevent'] = setups['calendar_outages_addjob'] + '''
  404. - do:
  405. ml.post_calendar_events:
  406. calendar_id: "planned-outages"
  407. body: >
  408. { "events" : [
  409. { "description": "event 1", "start_time": "1513641600000", "end_time": "1513728000000"},
  410. { "description": "event 2", "start_time": "1513814400000", "end_time": "1513900800000"},
  411. { "description": "event 3", "start_time": "1514160000000", "end_time": "1514246400000"}
  412. ]}
  413. '''
  414. setups['role_mapping'] = '''
  415. - do:
  416. security.put_role_mapping:
  417. name: "mapping1"
  418. body: >
  419. {
  420. "enabled": true,
  421. "roles": [ "user" ],
  422. "rules": { "field": { "username": "*" } }
  423. }
  424. '''
  425. setups['sensor_rollup_job'] = '''
  426. - do:
  427. indices.create:
  428. index: sensor-1
  429. body:
  430. settings:
  431. number_of_shards: 1
  432. number_of_replicas: 0
  433. mappings:
  434. properties:
  435. timestamp:
  436. type: date
  437. temperature:
  438. type: long
  439. voltage:
  440. type: float
  441. node:
  442. type: keyword
  443. - do:
  444. rollup.put_job:
  445. id: "sensor"
  446. body: >
  447. {
  448. "index_pattern": "sensor-*",
  449. "rollup_index": "sensor_rollup",
  450. "cron": "*/30 * * * * ?",
  451. "page_size" :1000,
  452. "groups" : {
  453. "date_histogram": {
  454. "field": "timestamp",
  455. "interval": "1h",
  456. "delay": "7d"
  457. },
  458. "terms": {
  459. "fields": ["node"]
  460. }
  461. },
  462. "metrics": [
  463. {
  464. "field": "temperature",
  465. "metrics": ["min", "max", "sum"]
  466. },
  467. {
  468. "field": "voltage",
  469. "metrics": ["avg"]
  470. }
  471. ]
  472. }
  473. '''
  474. setups['sensor_started_rollup_job'] = '''
  475. - do:
  476. indices.create:
  477. index: sensor-1
  478. body:
  479. settings:
  480. number_of_shards: 1
  481. number_of_replicas: 0
  482. mappings:
  483. properties:
  484. timestamp:
  485. type: date
  486. temperature:
  487. type: long
  488. voltage:
  489. type: float
  490. node:
  491. type: keyword
  492. - do:
  493. bulk:
  494. index: sensor-1
  495. refresh: true
  496. body: |
  497. {"index":{}}
  498. {"timestamp": 1516729294000, "temperature": 200, "voltage": 5.2, "node": "a"}
  499. {"index":{}}
  500. {"timestamp": 1516642894000, "temperature": 201, "voltage": 5.8, "node": "b"}
  501. {"index":{}}
  502. {"timestamp": 1516556494000, "temperature": 202, "voltage": 5.1, "node": "a"}
  503. {"index":{}}
  504. {"timestamp": 1516470094000, "temperature": 198, "voltage": 5.6, "node": "b"}
  505. {"index":{}}
  506. {"timestamp": 1516383694000, "temperature": 200, "voltage": 4.2, "node": "c"}
  507. {"index":{}}
  508. {"timestamp": 1516297294000, "temperature": 202, "voltage": 4.0, "node": "c"}
  509. - do:
  510. rollup.put_job:
  511. id: "sensor"
  512. body: >
  513. {
  514. "index_pattern": "sensor-*",
  515. "rollup_index": "sensor_rollup",
  516. "cron": "* * * * * ?",
  517. "page_size" :1000,
  518. "groups" : {
  519. "date_histogram": {
  520. "field": "timestamp",
  521. "interval": "1h",
  522. "delay": "7d"
  523. },
  524. "terms": {
  525. "fields": ["node"]
  526. }
  527. },
  528. "metrics": [
  529. {
  530. "field": "temperature",
  531. "metrics": ["min", "max", "sum"]
  532. },
  533. {
  534. "field": "voltage",
  535. "metrics": ["avg"]
  536. }
  537. ]
  538. }
  539. - do:
  540. rollup.start_job:
  541. id: "sensor"
  542. '''
  543. setups['sensor_index'] = '''
  544. - do:
  545. indices.create:
  546. index: sensor-1
  547. body:
  548. settings:
  549. number_of_shards: 1
  550. number_of_replicas: 0
  551. mappings:
  552. properties:
  553. timestamp:
  554. type: date
  555. temperature:
  556. type: long
  557. voltage:
  558. type: float
  559. node:
  560. type: keyword
  561. load:
  562. type: double
  563. net_in:
  564. type: long
  565. net_out:
  566. type: long
  567. hostname:
  568. type: keyword
  569. datacenter:
  570. type: keyword
  571. '''
  572. setups['sensor_prefab_data'] = '''
  573. - do:
  574. indices.create:
  575. index: sensor-1
  576. body:
  577. settings:
  578. number_of_shards: 1
  579. number_of_replicas: 0
  580. mappings:
  581. properties:
  582. timestamp:
  583. type: date
  584. temperature:
  585. type: long
  586. voltage:
  587. type: float
  588. node:
  589. type: keyword
  590. - do:
  591. indices.create:
  592. index: sensor_rollup
  593. body:
  594. settings:
  595. number_of_shards: 1
  596. number_of_replicas: 0
  597. mappings:
  598. properties:
  599. node.terms.value:
  600. type: keyword
  601. temperature.sum.value:
  602. type: double
  603. temperature.max.value:
  604. type: double
  605. temperature.min.value:
  606. type: double
  607. timestamp.date_histogram.time_zone:
  608. type: keyword
  609. timestamp.date_histogram.interval:
  610. type: keyword
  611. timestamp.date_histogram.timestamp:
  612. type: date
  613. timestamp.date_histogram._count:
  614. type: long
  615. voltage.avg.value:
  616. type: double
  617. voltage.avg._count:
  618. type: long
  619. _rollup.id:
  620. type: keyword
  621. _rollup.version:
  622. type: long
  623. _meta:
  624. _rollup:
  625. sensor:
  626. cron: "* * * * * ?"
  627. rollup_index: "sensor_rollup"
  628. index_pattern: "sensor-*"
  629. timeout: "20s"
  630. page_size: 1000
  631. groups:
  632. date_histogram:
  633. field: "timestamp"
  634. interval: "7d"
  635. time_zone: "UTC"
  636. terms:
  637. fields:
  638. - "node"
  639. id: sensor
  640. metrics:
  641. - field: "temperature"
  642. metrics:
  643. - min
  644. - max
  645. - sum
  646. - field: "voltage"
  647. metrics:
  648. - avg
  649. - do:
  650. bulk:
  651. index: sensor_rollup
  652. refresh: true
  653. body: |
  654. {"index":{}}
  655. {"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"}
  656. {"index":{}}
  657. {"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"}
  658. {"index":{}}
  659. {"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"}
  660. {"index":{}}
  661. {"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"}
  662. {"index":{}}
  663. {"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"}
  664. {"index":{}}
  665. {"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"}
  666. '''
  667. setups['admin_role'] = '''
  668. - do:
  669. security.put_role:
  670. name: "my_admin_role"
  671. body: >
  672. {
  673. "cluster": ["all"],
  674. "indices": [
  675. {"names": ["index1", "index2" ], "privileges": ["all"], "field_security" : {"grant" : [ "title", "body" ]}}
  676. ],
  677. "run_as": [ "other_user" ],
  678. "metadata" : {"version": 1}
  679. }
  680. '''
  681. setups['jacknich_user'] = '''
  682. - do:
  683. security.put_user:
  684. username: "jacknich"
  685. body: >
  686. {
  687. "password" : "test-password",
  688. "roles" : [ "admin", "other_role1" ],
  689. "full_name" : "Jack Nicholson",
  690. "email" : "jacknich@example.com",
  691. "metadata" : { "intelligence" : 7 }
  692. }
  693. '''
  694. setups['app0102_privileges'] = '''
  695. - do:
  696. security.put_privileges:
  697. body: >
  698. {
  699. "myapp": {
  700. "read": {
  701. "application": "myapp",
  702. "name": "read",
  703. "actions": [
  704. "data:read/*",
  705. "action:login" ],
  706. "metadata": {
  707. "description": "Read access to myapp"
  708. }
  709. }
  710. }
  711. }
  712. '''