Skip to content

Commit ef7c00f

Browse files
author
Vladimir Dolzhenko
committed
Merge remote-tracking branch 'remotes/origin/master' into allow_auto_create_index_param
2 parents 5a7d5d8 + ca6808e commit ef7c00f

File tree

222 files changed

+5513
-3376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+5513
-3376
lines changed

README.textile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@ h3. Indexing
4848
Let's try and index some twitter like information. First, let's index some tweets (the @twitter@ index will be created automatically):
4949

5050
<pre>
51-
curl -XPUT 'http://localhost:9200/twitter/doc/1?pretty' -H 'Content-Type: application/json' -d '
51+
curl -XPUT 'http://localhost:9200/twitter/_doc/1?pretty' -H 'Content-Type: application/json' -d '
5252
{
5353
"user": "kimchy",
5454
"post_date": "2009-11-15T13:12:00",
5555
"message": "Trying out Elasticsearch, so far so good?"
5656
}'
5757

58-
curl -XPUT 'http://localhost:9200/twitter/doc/2?pretty' -H 'Content-Type: application/json' -d '
58+
curl -XPUT 'http://localhost:9200/twitter/_doc/2?pretty' -H 'Content-Type: application/json' -d '
5959
{
6060
"user": "kimchy",
6161
"post_date": "2009-11-15T14:12:12",
6262
"message": "Another tweet, will it be indexed?"
6363
}'
6464

65-
curl -XPUT 'http://localhost:9200/twitter/doc/3?pretty' -H 'Content-Type: application/json' -d '
65+
curl -XPUT 'http://localhost:9200/twitter/_doc/3?pretty' -H 'Content-Type: application/json' -d '
6666
{
6767
"user": "elastic",
6868
"post_date": "2010-01-15T01:46:38",
@@ -73,9 +73,9 @@ curl -XPUT 'http://localhost:9200/twitter/doc/3?pretty' -H 'Content-Type: applic
7373
Now, let's see if the information was added by GETting it:
7474

7575
<pre>
76-
curl -XGET 'http://localhost:9200/twitter/doc/1?pretty=true'
77-
curl -XGET 'http://localhost:9200/twitter/doc/2?pretty=true'
78-
curl -XGET 'http://localhost:9200/twitter/doc/3?pretty=true'
76+
curl -XGET 'http://localhost:9200/twitter/_doc/1?pretty=true'
77+
curl -XGET 'http://localhost:9200/twitter/_doc/2?pretty=true'
78+
curl -XGET 'http://localhost:9200/twitter/_doc/3?pretty=true'
7979
</pre>
8080

8181
h3. Searching
@@ -133,14 +133,14 @@ Elasticsearch supports multiple indices. In the previous example we used an inde
133133
Another way to define our simple twitter system is to have a different index per user (note, though that each index has an overhead). Here is the indexing curl's in this case:
134134

135135
<pre>
136-
curl -XPUT 'http://localhost:9200/kimchy/doc/1?pretty' -H 'Content-Type: application/json' -d '
136+
curl -XPUT 'http://localhost:9200/kimchy/_doc/1?pretty' -H 'Content-Type: application/json' -d '
137137
{
138138
"user": "kimchy",
139139
"post_date": "2009-11-15T13:12:00",
140140
"message": "Trying out Elasticsearch, so far so good?"
141141
}'
142142

143-
curl -XPUT 'http://localhost:9200/kimchy/doc/2?pretty' -H 'Content-Type: application/json' -d '
143+
curl -XPUT 'http://localhost:9200/kimchy/_doc/2?pretty' -H 'Content-Type: application/json' -d '
144144
{
145145
"user": "kimchy",
146146
"post_date": "2009-11-15T14:12:12",

TESTING.asciidoc

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,39 +77,24 @@ Run a single test case (variants)
7777
./gradlew test "-Dtests.class=*.ClassName"
7878
----------------------------------------------------------
7979

80-
Run all tests in a package and sub-packages
80+
Run all tests in a package and its sub-packages
8181

8282
----------------------------------------------------
8383
./gradlew test "-Dtests.class=org.elasticsearch.package.*"
8484
----------------------------------------------------
8585

86-
Run any test methods that contain 'esi' (like: ...r*esi*ze...).
86+
Run any test methods that contain 'esi' (like: ...r*esi*ze...)
8787

8888
-------------------------------
8989
./gradlew test "-Dtests.method=*esi*"
9090
-------------------------------
9191

92-
You can also filter tests by certain annotations ie:
93-
94-
* `@Nightly` - tests that only run in nightly builds (disabled by default)
95-
* `@Backwards` - backwards compatibility tests (disabled by default)
96-
* `@AwaitsFix` - tests that are waiting for a bugfix (disabled by default)
97-
* `@BadApple` - tests that are known to fail randomly (disabled by default)
98-
99-
Those annotation names can be combined into a filter expression like:
92+
Run all tests that are waiting for a bugfix (disabled by default)
10093

10194
------------------------------------------------
102-
./gradlew test -Dtests.filter="@nightly and not @backwards"
95+
./gradlew test -Dtests.filter=@awaitsfix
10396
------------------------------------------------
10497

105-
to run all nightly test but not the ones that are backwards tests. `tests.filter` supports
106-
the boolean operators `and, or, not` and grouping ie:
107-
108-
109-
---------------------------------------------------------------
110-
./gradlew test -Dtests.filter="@nightly and not(@badapple or @backwards)"
111-
---------------------------------------------------------------
112-
11398
=== Seed and repetitions.
11499

115100
Run with a given seed (seed is a hex-encoded long).
@@ -160,8 +145,6 @@ Test groups can be enabled or disabled (true/false).
160145
Default value provided below in [brackets].
161146

162147
------------------------------------------------------------------
163-
./gradlew test -Dtests.nightly=[false] - nightly test group (@Nightly)
164-
./gradlew test -Dtests.weekly=[false] - weekly tests (@Weekly)
165148
./gradlew test -Dtests.awaitsfix=[false] - known issue (@AwaitsFix)
166149
------------------------------------------------------------------
167150

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ task verifyVersions {
170170
* the enabled state of every bwc task. It should be set back to true
171171
* after the backport of the backcompat code is complete.
172172
*/
173-
final boolean bwc_tests_enabled = true
174-
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
173+
final boolean bwc_tests_enabled = false
174+
final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/34724" /* place a PR link here when committing bwc changes */
175175
if (bwc_tests_enabled == false) {
176176
if (bwc_tests_disabled_issue.isEmpty()) {
177177
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")

buildSrc/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ dependencies {
106106
compile 'org.apache.rat:apache-rat:0.11'
107107
compile "org.elasticsearch:jna:4.5.1"
108108
compile 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
109+
compile 'de.thetaphi:forbiddenapis:2.6'
109110
testCompile "junit:junit:${props.getProperty('junit')}"
110111
}
111112

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,12 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
193193
"$snippet: Use `js` instead of `${snippet.language}`.")
194194
}
195195
if (snippet.testSetup) {
196-
setup(snippet)
196+
testSetup(snippet)
197+
previousTest = snippet
198+
return
199+
}
200+
if (snippet.testTearDown) {
201+
testTearDown(snippet)
197202
previousTest = snippet
198203
return
199204
}
@@ -223,6 +228,10 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
223228
throw new InvalidUserDataException("// TEST[continued] " +
224229
"cannot immediately follow // TESTSETUP: $test")
225230
}
231+
if (previousTest != null && previousTest.testTearDown) {
232+
throw new InvalidUserDataException("// TEST[continued] " +
233+
"cannot immediately follow // TEARDOWN: $test")
234+
}
226235
} else {
227236
current.println('---')
228237
current.println("\"line_$test.start\":")
@@ -259,20 +268,23 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
259268
current.println(" reason: $test.skip")
260269
}
261270
if (test.setup != null) {
262-
// Insert a setup defined outside of the docs
263-
for (String setupName : test.setup.split(',')) {
264-
String setup = setups[setupName]
265-
if (setup == null) {
266-
throw new InvalidUserDataException("Couldn't find setup "
267-
+ "for $test")
268-
}
269-
current.println(setup)
270-
}
271+
setup(test)
271272
}
272273

273274
body(test, false)
274275
}
275276

