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
|
2020-04-08 19:47:02 -04:00
|
|
|
import org.elasticsearch.gradle.Architecture
|
|
|
|
import org.elasticsearch.gradle.OS
|
2019-11-01 14:33:11 -04:00
|
|
|
import org.elasticsearch.gradle.info.BuildParams
|
2018-04-27 14:04:37 -04:00
|
|
|
|
2017-01-19 10:43:53 -05:00
|
|
|
apply plugin: 'elasticsearch.test-with-dependencies'
|
2020-04-08 19:47:02 -04:00
|
|
|
apply plugin: 'elasticsearch.jdk-download'
|
2020-07-13 14:53:05 -04:00
|
|
|
apply plugin: 'elasticsearch.yaml-rest-test'
|
2020-07-28 09:39:11 -04:00
|
|
|
apply plugin: 'elasticsearch.java-rest-test'
|
|
|
|
apply plugin: 'elasticsearch.internal-cluster-test'
|
2017-01-19 10:43:53 -05:00
|
|
|
|
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
|
|
|
|
2020-07-13 14:53:05 -04:00
|
|
|
testClusters.all {
|
2018-05-10 08:02:23 -04:00
|
|
|
// Modules who's integration is explicitly tested in integration tests
|
2020-09-03 22:26:44 -04:00
|
|
|
module ':modules:parent-join'
|
|
|
|
module ':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
|
|
|
}
|
|
|
|
|
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 {
|
2020-06-30 09:57:41 -04:00
|
|
|
api project(":client:rest")
|
|
|
|
api project(":libs:elasticsearch-ssl-config")
|
2016-07-12 05:08:59 -04:00
|
|
|
// for http - testing reindex from remote
|
2020-06-30 09:57:41 -04:00
|
|
|
testImplementation project(':modules:transport-netty4')
|
2017-05-12 09:58:06 -04:00
|
|
|
// for parent/child testing
|
2020-06-30 09:57:41 -04:00
|
|
|
testImplementation project(':modules:parent-join')
|
2016-05-19 12:40:22 -04:00
|
|
|
}
|
|
|
|
|
2020-03-19 13:28:59 -04:00
|
|
|
restResources {
|
|
|
|
restApi {
|
2020-04-13 11:53:35 -04:00
|
|
|
includeCore '_common', 'cluster', 'nodes', 'indices', 'index', 'get', 'search', 'mget', 'count',
|
|
|
|
'update_by_query', 'delete_by_query', 'reindex_rethrottle', 'tasks', 'reindex', 'put_script'
|
2020-03-19 13:28:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-14 06:01:23 -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 {
|
2019-11-14 06:01:23 -05:00
|
|
|
// PKCS#12 file are not UTF-8
|
|
|
|
exclude '**/*.p12'
|
2019-01-31 02:06:05 -05:00
|
|
|
}
|
|
|
|
|
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'
|
|
|
|
}
|
|
|
|
|
2020-04-08 19:47:02 -04:00
|
|
|
jdks {
|
|
|
|
legacy {
|
|
|
|
vendor = 'adoptopenjdk'
|
|
|
|
version = '8u242+b08'
|
|
|
|
platform = OS.current().name().toLowerCase()
|
|
|
|
architecture = Architecture.current().name().toLowerCase()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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")
|
2020-08-04 08:46:32 -04:00
|
|
|
javaRestTest {
|
2019-04-04 04:41:38 -04:00
|
|
|
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")
|
2020-08-04 08:46:32 -04:00
|
|
|
javaRestTest {
|
2019-04-04 04:41:38 -04:00
|
|
|
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. */
|
2020-01-27 06:40:27 -05:00
|
|
|
def versions = ['2', '1', '090']
|
|
|
|
if (Os.isFamily(Os.FAMILY_MAC)) {
|
|
|
|
// 0.90 fails sometimes on mac, given that it is so old, let us disable it
|
|
|
|
// see: https://github.com/elastic/elasticsearch/issues/51202
|
|
|
|
versions = ['2', '1']
|
|
|
|
}
|
|
|
|
for (String version : versions) {
|
2018-04-27 14:04:37 -04:00
|
|
|
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) {
|
2020-04-08 19:47:02 -04:00
|
|
|
dependsOn project.configurations.oldesFixture, jdks.legacy
|
2018-04-27 14:04:37 -04:00
|
|
|
dependsOn unzip
|
2019-11-01 14:33:11 -04:00
|
|
|
executable = "${BuildParams.runtimeJavaHome}/bin/java"
|
2019-11-14 06:01:23 -05:00
|
|
|
env 'CLASSPATH', "${-> project.configurations.oldesFixture.asPath}"
|
2020-04-08 19:47:02 -04:00
|
|
|
env 'JAVA_HOME', jdks.legacy.javaHomePath
|
2018-04-27 14:04:37 -04:00
|
|
|
args 'oldes.OldElasticsearch',
|
2019-11-14 06:01:23 -05:00
|
|
|
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
|
|
|
|
2020-07-28 09:39:11 -04:00
|
|
|
javaRestTest {
|
2019-04-04 04:41:38 -04:00
|
|
|
dependsOn fixture
|
|
|
|
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-11-14 06:01:23 -05:00
|
|
|
* ready. */
|
|
|
|
nonInputProperties.systemProperty "es${version}.port", "${-> fixture.addressAndPort}"
|
2018-04-27 14:04:37 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|