build.gradle 3.2 KB

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