85 lines
2.5 KiB
Groovy
85 lines
2.5 KiB
Groovy
/*
|
|
* Licensed to Elasticsearch under one or more contributor
|
|
* license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright
|
|
* ownership. Elasticsearch licenses this file to you under
|
|
* the Apache License, Version 2.0 (the "License"); you may
|
|
* not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the License is distributed on an
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
* KIND, either express or implied. See the License for the
|
|
* specific language governing permissions and limitations
|
|
* under the License.
|
|
*/
|
|
|
|
import org.elasticsearch.gradle.SnippetsTask
|
|
import org.elasticsearch.gradle.SnippetsTask.Snippet
|
|
import org.elasticsearch.gradle.RestTestsFromSnippetsTask
|
|
|
|
apply plugin: 'elasticsearch.rest-test'
|
|
|
|
task listSnippets(type: SnippetsTask) {
|
|
group 'Docs'
|
|
description 'List each snippet'
|
|
perSnippet { println(it) }
|
|
}
|
|
|
|
task listAutoSenseCandidates(type: SnippetsTask) {
|
|
group 'Docs'
|
|
description 'List snippets that probably should be marked // AUTOSENSE'
|
|
perSnippet {
|
|
if (
|
|
it.autoSense // Already marked, nothing to do
|
|
|| it.testResponse // Only commands are autosense
|
|
) {
|
|
return
|
|
}
|
|
List<String> languages = [
|
|
'js', 'json', // These languages should almost always be marked autosense
|
|
'sh', 'shell', // These are often curl commands that should be converted
|
|
]
|
|
if (false == languages.contains(it.language)) {
|
|
return
|
|
}
|
|
println(it)
|
|
}
|
|
}
|
|
|
|
task buildRestTests(type: RestTestsFromSnippetsTask) {
|
|
docs = fileTree(project.projectDir) {
|
|
// No snippets in here!
|
|
exclude 'build.gradle'
|
|
// Remove plugins because they aren't installed during this test. Yet?
|
|
exclude 'plugins'
|
|
// This file simply doesn't pass yet. We should figure out how to fix it.
|
|
exclude 'reference/modules/snapshots.asciidoc'
|
|
}
|
|
Closure setupTwitter = { String name, int count ->
|
|
setups[name] = '''
|
|
- do:
|
|
bulk:
|
|
index: twitter
|
|
type: tweet
|
|
refresh: true
|
|
body: |'''
|
|
for (int i = 0; i < count; i++) {
|
|
setups[name] += """
|
|
{"index":{}}
|
|
{"msg": "some message with the number $i", "date": $i}"""
|
|
}
|
|
}
|
|
setupTwitter('twitter', 5)
|
|
setupTwitter('big_twitter', 120)
|
|
}
|
|
|
|
integTest {
|
|
cluster {
|
|
setting 'script.inline', 'true'
|
|
}
|
|
}
|