Skip to content

Commit b336c56

Browse files
committed
Merge remote-tracking branch 'elastic/7.x' into 7x-geoshape-doc-values
2 parents 8c3a1b8 + 19a6c5d commit b336c56

File tree

462 files changed

+13353
-3256
lines changed

Some content is hidden

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

462 files changed

+13353
-3256
lines changed

.ci/dockerOnLinuxExclusions

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ debian-8
99
opensuse-15-1
1010
ol-6.10
1111
ol-7.7
12-
sles-12
12+
sles-12.3 # older version used in Vagrant image
13+
sles-12.4
14+
sles-15.1

TESTING.asciidoc

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -273,34 +273,49 @@ test fixtures. If it's not present those checks will be skipped automatically.
273273

274274
== Testing the REST layer
275275

276-
The available integration tests make use of the java API to communicate with
277-
the elasticsearch nodes, using the internal binary transport (port 9300 by
278-
default).
279-
The REST layer is tested through specific tests that are shared between all
280-
the elasticsearch official clients and consist of YAML files that describe the
276+
The REST layer is tested through specific tests that are executed against
277+
a cluster that is configured and initialized via Gradle. The tests
278+
themselves can be written in either Java or with a YAML based DSL.
279+
280+
YAML based REST tests should be preferred since these are shared between all
281+
the elasticsearch official clients. The YAML based tests describe the
281282
operations to be executed and the obtained results that need to be tested.
282283

283-
The YAML files support various operators defined in the link:/rest-api-spec/src/main/resources/rest-api-spec/test/README.asciidoc[rest-api-spec] and adhere to the link:/rest-api-spec/README.markdown[Elasticsearch REST API JSON specification]
284+
The YAML tests support various operators defined in the link:/rest-api-spec/src/main/resources/rest-api-spec/test/README.asciidoc[rest-api-spec] and adhere to the link:/rest-api-spec/README.markdown[Elasticsearch REST API JSON specification]
285+
In order to run the the YAML tests, the relevant API specification needs
286+
to be on the test classpath. Any gradle project that has support for REST
287+
tests will get the primary API on it's class path. However, to better support
288+
Gradle incremental builds, it is recommended to explicitly declare which
289+
parts of the API the tests depend upon.
290+
291+
For example:
292+
---------------------------------------------------------------------------
293+
restResources {
294+
restApi {
295+
includeCore '_common', 'indices', 'index', 'cluster', 'nodes', 'get', 'ingest'
296+
}
297+
}
298+
---------------------------------------------------------------------------
299+
300+
YAML tests that include x-pack specific APIs need to explicitly declare
301+
which APIs are required through a similar `includeXpack` configuration.
284302

285303
The REST tests are run automatically when executing the "./gradlew check" command. To run only the
286304
REST tests use the following command:
287305

288306
---------------------------------------------------------------------------
289-
./gradlew :distribution:archives:integ-test-zip:integTest \
290-
-Dtests.class="org.elasticsearch.test.rest.*Yaml*IT"
307+
./gradlew :distribution:archives:integ-test-zip:integTestRunner \
308+
--tests "org.elasticsearch.test.rest.IntegTestZipClientYamlTestSuiteIT"
291309
---------------------------------------------------------------------------
292310

293-
A specific test case can be run with
311+
A specific test case can be run with the following command:
294312

295313
---------------------------------------------------------------------------
296-
./gradlew :distribution:archives:integ-test-zip:integTest \
297-
-Dtests.class="org.elasticsearch.test.rest.*Yaml*IT" \
298-
-Dtests.method="test {p0=cat.shards/10_basic/Help}"
314+
./gradlew ':distribution:archives:integ-test-zip:integTestRunner' \
315+
--tests "org.elasticsearch.test.rest.IntegTestZipClientYamlTestSuiteIT" \
316+
-Dtests.method="test {p0=cat.segments/10_basic/Help}"
299317
---------------------------------------------------------------------------
300318

301-
`*Yaml*IT` are the executable test classes that runs all the
302-
yaml suites available within the `rest-api-spec` folder.
303-
304319
The REST tests support all the options provided by the randomized runner, plus the following:
305320

306321
* `tests.rest[true|false]`: determines whether the REST tests need to be run (default) or not.
@@ -494,6 +509,14 @@ version 5.3.2 run:
494509
./gradlew v5.3.2#bwcTest
495510
-------------------------------------------------
496511

