2015-11-25 11:58:14 -05:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2018-04-27 14:04:37 -04:00
|
|
|
import org.apache.tools.ant.taskdefs.condition.Os
|
|
|
|
|
|
|
|
import static org.elasticsearch.gradle.BuildPlugin.getJavaHome
|
|
|
|
|
2017-01-19 10:43:53 -05:00
|
|
|
apply plugin: 'elasticsearch.test-with-dependencies'
|
|
|
|
|
2015-11-25 11:58:14 -05:00
|
|
|
esplugin {
|
2016-02-29 10:21:10 -05:00
|
|
|
description 'The Reindex module adds APIs to reindex from one index to another or update documents in place.'
|
2016-02-11 16:27:15 -05:00
|
|
|
classname 'org.elasticsearch.index.reindex.ReindexPlugin'
|
2016-07-14 04:54:24 -04:00
|
|
|
hasClientJar = true
|
2015-11-25 11:58:14 -05:00
|
|
|
}
|
2016-05-19 12:40:22 -04:00
|
|
|
|
Build: Rework integ test setup and shutdown to ensure stop runs when desired (#23304)
Gradle's finalizedBy on tasks only ensures one task runs after another,
but not immediately after. This is problematic for our integration tests
since it allows multiple project's integ test clusters to be
simultaneously. While this has not been a problem thus far (gradle 2.13
happened to keep the finalizedBy tasks close enough that no clusters
were running in parallel), with gradle 3.3 the task graph generation has
changed, and numerous clusters may be running simultaneously, causing
memory pressure, and thus generally slower tests, or even failure if the
system has a limited amount of memory (eg in a vagrant host).
This commit reworks how integ tests are configured. It adds an
`integTestCluster` extension to gradle which is equivalent to the current
`integTest.cluster` and moves the rest test runner task to
`integTestRunner`. The `integTest` task is then just a dummy task,
which depends on the cluster runner task, as well as the cluster stop
task. This means running `integTest` in one project will both run the
rest tests, and shut down the cluster, before running `integTest` in
another project.
2017-02-22 15:43:15 -05:00
|
|
|
integTestCluster {
|
2018-05-10 08:02:23 -04:00
|
|
|
// Modules who's integration is explicitly tested in integration tests
|
|
|
|
module project(':modules:parent-join')
|
|
|
|
module project(':modules:lang-painless')
|
2017-09-25 16:25:27 -04:00
|
|
|
// Whitelist reindexing from the local node so we can test reindex-from-remote.
|
Build: Rework integ test setup and shutdown to ensure stop runs when desired (#23304)
Gradle's finalizedBy on tasks only ensures one task runs after another,
but not immediately after. This is problematic for our integration tests
since it allows multiple project's integ test clusters to be
simultaneously. While this has not been a problem thus far (gradle 2.13
happened to keep the finalizedBy tasks close enough that no clusters
were running in parallel), with gradle 3.3 the task graph generation has
changed, and numerous clusters may be running simultaneously, causing
memory pressure, and thus generally slower tests, or even failure if the
system has a limited amount of memory (eg in a vagrant host).
This commit reworks how integ tests are configured. It adds an
`integTestCluster` extension to gradle which is equivalent to the current
`integTest.cluster` and moves the rest test runner task to
`integTestRunner`. The `integTest` task is then just a dummy task,
which depends on the cluster runner task, as well as the cluster stop
task. This means running `integTest` in one project will both run the
rest tests, and shut down the cluster, before running `integTest` in
another project.
2017-02-22 15:43:15 -05:00
|
|
|
setting 'reindex.remote.whitelist', '127.0.0.1:*'
|
2016-05-19 12:40:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
run {
|
2018-05-10 08:02:23 -04:00
|
|
|
// Modules who's integration is explicitly tested in integration tests
|
|
|
|
module project(':modules:parent-join')
|
|
|
|
module project(':modules:lang-painless')
|
2017-09-25 16:25:27 -04:00
|
|
|
// Whitelist reindexing from the local node so we can test reindex-from-remote.
|
2016-10-18 15:00:49 -04:00
|
|
|
setting 'reindex.remote.whitelist', '127.0.0.1:*'
|
2016-05-19 12:40:22 -04:00
|
|
|
}
|
|
|
|
|
2018-12-19 01:25:20 -05:00
|
|
|
unitTest {
|
2017-10-25 22:05:46 -04:00
|
|
|
/*
|
|
|
|
* We have to disable setting the number of available processors as tests in the
|
|
|
|
* same JVM randomize processors and will step on each other if we allow them to
|
|
|
|
* set the number of available processors as it's set-once in Netty.
|
|
|
|
*/
|
|
|
|
systemProperty 'es.set.netty.runtime.available.processors', 'false'
|
|
|
|
}
|
|
|
|
|
2016-05-19 12:40:22 -04:00
|
|
|
dependencies {
|
2017-07-13 03:44:25 -04:00
|
|
|
compile "org.elasticsearch.client:elasticsearch-rest-client:${version}"
|
2016-07-12 05:08:59 -04:00
|
|
|
// for http - testing reindex from remote
|
2016-07-22 22:26:35 -04:00
|
|
|
testCompile project(path: ':modules:transport-netty4', configuration: 'runtime')
|
2017-05-12 09:58:06 -04:00
|
|
|
// for parent/child testing
|
|
|
|
testCompile project(path: ':modules:parent-join', configuration: 'runtime')
|
2016-05-19 12:40:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
thirdPartyAudit.excludes = [
|
|
|
|
// Commons logging
|
|
|
|
'javax.servlet.ServletContextEvent',
|
|
|
|
'javax.servlet.ServletContextListener',
|
2017-08-25 15:13:12 -04:00
|
|
|
'org.apache.avalon.framework.logger.Logger',
|
|
|
|
'org.apache.log.Hierarchy',
|
|
|
|
'org.apache.log.Logger',
|
2016-05-19 12:40:22 -04:00
|
|
|
]
|
2018-04-27 14:04:37 -04:00
|
|
|
|
2018-09-10 12:29:00 -04:00
|
|
|
// Support for testing reindex-from-remote against old Elaticsearch versions
|
2018-04-27 14:04:37 -04:00
|
|
|
configurations {
|
|
|
|
oldesFixture
|
|
|
|
es2
|
|
|
|
es1
|
|
|
|
es090
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
oldesFixture project(':test:fixtures:old-elasticsearch')
|
|
|
|
/* Right now we just test against the latest version of each major we expect
|
|
|
|
* reindex-from-remote to work against. We could randomize the versions but
|
|
|
|
* that doesn't seem worth it at this point. */
|
|
|
|
es2 'org.elasticsearch.distribution.zip:elasticsearch:2.4.5@zip'
|
|
|
|
es1 'org.elasticsearch:elasticsearch:1.7.6@zip'
|
|
|
|
es090 'org.elasticsearch:elasticsearch:0.90.13@zip'
|
|
|
|
}
|
|
|
|
|
2018-05-01 11:23:18 -04:00
|
|
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|
|
|
logger.warn("Disabling reindex-from-old tests because we can't get the pid file on windows")
|
|
|
|
integTestRunner.systemProperty "tests.fromOld", "false"
|
|
|
|
} else if (rootProject.rootDir.toString().contains(" ")) {
|
|
|
|
logger.warn("Disabling reindex-from-old tests because Elasticsearch 1.7 won't start with spaces in the path")
|
2018-04-27 14:04:37 -04:00
|
|
|
integTestRunner.systemProperty "tests.fromOld", "false"
|
|
|
|
} else {
|
|
|
|
integTestRunner.systemProperty "tests.fromOld", "true"
|
|
|
|
/* Set up tasks to unzip and run the old versions of ES before running the
|
|
|
|
* integration tests. */
|
|
|
|
for (String version : ['2', '1', '090']) {
|
|
|
|
Task unzip = task("unzipEs${version}", type: Sync) {
|
|
|
|
Configuration oldEsDependency = configurations['es' + version]
|
|
|
|
dependsOn oldEsDependency
|
|
|
|
/* Use a closure here to delay resolution of the dependency until we need
|
|
|
|
* it */
|
|
|
|
from {
|
|
|
|
oldEsDependency.collect { zipTree(it) }
|
|
|
|
}
|
|
|
|
into temporaryDir
|
|
|
|
}
|
|
|
|
Task fixture = task("oldEs${version}Fixture",
|
|
|
|
type: org.elasticsearch.gradle.test.AntFixture) {
|
|
|
|
dependsOn project.configurations.oldesFixture
|
|
|
|
dependsOn unzip
|
|
|
|
executable = new File(project.runtimeJavaHome, 'bin/java')
|
|
|
|
env 'CLASSPATH', "${ -> project.configurations.oldesFixture.asPath }"
|
2018-10-19 15:11:48 -04:00
|
|
|
env 'JAVA_HOME', getJavaHome(it, 8)
|
2018-04-27 14:04:37 -04:00
|
|
|
args 'oldes.OldElasticsearch',
|
|
|
|
baseDir,
|
|
|
|
unzip.temporaryDir,
|
|
|
|
version == '090'
|
2018-06-13 06:40:22 -04:00
|
|
|
waitCondition = { fixture, ant ->
|
|
|
|
// the fixture writes the ports file when Elasticsearch's HTTP service
|
|
|
|
// is ready, so we can just wait for the file to exist
|
|
|
|
return fixture.portsFile.exists()
|
|
|
|
}
|
2018-04-27 14:04:37 -04:00
|
|
|
}
|
|
|
|
integTest.dependsOn fixture
|
|
|
|
integTestRunner {
|
|
|
|
/* Use a closure on the string to delay evaluation until right before we
|
|
|
|
* run the integration tests so that we can be sure that the file is
|
|
|
|
* ready. */
|
|
|
|
systemProperty "es${version}.port", "${ -> fixture.addressAndPort }"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|