277+
private void setup(final Snippet snippet) {
278+
// insert a setup defined outside of the docs
279+
for (final String setupName : snippet.setup.split(',')) {
280+
final String setup = setups[setupName]
281+
if (setup == null) {
282+
throw new InvalidUserDataException("Couldn't find setup for $snippet")
283+
}
284+
current.println(setup)
285+
}
286+
}
287+
276288
private void response(Snippet response) {
277289
if (null == response.skip) {
278290
current.println(" - match: ")
@@ -339,14 +351,27 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
339351
}
340352
}
341353

342-
private void setup(Snippet setup) {
343-
if (lastDocsPath == setup.path) {
344-
throw new InvalidUserDataException("$setup: wasn't first")
354+
private void testSetup(Snippet snippet) {
355+
if (lastDocsPath == snippet.path) {
356+
throw new InvalidUserDataException("$snippet: wasn't first")
345357
}
346-
setupCurrent(setup)
358+
setupCurrent(snippet)
347359
current.println('---')
348360
current.println("setup:")
349-
body(setup, true)
361+
if (snippet.setup != null) {
362+
setup(snippet)
363+
}
364+
body(snippet, true)
365+
}
366+
367+
private void testTearDown(Snippet snippet) {
368+
if (previousTest.testSetup == false && lastDocsPath == snippet.path) {
369+
throw new InvalidUserDataException("$snippet must follow test setup or be first")
370+
}
371+
setupCurrent(snippet)
372+
current.println('---')
373+
current.println('teardown:')
374+
body(snippet, true)
350375
}
351376

352377
private void body(Snippet snippet, boolean inSetup) {

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/SnippetsTask.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ public class SnippetsTask extends DefaultTask {
273273
snippet.testSetup = true
274274
return
275275
}
276+
if (line ==~ /\/\/\s*TEARDOWN\s*/) {
277+
snippet.testTearDown = true
278+
return
279+
}
276280
if (snippet == null) {
277281
// Outside
278282
return
@@ -317,6 +321,7 @@ public class SnippetsTask extends DefaultTask {
317321
boolean test = false
318322
boolean testResponse = false
319323
boolean testSetup = false
324+
boolean testTearDown = false
320325
String skip = null
321326
boolean continued = false
322327
String language = null

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
package org.elasticsearch.gradle.precommit
2020

2121
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
22+
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
23+
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
2224
import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask
25+
import org.gradle.api.JavaVersion
2326
import org.gradle.api.Project
2427
import org.gradle.api.Task
2528
import org.gradle.api.plugins.JavaBasePlugin
@@ -33,7 +36,7 @@ class PrecommitTasks {
3336
public static Task create(Project project, boolean includeDependencyLicenses) {
3437
project.configurations.create("forbiddenApisCliJar")
3538
project.dependencies {
36-
forbiddenApisCliJar ('de.thetaphi:forbiddenapis:2.5')
39+
forbiddenApisCliJar ('de.thetaphi:forbiddenapis:2.6')
3740
}
3841

3942
List<Task> precommitTasks = [
@@ -109,47 +112,43 @@ class PrecommitTasks {
109112
}
110113

111114
private static Task configureForbiddenApisCli(Project project) {
112-
Task forbiddenApisCli = project.tasks.create('forbiddenApis')
113-
project.sourceSets.all { sourceSet ->
114-
forbiddenApisCli.dependsOn(
115-
project.tasks.create(sourceSet.getTaskName('forbiddenApis', null), ForbiddenApisCliTask) {
116-
ExportElasticsearchBuildResourcesTask buildResources = project.tasks.getByName('buildResources')
117-
dependsOn(buildResources)
118-
it.sourceSet = sourceSet
119-
javaHome = project.runtimeJavaHome
120-
targetCompatibility = project.compilerJavaVersion
121-
bundledSignatures = [
122-
"jdk-unsafe", "jdk-deprecated", "jdk-non-portable", "jdk-system-out"
123-
]
124-
signaturesFiles = project.files(
125-
buildResources.copy("forbidden/jdk-signatures.txt"),
126-
buildResources.copy("forbidden/es-all-signatures.txt")
127-
)
128-
suppressAnnotations = ['**.SuppressForbidden']
129-
if (sourceSet.name == 'test') {
130-
signaturesFiles += project.files(
131-
buildResources.copy("forbidden/es-test-signatures.txt"),
132-
buildResources.copy("forbidden/http-signatures.txt")
133-
)
134-
} else {
135-
signaturesFiles += project.files(buildResources.copy("forbidden/es-server-signatures.txt"))
136-
}
137-
dependsOn sourceSet.classesTaskName
138-
classesDirs = sourceSet.output.classesDirs
139-
ext.replaceSignatureFiles = { String... names ->
140-
signaturesFiles = project.files(
141-
names.collect { buildResources.copy("forbidden/${it}.txt") }
142-
)
143-
}
144-
ext.addSignatureFiles = { String... names ->
145-
signaturesFiles += project.files(
146-
names.collect { buildResources.copy("forbidden/${it}.txt") }
147-
)
148-
}
149-
}
115+
project.pluginManager.apply(ForbiddenApisPlugin)
116+
ExportElasticsearchBuildResourcesTask buildResources = project.tasks.getByName('buildResources')
117+
project.tasks.withType(CheckForbiddenApis) {
118+
dependsOn(buildResources)
119+
targetCompatibility = project.runtimeJavaVersion >= JavaVersion.VERSION_1_9 ?
120+
project.runtimeJavaVersion.getMajorVersion() :
121+
project.runtimeJavaVersion
122+
bundledSignatures = [
123+
"jdk-unsafe", "jdk-deprecated", "jdk-non-portable", "jdk-system-out"
124+
]
125+
signaturesFiles = project.files(
126+
buildResources.copy("forbidden/jdk-signatures.txt"),
127+
buildResources.copy("forbidden/es-all-signatures.txt")
150128
)
129+
suppressAnnotations = ['**.SuppressForbidden']
130+
if (name.endsWith('Test')) {
131+
signaturesFiles += project.files(
132+
buildResources.copy("forbidden/es-test-signatures.txt"),
133+
buildResources.copy("forbidden/http-signatures.txt")
134+
)
135+
} else {
136+
signaturesFiles += project.files(buildResources.copy("forbidden/es-server-signatures.txt"))
137+
}
138+
ext.replaceSignatureFiles = { String... names ->
139+
signaturesFiles = project.files(
140+
names.collect { buildResources.copy("forbidden/${it}.txt") }
141+
)
142+
}
143+
ext.addSignatureFiles = { String... names ->
144+
signaturesFiles += project.files(
145+
names.collect { buildResources.copy("forbidden/${it}.txt") }
146+
)
147+
}
151148
}
152-
return forbiddenApisCli
149+
Task forbiddenApis = project.tasks.getByName("forbiddenApis")
150+
forbiddenApis.group = ""
151+
return forbiddenApis
153152
}
154153

155154
private static Task configureCheckstyle(Project project) {

0 commit comments

Comments
 (0)