Skip to content

Commit cd6e3f4

Browse files
authored
Merge branch 'master' into keystore
2 parents 42ebfe7 + b9c2c2f commit cd6e3f4

File tree

539 files changed

+9023
-5730
lines changed

Some content is hidden

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

539 files changed

+9023
-5730
lines changed

benchmarks/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ dependencies {
5555
runtime 'org.apache.commons:commons-math3:3.2'
5656
}
5757

58-
compileJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked"
58+
compileJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked,-processing"
5959
// enable the JMH's BenchmarkProcessor to generate the final benchmark classes
6060
// needs to be added separately otherwise Gradle will quote it and javac will fail
6161
compileJava.options.compilerArgs.addAll(["-processor", "org.openjdk.jmh.generators.BenchmarkProcessor"])

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package org.elasticsearch.gradle
2121
import nebula.plugin.extraconfigurations.ProvidedBasePlugin
2222
import org.elasticsearch.gradle.precommit.PrecommitTasks
2323
import org.gradle.api.GradleException
24+
import org.gradle.api.InvalidUserDataException
2425
import org.gradle.api.JavaVersion
2526
import org.gradle.api.Plugin
2627
import org.gradle.api.Project
@@ -54,6 +55,11 @@ class BuildPlugin implements Plugin<Project> {
5455

5556
@Override
5657
void apply(Project project) {
58+
if (project.pluginManager.hasPlugin('elasticsearch.standalone-rest-test')) {
59+
throw new InvalidUserDataException('elasticsearch.standalone-test, '
60+
+ 'elasticearch.standalone-rest-test, and elasticsearch.build '
61+
+ 'are mutually exclusive')
62+
}
5763
project.pluginManager.apply('java')
5864
project.pluginManager.apply('carrotsearch.randomized-testing')
5965
// these plugins add lots of info to our jars

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class DocsTestPlugin extends RestTestPlugin {
3030

3131
@Override
3232
public void apply(Project project) {
33+
project.pluginManager.apply('elasticsearch.standalone-rest-test')
3334
super.apply(project)
3435
Map<String, String> defaultSubstitutions = [
3536
/* These match up with the asciidoc syntax for substitutions but

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ class ClusterConfiguration {
7272
boolean useMinimumMasterNodes = true
7373

7474
@Input
75-
String jvmArgs = "-Xms" + System.getProperty('tests.heap.size', '512m') +
76-
" " + "-Xmx" + System.getProperty('tests.heap.size', '512m') +
77-
" " + System.getProperty('tests.jvm.argline', '')
75+
String jvmArgs = "-ea" +
76+
" " + "-Xms" + System.getProperty('tests.heap.size', '512m') +
77+
" " + "-Xmx" + System.getProperty('tests.heap.size', '512m') +
78+
" " + System.getProperty('tests.jvm.argline', '')
79+
7880

7981
/**
8082
* A closure to call which returns the unicast host to connect to for cluster formation.

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import org.gradle.api.tasks.Delete
3939
import org.gradle.api.tasks.Exec
4040

4141
import java.nio.file.Paths
42+
import java.util.concurrent.TimeUnit
4243

4344
/**
4445
* A helper for creating tasks to build a cluster that is used by a task, and tear down the cluster when the task is finished.
@@ -91,6 +92,8 @@ class ClusterFormationTasks {
9192
configureBwcPluginDependency("${task.name}_elasticsearchBwcPlugins", project, entry.getValue(),
9293
project.configurations.elasticsearchBwcPlugins, config.bwcVersion)
9394
}
95+
project.configurations.elasticsearchBwcDistro.resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
96+
project.configurations.elasticsearchBwcPlugins.resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
9497
}
9598
for (int i = 0; i < config.numNodes; i++) {
9699
// we start N nodes and out of these N nodes there might be M bwc nodes.

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,29 @@
1818
*/
1919
package org.elasticsearch.gradle.test
2020

21+
import org.elasticsearch.gradle.BuildPlugin
22+
import org.gradle.api.InvalidUserDataException
2123
import org.gradle.api.Plugin
2224
import org.gradle.api.Project
2325

24-
/** A plugin to add rest integration tests. Used for qa projects. */
26+
/**
27+
* Adds support for starting an Elasticsearch cluster before running integration
28+
* tests. Used in conjunction with {@link StandaloneRestTestPlugin} for qa
29+
* projects and in conjunction with {@link BuildPlugin} for testing the rest
30+
* client.
31+
*/
2532
public class RestTestPlugin implements Plugin<Project> {
33+
List REQUIRED_PLUGINS = [
34+
'elasticsearch.build',
35+
'elasticsearch.standalone-rest-test']
2636

2737
@Override
2838
public void apply(Project project) {
29-
project.pluginManager.apply(StandaloneTestBasePlugin)
39+
if (false == REQUIRED_PLUGINS.any {project.pluginManager.hasPlugin(it)}) {
40+
throw new InvalidUserDataException('elasticsearch.rest-test '
41+
+ 'requires either elasticsearch.build or '
42+
+ 'elasticsearch.standalone-test')
43+
}
3044

3145
RestIntegTestTask integTest = project.tasks.create('integTest', RestIntegTestTask.class)
3246
integTest.cluster.distribution = 'zip' // rest tests should run with the real zip

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/StandaloneTestBasePlugin.groovy renamed to buildSrc/src/main/groovy/org/elasticsearch/gradle/test/StandaloneRestTestPlugin.groovy

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,26 @@ import com.carrotsearch.gradle.junit4.RandomizedTestingPlugin
2424
import org.elasticsearch.gradle.BuildPlugin
2525
import org.elasticsearch.gradle.VersionProperties
2626
import org.elasticsearch.gradle.precommit.PrecommitTasks
27+
import org.gradle.api.InvalidUserDataException
2728
import org.gradle.api.Plugin
2829
import org.gradle.api.Project
30+
import org.gradle.api.Task
2931
import org.gradle.api.plugins.JavaBasePlugin
3032

31-
/** Configures the build to have a rest integration test. */
32-
public class StandaloneTestBasePlugin implements Plugin<Project> {
33+
/**
34+
* Configures the build to compile tests against Elasticsearch's test framework
35+
* and run REST tests. Use BuildPlugin if you want to build main code as well
36+
* as tests.
37+
*/
38+
public class StandaloneRestTestPlugin implements Plugin<Project> {
3339

3440
@Override
3541
public void apply(Project project) {
42+
if (project.pluginManager.hasPlugin('elasticsearch.build')) {
43+
throw new InvalidUserDataException('elasticsearch.standalone-test, '
44+
+ 'elasticsearch.standalone-test, and elasticsearch.build are '
45+
+ 'mutually exclusive')
46+
}
3647
project.pluginManager.apply(JavaBasePlugin)
3748
project.pluginManager.apply(RandomizedTestingPlugin)
3849

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/StandaloneTestPlugin.groovy

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ import org.gradle.api.Plugin
2525
import org.gradle.api.Project
2626
import org.gradle.api.plugins.JavaBasePlugin
2727

28-
/** A plugin to add tests only. Used for QA tests that run arbitrary unit tests. */
28+
/**
29+
* Configures the build to compile against Elasticsearch's test framework and
30+
* run integration and unit tests. Use BuildPlugin if you want to build main
31+
* code as well as tests. */
2932
public class StandaloneTestPlugin implements Plugin<Project> {
3033

3134
@Override
3235
public void apply(Project project) {
33-
project.pluginManager.apply(StandaloneTestBasePlugin)
36+
project.pluginManager.apply(StandaloneRestTestPlugin)
3437

3538
Map testOptions = [
3639
name: 'test',
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
20+
implementation-class=org.elasticsearch.gradle.test.StandaloneRestTestPlugin

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
<suppress files="org[/\\]elasticsearch[/\\]painless[/\\]antlr[/\\]PainlessLexer\.java" checks="." />
1111
<suppress files="org[/\\]elasticsearch[/\\]painless[/\\]antlr[/\\]PainlessParser(|BaseVisitor|Visitor)\.java" checks="." />
1212

13-
<!-- ThrowableProxy is a forked copy from Log4j to hack around a bug; this can be removed when the hack is removed -->
14-
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]apache[/\\]logging[/\\]log4j[/\\]core[/\\]impl[/\\]ThrowableProxy.java" checks="RegexpSinglelineJava" />
15-
1613
<!-- Hopefully temporary suppression of LineLength on files that don't pass it. We should remove these when we the
1714
files start to pass. -->
1815
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]apache[/\\]lucene[/\\]queries[/\\]BlendedTermQuery.java" checks="LineLength" />
@@ -352,12 +349,10 @@
352349
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]get[/\\]ShardGetService.java" checks="LineLength" />
353350
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]DocumentFieldMappers.java" checks="LineLength" />
354351
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]DocumentMapper.java" checks="LineLength" />
355-
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]DocumentMapperParser.java" checks="LineLength" />
356352
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]DocumentParser.java" checks="LineLength" />
357353
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]FieldMapper.java" checks="LineLength" />
358354
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]FieldTypeLookup.java" checks="LineLength" />
359355
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]MappedFieldType.java" checks="LineLength" />
360-
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]Mapper.java" checks="LineLength" />
361356
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]MapperService.java" checks="LineLength" />
362357
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]Mapping.java" checks="LineLength" />
363358
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]MetadataFieldMapper.java" checks="LineLength" />
@@ -391,7 +386,6 @@
391386
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]QueryBuilders.java" checks="LineLength" />
392387
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]QueryValidationException.java" checks="LineLength" />
393388
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]support[/\\]InnerHitsQueryParserHelper.java" checks="LineLength" />
394-
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]support[/\\]QueryParsers.java" checks="LineLength" />
395389
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]search[/\\]MatchQuery.java" checks="LineLength" />
396390
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]search[/\\]MultiMatchQuery.java" checks="LineLength" />
397391
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]search[/\\]geo[/\\]IndexedGeoBoundingBoxQuery.java" checks="LineLength" />
@@ -1001,7 +995,6 @@
1001995
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]engine[/\\]AssertingSearcher.java" checks="LineLength" />
1002996
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]engine[/\\]MockEngineSupport.java" checks="LineLength" />
1003997
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]hamcrest[/\\]ElasticsearchAssertions.java" checks="LineLength" />
1004-
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]junit[/\\]listeners[/\\]LoggingListener.java" checks="LineLength" />
1005998
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]store[/\\]MockFSDirectoryService.java" checks="LineLength" />
1006999
<suppress files="test[/\\]framework[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]store[/\\]MockFSIndexStore.java" checks="LineLength" />
10071000
<suppress files="core[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]common[/\\]cli[/\\]CliTool.java" checks="LineLength" />

