build.gradle 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. Closure configFile = {
  26. extraConfigFile it, "src/test/cluster/config/$it"
  27. }
  28. configFile 'scripts/my_script.js'
  29. configFile 'scripts/my_script.py'
  30. configFile 'userdict_ja.txt'
  31. configFile 'KeywordTokenizer.rbbi'
  32. // Whitelist reindexing from the local node so we can test it.
  33. setting 'reindex.remote.whitelist', 'myself'
  34. }
  35. }
  36. // Build the cluser with all plugins
  37. project.rootProject.subprojects.findAll { it.parent.path == ':plugins' }.each { subproj ->
  38. /* Skip repositories. We just aren't going to be able to test them so it
  39. * doesn't make sense to waste time installing them. */
  40. if (subproj.path.startsWith(':plugins:repository-')) {
  41. return
  42. }
  43. subproj.afterEvaluate { // need to wait until the project has been configured
  44. integTest {
  45. cluster {
  46. plugin subproj.path
  47. }
  48. }
  49. }
  50. }
  51. buildRestTests.docs = fileTree(projectDir) {
  52. // No snippets in here!
  53. exclude 'build.gradle'
  54. // That is where the snippets go, not where they come from!
  55. exclude 'build'
  56. // This file simply doesn't pass yet. We should figure out how to fix it.
  57. exclude 'reference/modules/snapshots.asciidoc'
  58. }
  59. Closure setupTwitter = { String name, int count ->
  60. buildRestTests.setups[name] = '''
  61. - do:
  62. indices.create:
  63. index: twitter
  64. body:
  65. settings:
  66. number_of_shards: 1
  67. number_of_replicas: 1
  68. - do:
  69. bulk:
  70. index: twitter
  71. type: tweet
  72. refresh: true
  73. body: |'''
  74. for (int i = 0; i < count; i++) {
  75. String user, text
  76. if (i == 0) {
  77. user = 'kimchy'
  78. text = 'trying out Elasticsearch'
  79. } else {
  80. user = 'test'
  81. text = "some message with the number $i"
  82. }
  83. buildRestTests.setups[name] += """
  84. {"index":{"_id": "$i"}}
  85. {"user": "$user", "message": "$text", "date": "2009-11-15T14:12:12", "likes": $i}"""
  86. }
  87. }
  88. setupTwitter('twitter', 5)
  89. setupTwitter('big_twitter', 120)
  90. buildRestTests.setups['host'] = '''
  91. # Fetch the http host. We use the host of the master because we know there will always be a master.
  92. - do:
  93. cluster.state: {}
  94. - set: { master_node: master }
  95. - do:
  96. nodes.info:
  97. metric: [ http ]
  98. - is_true: nodes.$master.http.publish_address
  99. - set: {nodes.$master.http.publish_address: host}
  100. '''
  101. // Used by pipeline aggregation docs
  102. buildRestTests.setups['sales'] = '''
  103. - do:
  104. indices.create:
  105. index: sales
  106. body:
  107. settings:
  108. number_of_shards: 2
  109. number_of_replicas: 1
  110. mappings:
  111. sale:
  112. properties:
  113. type:
  114. type: keyword
  115. - do:
  116. bulk:
  117. index: sales
  118. type: sale
  119. refresh: true
  120. body: |
  121. {"index":{}}
  122. {"date": "2015/01/01 00:00:00", "price": 200, "type": "hat"}
  123. {"index":{}}
  124. {"date": "2015/01/01 00:00:00", "price": 200, "type": "t-shirt"}
  125. {"index":{}}
  126. {"date": "2015/01/01 00:00:00", "price": 150, "type": "bag"}
  127. {"index":{}}
  128. {"date": "2015/02/01 00:00:00", "price": 50, "type": "hat"}
  129. {"index":{}}
  130. {"date": "2015/02/01 00:00:00", "price": 10, "type": "t-shirt"}
  131. {"index":{}}
  132. {"date": "2015/03/01 00:00:00", "price": 200, "type": "hat"}
  133. {"index":{}}
  134. {"date": "2015/03/01 00:00:00", "price": 175, "type": "t-shirt"}'''