build.gradle 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Licensed to Elasticsearch under one or more contributor
  3. * license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright
  5. * ownership. Elasticsearch licenses this file to you under
  6. * the Apache License, Version 2.0 (the "License"); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. apply plugin: 'elasticsearch.docs-test'
  20. integTest {
  21. cluster {
  22. setting 'script.inline', 'true'
  23. setting 'script.stored', 'true'
  24. setting 'script.max_compilations_per_minute', '1000'
  25. /* Enable regexes in painless so our tests don't complain about example
  26. * snippets that use them. */
  27. setting 'script.painless.regex.enabled', 'true'
  28. Closure configFile = {
  29. extraConfigFile it, "src/test/cluster/config/$it"
  30. }
  31. configFile 'scripts/my_script.js'
  32. configFile 'scripts/my_script.py'
  33. configFile 'userdict_ja.txt'
  34. configFile 'KeywordTokenizer.rbbi'
  35. // Whitelist reindexing from the local node so we can test it.
  36. setting 'reindex.remote.whitelist', 'myself'
  37. }
  38. }
  39. // Build the cluser with all plugins
  40. project.rootProject.subprojects.findAll { it.parent.path == ':plugins' }.each { subproj ->
  41. /* Skip repositories. We just aren't going to be able to test them so it
  42. * doesn't make sense to waste time installing them. */
  43. if (subproj.path.startsWith(':plugins:repository-')) {
  44. return
  45. }
  46. subproj.afterEvaluate { // need to wait until the project has been configured
  47. integTest {
  48. cluster {
  49. plugin subproj.path
  50. }
  51. }
  52. }
  53. }
  54. buildRestTests.docs = fileTree(projectDir) {
  55. // No snippets in here!
  56. exclude 'build.gradle'
  57. // That is where the snippets go, not where they come from!
  58. exclude 'build'
  59. // This file simply doesn't pass yet. We should figure out how to fix it.
  60. exclude 'reference/modules/snapshots.asciidoc'
  61. }
  62. Closure setupTwitter = { String name, int count ->
  63. buildRestTests.setups[name] = '''
  64. - do:
  65. indices.create:
  66. index: twitter
  67. body:
  68. settings:
  69. number_of_shards: 1
  70. number_of_replicas: 1
  71. - do:
  72. bulk:
  73. index: twitter
  74. type: tweet
  75. refresh: true
  76. body: |'''
  77. for (int i = 0; i < count; i++) {
  78. String user, text
  79. if (i == 0) {
  80. user = 'kimchy'
  81. text = 'trying out Elasticsearch'
  82. } else {
  83. user = 'test'
  84. text = "some message with the number $i"
  85. }
  86. buildRestTests.setups[name] += """
  87. {"index":{"_id": "$i"}}
  88. {"user": "$user", "message": "$text", "date": "2009-11-15T14:12:12", "likes": $i}"""
  89. }
  90. }
  91. setupTwitter('twitter', 5)
  92. setupTwitter('big_twitter', 120)
  93. setupTwitter('huge_twitter', 1200)
  94. buildRestTests.setups['host'] = '''
  95. # Fetch the http host. We use the host of the master because we know there will always be a master.
  96. - do:
  97. cluster.state: {}
  98. - set: { master_node: master }
  99. - do:
  100. nodes.info:
  101. metric: [ http ]
  102. - is_true: nodes.$master.http.publish_address
  103. - set: {nodes.$master.http.publish_address: host}
  104. '''
  105. // Used by pipeline aggregation docs
  106. buildRestTests.setups['sales'] = '''
  107. - do:
  108. indices.create:
  109. index: sales
  110. body:
  111. settings:
  112. number_of_shards: 2
  113. number_of_replicas: 1
  114. mappings:
  115. sale:
  116. properties:
  117. type:
  118. type: keyword
  119. - do:
  120. bulk:
  121. index: sales
  122. type: sale
  123. refresh: true
  124. body: |
  125. {"index":{}}
  126. {"date": "2015/01/01 00:00:00", "price": 200, "type": "hat"}
  127. {"index":{}}
  128. {"date": "2015/01/01 00:00:00", "price": 200, "type": "t-shirt"}
  129. {"index":{}}
  130. {"date": "2015/01/01 00:00:00", "price": 150, "type": "bag"}
  131. {"index":{}}
  132. {"date": "2015/02/01 00:00:00", "price": 50, "type": "hat"}
  133. {"index":{}}
  134. {"date": "2015/02/01 00:00:00", "price": 10, "type": "t-shirt"}
  135. {"index":{}}
  136. {"date": "2015/03/01 00:00:00", "price": 200, "type": "hat"}
  137. {"index":{}}
  138. {"date": "2015/03/01 00:00:00", "price": 175, "type": "t-shirt"}'''