-
Notifications
You must be signed in to change notification settings - Fork 25.2k
/
Copy pathbuild.gradle
194 lines (173 loc) · 8.48 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import org.elasticsearch.gradle.Architecture
import org.elasticsearch.gradle.OS
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.internal.info.BuildParams
import org.elasticsearch.gradle.internal.test.AntFixture
import org.elasticsearch.gradle.transform.UnzipTransform
apply plugin: 'elasticsearch.test-with-dependencies'
apply plugin: 'elasticsearch.jdk-download'
apply plugin: 'elasticsearch.internal-yaml-rest-test'
apply plugin: 'elasticsearch.legacy-java-rest-test'
apply plugin: 'elasticsearch.yaml-rest-compat-test'
apply plugin: 'elasticsearch.internal-cluster-test'
esplugin {
description = 'The Reindex module adds APIs to reindex from one index to another or update documents in place.'
classname = 'org.elasticsearch.reindex.ReindexPlugin'
}
testClusters.configureEach {
// Modules who's integration is explicitly tested in integration tests
module ':modules:parent-join'
module ':modules:lang-painless'
module ':modules:rest-root'
// Whitelist reindexing from the local node so we can test reindex-from-remote.
setting 'reindex.remote.whitelist', '127.0.0.1:*'
}
dependencies {
api project(":client:rest")
api project(":libs:ssl-config")
// for parent/child testing
testImplementation project(':modules:parent-join')
testImplementation project(':modules:rest-root')
clusterModules project(':modules:lang-painless')
clusterModules project(':modules:parent-join')
clusterModules project(":modules:rest-root")
}
restResources {
restApi {
include '_common', 'cluster', 'nodes', 'indices', 'index', 'get', 'search', 'mget', 'count',
'update_by_query', 'delete_by_query', 'reindex_rethrottle', 'tasks', 'reindex', 'put_script', 'bulk', 'info'
}
}
tasks.named("thirdPartyAudit").configure {
ignoreMissingClasses(
// Commons logging
'javax.servlet.ServletContextEvent',
'javax.servlet.ServletContextListener',
'org.apache.avalon.framework.logger.Logger',
'org.apache.log.Hierarchy',
'org.apache.log.Logger',
)
}
tasks.named("forbiddenPatterns").configure {
// PKCS#12 file are not UTF-8
exclude '**/*.p12'
}
// Support for testing reindex-from-remote against old Elasticsearch versions
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'
}
jdks {
legacy {
vendor = 'adoptium'
version = '8u302+b08'
platform = OS.current().name().toLowerCase()
architecture = Architecture.current().name().toLowerCase()
}
}
if (OS.current() == OS.MAC && Architecture.current() == Architecture.AARCH64) {
jdks.legacy.vendor = 'zulu'
jdks.legacy.distributionVersion = '8.56.0.23'
}
if (OS.current() == OS.WINDOWS) {
logger.warn("Disabling reindex-from-old tests because we can't get the pid file on windows")
tasks.named("javaRestTest").configure {
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")
tasks.named("javaRestTest").configure {
systemProperty "tests.fromOld", "false"
}
} else {
/* Register a gradle artifact transformation to unpack resolved elasticsearch distributions. We only resolve
* zip files here. Using artifact transforms allow a better caching of the downloaded distros as the
* transformed (unpacked) distro will be cached by gradle resulting in less unpacking
*
* To avoid testing against too many old versions, always pick first and last version per major
*/
project.getDependencies().registerTransform(UnzipTransform.class, transformSpec -> {
transformSpec.getFrom().attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.ZIP_TYPE);
transformSpec.getTo().attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE);
});
def versions = ['2', '1', '090']
if (OS.current() == OS.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']
}
versions.each { version ->
def oldEsDependency = configurations['es' + version]
oldEsDependency.getAttributes().attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE);
TaskProvider<AntFixture> fixture = tasks.register("oldEs${version}Fixture", AntFixture) {
dependsOn project.configurations.oldesFixture, jdks.legacy, oldEsDependency
executable = "${buildParams.runtimeJavaHome.get()}/bin/java"
def oldesFixtureConfiguration = project.configurations.oldesFixture
env 'CLASSPATH', "${-> oldesFixtureConfiguration.asPath}"
// old versions of Elasticsearch need JAVA_HOME
env 'JAVA_HOME', jdks.legacy.javaHomePath
// If we are running on certain arm systems we need to explicitly set the stack size to overcome JDK page size bug
if (Architecture.current() == Architecture.AARCH64) {
env 'ES_JAVA_OPTS', '-Xss512k'
}
args 'oldes.OldElasticsearch',
baseDir,
"${ -> oldEsDependency.singleFile.getPath()}",
version == '090'
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()
}
}
tasks.named("javaRestTest").configure {
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
* ready. */
nonInputProperties.systemProperty "es${version}.port", fixture.map(f->f.addressAndPort)
}
}
}
tasks.named("yamlRestTestV7CompatTransform").configure { task ->
task.skipTest("reindex/20_validation/reindex without source gives useful error message", "exception with a type. Not much benefit adding _doc there.")
task.skipTest("update_by_query/20_validation/update_by_query without source gives useful error message", "exception with a type. Not much benefit adding _doc there.")
// these tests are all relying on a call to refresh all indices, when they could easily be changed
// in 7.x to call the specific index they want to refresh.
// See https://github.com/elastic/elasticsearch/issues/81188
task.skipTest("delete_by_query/70_throttle/Rethrottle to -1 which turns off throttling", "test relies on system index being non-hidden")
task.skipTest("delete_by_query/80_slices/Multiple slices with rethrottle", "test relies on system index being non-hidden")
task.skipTest("delete_by_query/80_slices/Multiple slices with wait_for_completion=false", "test relies on system index being non-hidden")
task.skipTest("reindex/80_slices/Multiple slices with rethrottle", "test relies on system index being non-hidden")
task.skipTest("reindex/80_slices/Multiple slices with wait_for_completion=false", "test relies on system index being non-hidden")
task.skipTest("update_by_query/70_slices/Multiple slices with rethrottle", "test relies on system index being non-hidden")
task.skipTest("update_by_query/70_slices/Multiple slices with wait_for_completion=false", "test relies on system index being non-hidden")
task.addAllowedWarningRegex("\\[types removal\\].*")
}
tasks.named("yamlRestTestV7CompatTest").configure {
systemProperty 'tests.rest.blacklist', [
'update_by_query/80_scripting/Can\'t change _id',
'update_by_query/80_scripting/Set unsupported operation type',
'update_by_query/80_scripting/Setting bogus context is an error',
].join(',')
}