buildSrc/version.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
elasticsearch = 6.0.0-alpha1
2-
lucene = 6.4.0-snapshot-ec38570
2+
lucene = 6.4.0-snapshot-084f7a0
33

44
# optional dependencies
55
spatial4j = 0.6
@@ -20,5 +20,6 @@ commonslogging = 1.1.3
2020
commonscodec = 1.10
2121
hamcrest = 1.3
2222
securemock = 1.2
23+
mocksocket = 1.1
2324
# benchmark dependencies
2425
jmh = 1.17.3

client/rest-high-level/build.gradle

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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.build'
20+
apply plugin: 'elasticsearch.rest-test'
21+
22+
group = 'org.elasticsearch.client'
23+
24+
dependencies {
25+
compile "org.elasticsearch:elasticsearch:${version}"
26+
compile "org.elasticsearch.client:rest:${version}"
27+
28+
testCompile "org.elasticsearch.client:test:${version}"
29+
testCompile "org.elasticsearch.test:framework:${version}"
30+
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
31+
testCompile "junit:junit:${versions.junit}"
32+
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
33+
}
34+
35+
dependencyLicenses {
36+
// Don't check licenses for dependency that are part of the elasticsearch project
37+
// But any other dependency should have its license/notice/sha1
38+
dependencies = project.configurations.runtime.fileCollection {
39+
it.group.startsWith('org.elasticsearch') == false
40+
}
41+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
20+
package org.elasticsearch.client;
21+
22+
import org.apache.commons.logging.Log;
23+
import org.apache.commons.logging.LogFactory;
24+
import org.apache.http.Header;
25+
26+
import java.io.IOException;
27+
import java.util.Objects;
28+
29+
/**
30+
* High level REST client that wraps an instance of the low level {@link RestClient} and allows to build requests and read responses.
31+
* The provided {@link RestClient} is externally built and closed.
32+
*/
33+
public final class RestHighLevelClient {
34+
35+
private static final Log logger = LogFactory.getLog(RestHighLevelClient.class);
36+
37+
private final RestClient client;
38+
39+
public RestHighLevelClient(RestClient client) {
40+
this.client = Objects.requireNonNull(client);
41+
}
42+
43+
public boolean ping(Header... headers) {
44+
try {
45+
client.performRequest("HEAD", "/", headers);
46+
return true;
47+
} catch(IOException exception) {
48+
return false;
49+
}
50+
}
51+
52+
53+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
20+
package org.elasticsearch.client;
21+
22+
import org.elasticsearch.test.rest.ESRestTestCase;
23+
import org.junit.AfterClass;
24+
import org.junit.Before;
25+
26+
import java.io.IOException;
27+
28+
public abstract class ESRestHighLevelClientTestCase extends ESRestTestCase {
29+
30+
private static RestHighLevelClient restHighLevelClient;
31+
32+
@Before
33+
public void initHighLevelClient() throws IOException {
34+
super.initClient();
35+
if (restHighLevelClient == null) {
36+
restHighLevelClient = new RestHighLevelClient(client());
37+
}
38+
}
39+
40+
@AfterClass
41+
public static void cleanupClient() throws IOException {
42+
restHighLevelClient = null;
43+
}
44+
45+
protected static RestHighLevelClient highLevelClient() {
46+
return restHighLevelClient;
47+
}
48+
}

core/src/main/java/org/elasticsearch/common/xcontent/FromXContentBuilder.java renamed to client/rest-high-level/src/test/java/org/elasticsearch/client/MainActionIT.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,11 @@
1717
* under the License.
1818
*/
1919

20-
package org.elasticsearch.common.xcontent;
20+
package org.elasticsearch.client;
2121

22-
import org.elasticsearch.common.ParseFieldMatcher;
22+
public class MainActionIT extends ESRestHighLevelClientTestCase {
2323

24-
import java.io.IOException;
25-
26-
/**
27-
* Indicates that the class supports XContent deserialization.
28-
*/
29-
public interface FromXContentBuilder<T> {
30-
/**
31-
* Parses an object with the type T from parser
32-
*/
33-
T fromXContent(XContentParser parser, ParseFieldMatcher parseFieldMatcher) throws IOException;
24+
public void testPing() {
25+
assertTrue(highLevelClient().ping());
26+
}
3427
}

0 commit comments

Comments
 (0)