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
|
2019-11-01 14:33:11 -04:00
|
|
|
import org.elasticsearch.gradle.info.BuildParams
|
2018-04-27 14:04:37 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
2019-04-04 04:41:38 -04:00
|
|
|
testClusters.integTest {
|
2018-05-10 08:02:23 -04:00
|
|
|
// Modules who's integration is explicitly tested in integration tests
|
2019-04-04 04:41:38 -04:00
|
|
|
module file(project(':modules:parent-join').tasks.bundlePlugin.archiveFile)
|
|
|
|
module file(project(':modules:lang-painless').tasks.bundlePlugin.archiveFile)
|
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
|
|
|
}
|
|
|
|
|
2019-04-09 14:52:50 -04:00
|
|
|
test {
|
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 {
|
2019-06-04 16:50:23 -04:00
|
|
|
compile project(":client:rest")
|
|
|
|
compile project(":libs:elasticsearch-ssl-config")
|
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
|
|
|
}
|
|
|
|
|
2019-01-07 10:24:19 -05:00
|
|
|
thirdPartyAudit.ignoreMissingClasses (
|
2016-05-19 12:40:22 -04:00
|
|
|
// 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',
|
2019-01-07 10:24:19 -05:00
|
|
|
)
|
2018-04-27 14:04:37 -04:00
|
|
|
|
2019-01-31 02:06:05 -05:00
|
|
|
forbiddenPatterns {
|
|
|
|
// PKCS#12 file are not UTF-8
|
|
|
|
exclude '**/*.p12'
|
|
|
|
}
|
|
|
|
|
2019-06-06 14:50:06 -04:00
|
|
|
// Support for testing reindex-from-remote against old Elasticsearch 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")
|
2019-04-04 04:41:38 -04:00
|
|
|
integTest.runner {
|
|
|
|
systemProperty "tests.fromOld", "false"
|
|
|
|
}
|
2018-05-01 11:23:18 -04:00
|
|
|
} 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")
|
2019-04-04 04:41:38 -04:00
|
|
|
integTest.runner {
|
|
|
|
systemProperty "tests.fromOld", "false"
|
|
|
|
}
|
2018-04-27 14:04:37 -04:00
|
|
|
} else {
|
|
|
|
/* 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
|
|
|
|
}
|
2019-04-04 04:41:38 -04:00
|
|
|
|
|
|
|
Task fixture = task("oldEs${version}Fixture", type: org.elasticsearch.gradle.test.AntFixture) {
|
2018-04-27 14:04:37 -04:00
|
|
|
dependsOn project.configurations.oldesFixture
|
|
|
|
dependsOn unzip
|
2019-11-01 14:33:11 -04:00
|
|
|
executable = "${BuildParams.runtimeJavaHome}/bin/java"
|
2018-04-27 14:04:37 -04:00
|
|
|
env 'CLASSPATH', "${ -> project.configurations.oldesFixture.asPath }"
|
2019-05-28 13:04:19 -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
|
|
|
}
|
2019-04-04 04:41:38 -04:00
|
|
|
|
|
|
|
integTest {
|
|
|
|
dependsOn fixture
|
|
|
|
runner {
|
|
|
|
systemProperty "tests.fromOld", "true"
|
|
|
|
/* 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
|
2019-04-09 14:52:50 -04:00
|
|
|
* ready. */
|
|
|
|
nonInputProperties.systemProperty "es${version}.port", "${ -> fixture.addressAndPort }"
|
2019-04-04 04:41:38 -04:00
|
|
|
}
|
2018-04-27 14:04:37 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|