512+
Use -Dtest.class and -Dtests.method to run a specific bwcTest test.
513+
For example to run a specific tests from the x-pack rolling upgrade from 7.7.0:
514+
-------------------------------------------------
515+
./gradlew :x-pack:qa:rolling-upgrade:v7.7.0#bwcTest \
516+
-Dtests.class=org.elasticsearch.upgrades.UpgradeClusterClientYamlTestSuiteIT \
517+
-Dtests.method="test {p0=*/40_ml_datafeed_crud/*}"
518+
-------------------------------------------------
519+
497520
Tests are ran for versions that are not yet released but with which the current version will be compatible with.
498521
These are automatically checked out and built from source.
499522
See link:./buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java[VersionCollection]
@@ -547,8 +570,9 @@ There are multiple base classes for tests:
547570
* **`ESIntegTestCase`**: An integration test case that creates a cluster that
548571
might have multiple nodes.
549572
* **`ESRestTestCase`**: An integration tests that interacts with an external
550-
cluster via the REST API. For instance, YAML tests run via sub classes of
551-
`ESRestTestCase`.
573+
cluster via the REST API. This is used for Java based REST tests.
574+
* **`ESClientYamlSuiteTestCase` **: A subclass of `ESRestTestCase` used to run
575+
YAML based REST tests.
552576

553577
=== Good practices
554578

@@ -678,4 +702,4 @@ please see https://esrally.readthedocs.io/en/stable/[Rally's documentation].
678702

