build.gradle 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. import org.elasticsearch.gradle.SnippetsTask
  20. import org.elasticsearch.gradle.SnippetsTask.Snippet
  21. import org.elasticsearch.gradle.RestTestsFromSnippetsTask
  22. apply plugin: 'elasticsearch.rest-test'
  23. task listSnippets(type: SnippetsTask) {
  24. group 'Docs'
  25. description 'List each snippet'
  26. perSnippet { println(it) }
  27. }
  28. task listAutoSenseCandidates(type: SnippetsTask) {
  29. group 'Docs'
  30. description 'List snippets that probably should be marked // CONSOLE'
  31. perSnippet {
  32. if (
  33. it.autoSense // Already marked, nothing to do
  34. || it.testResponse // Only commands are autosense
  35. ) {
  36. return
  37. }
  38. List<String> languages = [
  39. 'js', 'json', // These languages should almost always be marked autosense
  40. 'sh', 'shell', // These are often curl commands that should be converted
  41. ]
  42. if (false == languages.contains(it.language)) {
  43. return
  44. }
  45. println(it)
  46. }
  47. }
  48. task buildRestTests(type: RestTestsFromSnippetsTask) {
  49. docs = fileTree(project.projectDir) {
  50. // No snippets in here!
  51. exclude 'build.gradle'
  52. // Remove plugins because they aren't installed during this test. Yet?
  53. exclude 'plugins'
  54. // This file simply doesn't pass yet. We should figure out how to fix it.
  55. exclude 'reference/modules/snapshots.asciidoc'
  56. }
  57. Closure setupTwitter = { String name, int count ->
  58. setups[name] = '''
  59. - do:
  60. bulk:
  61. index: twitter
  62. type: tweet
  63. refresh: true
  64. body: |'''
  65. for (int i = 0; i < count; i++) {
  66. setups[name] += """
  67. {"index":{}}
  68. {"msg": "some message with the number $i", "date": $i}"""
  69. }
  70. }
  71. setupTwitter('twitter', 5)
  72. setupTwitter('big_twitter', 120)
  73. }
  74. integTest {
  75. cluster {
  76. setting 'script.inline', 'true'
  77. }
  78. }