679703
The Elasticsearch docs are in AsciiDoc format. You can test and build the docs
680704
locally using the Elasticsearch documentation build process. See
681-
https://github.com/elastic/docs.
705+
https://github.com/elastic/docs.

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ subprojects {
106106
// Projects that should be formatted and checked with Spotless are
107107
// listed here, by project path. Once the number of formatted projects
108108
// is greater than the number of unformatted projects, this can be
109-
// switched to an exclude list, and eventualy removed completely.
109+
// switched to an exclude list, and eventually removed completely.
110110
def projectPathsToFormat = [
111111
':build-tools',
112112
':distribution:tools:java-version-checker',
@@ -193,7 +193,7 @@ task verifyVersions {
193193
throw new GradleException("Must run in online mode to verify versions")
194194
}
195195
// Read the list from maven central.
196-
// Fetch the metadata an parse the xml into Version instances because it's more straight forward here
196+
// Fetch the metadata and parse the xml into Version instances because it's more straight forward here
197197
// rather than bwcVersion ( VersionCollection ).
198198
new URL('https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/maven-metadata.xml').openStream().withStream { s ->
199199
bwcVersions.compareToAuthoritative(

buildSrc/build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ configurations {
7878
compileMinimumRuntimeJava {
7979
targetCompatibility = 8
8080
sourceCompatibility = 8
81+
tasks.withType(JavaCompile).configureEach {
82+
options.encoding = 'UTF-8'
83+
}
8184
}
8285

8386
jar {
@@ -199,6 +202,18 @@ if (project != rootProject) {
199202
}
200203
}
201204

205+
// Track reaper jar as a test input using runtime classpath normalization strategy
206+
tasks.withType(Test).configureEach {
207+
inputs.files(configurations.reaper).withNormalizer(ClasspathNormalizer)
208+
}
209+
210+
normalization {
211+
runtimeClasspath {
212+
// We already include the reaper jar as part of our runtime classpath. Ignore the copy in META-INF.
213+
ignore('META-INF/reaper.jar')
214+
}
215+
}
216+
202217
// TODO: re-enable once randomizedtesting gradle code is published and removed from here
203218
licenseHeaders.enabled = false
204219

buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import org.elasticsearch.gradle.NoticeTask
2525
import org.elasticsearch.gradle.Version
2626
import org.elasticsearch.gradle.VersionProperties
2727
import org.elasticsearch.gradle.info.BuildParams
28+
import org.elasticsearch.gradle.test.rest.RestResourcesPlugin
2829
import org.elasticsearch.gradle.test.RestIntegTestTask
2930
import org.elasticsearch.gradle.testclusters.RunTask
3031
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
@@ -54,6 +55,7 @@ class PluginBuildPlugin implements Plugin<Project> {
5455
void apply(Project project) {
5556
project.pluginManager.apply(BuildPlugin)
5657
project.pluginManager.apply(TestClustersPlugin)
58+
project.pluginManager.apply(RestResourcesPlugin)
5759

5860
PluginPropertiesExtension extension = project.extensions.create(PLUGIN_EXTENSION_NAME, PluginPropertiesExtension, project)
5961
configureDependencies(project)

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

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,19 @@
1818
*/
1919
package org.elasticsearch.gradle.test
2020

21-
import org.elasticsearch.gradle.VersionProperties
22-
import org.elasticsearch.gradle.info.BuildParams
2321
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster
2422
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
25-
import org.elasticsearch.gradle.tool.Boilerplate
2623
import org.gradle.api.DefaultTask
2724
import org.gradle.api.Task
28-
import org.gradle.api.file.FileCopyDetails
29-
import org.gradle.api.tasks.Copy
30-
import org.gradle.api.tasks.Input
3125
import org.gradle.api.tasks.testing.Test
32-
import org.gradle.plugins.ide.idea.IdeaPlugin
26+
3327
/**
3428
* A wrapper task around setting up a cluster and running rest tests.
3529
*/
3630
class RestIntegTestTask extends DefaultTask {
3731

3832
protected Test runner
3933

40-
/** Flag indicating whether the rest tests in the rest spec should be run. */
41-
@Input
42-
Boolean includePackaged = false
43-
4434
RestIntegTestTask() {
4535
runner = project.tasks.create("${name}Runner", RestTestRunnerTask.class)
4636
super.dependsOn(runner)
@@ -68,10 +58,6 @@ class RestIntegTestTask extends DefaultTask {
6858
runner.systemProperty('test.cluster', System.getProperty("tests.cluster"))
6959
}
7060

71-
// copy the rest spec/tests onto the test classpath
72-
Copy copyRestSpec = createCopyRestSpecTask()
73-
project.sourceSets.test.output.builtBy(copyRestSpec)
74-
7561
// this must run after all projects have been configured, so we know any project
7662
// references can be accessed as a fully configured
7763
project.gradle.projectsEvaluated {
@@ -82,11 +68,6 @@ class RestIntegTestTask extends DefaultTask {
8268
}
8369
}
8470

85-
/** Sets the includePackaged property */
86-
public void includePackaged(boolean include) {
87-
includePackaged = include
88-
}
89-
9071
@Override
9172
public Task dependsOn(Object... dependencies) {
9273
runner.dependsOn(dependencies)
@@ -112,37 +93,4 @@ class RestIntegTestTask extends DefaultTask {
11293
project.tasks.getByName("${name}Runner").configure(configure)
11394
}
11495

115-
Copy createCopyRestSpecTask() {
116-
Boilerplate.maybeCreate(project.configurations, 'restSpec') {
117-
project.dependencies.add(
118-
'restSpec',
119-
BuildParams.internal ? project.project(':rest-api-spec') :
120-
"org.elasticsearch:rest-api-spec:${VersionProperties.elasticsearch}"
121-
)
122-
}
123-
124-
return Boilerplate.maybeCreate(project.tasks, 'copyRestSpec', Copy) { Copy copy ->
125-
copy.dependsOn project.configurations.restSpec
126-
copy.into(project.sourceSets.test.output.resourcesDir)
127-
copy.from({ project.zipTree(project.configurations.restSpec.singleFile) }) {
128-
includeEmptyDirs = false
129-
include 'rest-api-spec/**'
130-
filesMatching('rest-api-spec/test/**') { FileCopyDetails details ->
131-
if (includePackaged == false) {
132-
details.exclude()
133-
}
134-
}
135-
}
136-
137-
if (project.plugins.hasPlugin(IdeaPlugin)) {
138-
project.idea {
139-
module {
140-
if (scopes.TEST != null) {
141-
scopes.TEST.plus.add(project.configurations.restSpec)
142-
}
143-
}
144-
}
145-
}
146-
}
147-
}
14896
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask
2626
import org.elasticsearch.gradle.info.BuildParams
2727
import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin
2828
import org.elasticsearch.gradle.precommit.PrecommitTasks
29+
import org.elasticsearch.gradle.test.rest.RestResourcesPlugin
2930
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
3031
import org.gradle.api.InvalidUserDataException
31-
import org.gradle.api.JavaVersion
3232
import org.gradle.api.Plugin
3333
import org.gradle.api.Project
3434
import org.gradle.api.artifacts.Configuration
@@ -42,6 +42,7 @@ import org.gradle.api.tasks.compile.JavaCompile
4242
import org.gradle.api.tasks.testing.Test
4343
import org.gradle.plugins.ide.eclipse.model.EclipseModel
4444
import org.gradle.plugins.ide.idea.model.IdeaModel
45+
4546
/**
4647
* Configures the build to compile tests against Elasticsearch's test framework
4748
* and run REST tests. Use BuildPlugin if you want to build main code as well
@@ -74,6 +75,8 @@ class StandaloneRestTestPlugin implements Plugin<Project> {
7475
// only setup tests to build
7576
SourceSetContainer sourceSets = project.extensions.getByType(SourceSetContainer)
7677
SourceSet testSourceSet = sourceSets.create('test')
78+
// need to apply plugin after test source sets are created
79+
project.pluginManager.apply(RestResourcesPlugin)
7780

7881
project.tasks.withType(Test) { Test test ->
7982
test.testClassesDirs = testSourceSet.output.classesDirs

buildSrc/src/main/java/org/elasticsearch/gradle/docker/DockerSupportService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static Map<String, String> parseOsRelease(final List<String> osReleaseLines) {
220220
// remove optional leading and trailing quotes and whitespace
221221
final String value = parts[1].replaceAll("^['\"]?\\s*", "").replaceAll("\\s*['\"]?$", "");
222222

223-
values.put(key, value);
223+
values.put(key, value.toLowerCase());
224224
});
225225

226226
return values;

buildSrc/src/main/java/org/elasticsearch/gradle/precommit/TestingConventionsTasks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public void doCheck() throws IOException {
250250
Files.write(getSuccessMarker().toPath(), new byte[] {}, StandardOpenOption.CREATE);
251251
} else {
252252
getLogger().error(problems);
253-
throw new IllegalStateException("Testing conventions are not honored");
253+
throw new IllegalStateException(String.format("Testing conventions [%s] are not honored", problems));
254254
}
255255
}
256256

0 commit comments

Comments
 (0)