@@ -3,10 +3,10 @@ import org.elasticsearch.gradle.test.RestIntegTestTask
33import org.elasticsearch.gradle.Version
44
55import java.nio.charset.StandardCharsets
6- import java.util.regex.Matcher
76
87// Apply the java plugin to this project so the sources can be edited in an IDE
9- apply plugin : ' elasticsearch.build'
8+ apply plugin : ' elasticsearch.standalone-test'
9+
1010unitTest. enabled = false
1111
1212dependencies {
@@ -70,8 +70,6 @@ Closure waitWithAuth = { NodeInfo node, AntBuilder ant ->
7070 return tmpFile. exists()
7171}
7272
73- Project mainProject = project
74-
7573String coreFullClusterRestartPath = project(' :qa:full-cluster-restart' ). projectDir. toPath(). resolve(' src/test/java' ). toString()
7674sourceSets {
7775 test {
@@ -89,224 +87,157 @@ forbiddenPatterns {
8987 exclude ' **/system_key'
9088}
9189
92- // tests are pushed down to subprojects
93- testingConventions. enabled = false
94-
95- /**
96- * Subdirectories of this project are test rolling upgrades with various
97- * configuration options based on their name.
98- */
99- subprojects {
100- Matcher m = project. name =~ / with(out)?-system-key/
101- if (false == m. matches()) {
102- throw new InvalidUserDataException (" Invalid project name [${ project.name} ]" )
103- }
104- boolean withSystemKey = m. group(1 ) == null
105-
106- apply plugin : ' elasticsearch.standalone-test'
90+ String outputDir = " ${ buildDir} /generated-resources/${ project.name} "
10791
108- // Use resources from the rolling-upgrade project in subdirectories
109- sourceSets {
110- test {
111- java {
112- srcDirs = [" ${ mainProject.projectDir} /src/test/java" , coreFullClusterRestartPath]
113- }
114- resources {
115- srcDirs = [" ${ mainProject.projectDir} /src/test/resources" ]
116- }
117- }
118- }
119-
120- licenseHeaders {
121- approvedLicenses << ' Apache'
122- }
123-
124- forbiddenPatterns {
125- exclude ' **/system_key'
126- }
127-
128- String outputDir = " ${ buildDir} /generated-resources/${ project.name} "
129-
130- // This is a top level task which we will add dependencies to below.
131- // It is a single task that can be used to backcompat tests against all versions.
132- task bwcTest {
92+ // This is a top level task which we will add dependencies to below.
93+ // It is a single task that can be used to backcompat tests against all versions.
94+ task bwcTest {
13395 description = ' Runs backwards compatibility tests.'
13496 group = ' verification'
135- }
97+ }
13698
137- String output = " ${ buildDir} /generated-resources/${ project.name} "
138- task copyTestNodeKeyMaterial(type : Copy ) {
99+ task copyTestNodeKeyMaterial (type : Copy ) {
139100 from project(' :x-pack:plugin:core' ). files(' src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem' ,
140- ' src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt' ,
141- ' src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks' )
101+ ' src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt' ,
102+ ' src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks' )
142103 into outputDir
143- }
104+ }
144105
145- for (Version version : bwcVersions. indexCompatible) {
106+ for (Version version : bwcVersions. indexCompatible) {
146107 String baseName = " v${ version} "
147108
148109 Task oldClusterTest = tasks. create(name : " ${ baseName} #oldClusterTest" , type : RestIntegTestTask ) {
149- mustRunAfter(precommit)
110+ mustRunAfter(precommit)
150111 }
151112
152113 Object extension = extensions. findByName(" ${ baseName} #oldClusterTestCluster" )
153114 configure(extensions. findByName(" ${ baseName} #oldClusterTestCluster" )) {
154- dependsOn copyTestNodeKeyMaterial
155- if (version. before(' 6.3.0' )) {
156- String depVersion = version;
157- if (project. bwcVersions. unreleased. contains(version)) {
158- depVersion + = " -SNAPSHOT"
159- }
160- mavenPlugin ' x-pack' , " org.elasticsearch.plugin:x-pack:${ depVersion} "
161-
162- }
163- bwcVersion = version
164- numBwcNodes = 2
165- numNodes = 2
166- clusterName = ' full-cluster-restart'
167- String usersCli = version. before(' 6.3.0' ) ? ' bin/x-pack/users' : ' bin/elasticsearch-users'
168- setupCommand ' setupTestUser' , usersCli, ' useradd' , ' test_user' , ' -p' , ' x-pack-test-password' , ' -r' , ' superuser'
169- waitCondition = waitWithAuth
170-
171- // some tests rely on the translog not being flushed
172- setting ' indices.memory.shard_inactive_time' , ' 20m'
173-
174- setting ' xpack.security.enabled' , ' true'
175- setting ' xpack.security.transport.ssl.enabled' , ' true'
176- if (project. inFipsJvm) {
177- setting ' xpack.security.transport.ssl.key' , ' testnode.pem'
178- setting ' xpack.security.transport.ssl.certificate' , ' testnode.crt'
179- keystoreSetting ' xpack.security.transport.ssl.secure_key_passphrase' , ' testnode'
180- } else {
181- setting ' xpack.security.transport.ssl.keystore.path' , ' testnode.jks'
182- setting ' xpack.security.transport.ssl.keystore.password' , ' testnode'
183- }
184- setting ' xpack.license.self_generated.type' , ' trial'
185- dependsOn copyTestNodeKeyMaterial
186- extraConfigFile ' testnode.pem' , new File (outputDir + ' /testnode.pem' )
187- extraConfigFile ' testnode.crt' , new File (outputDir + ' /testnode.crt' )
188- extraConfigFile ' testnode.jks' , new File (outputDir + ' /testnode.jks' )
189- if (withSystemKey) {
190- if (version. onOrAfter(' 5.1.0' ) && version. before(' 6.0.0' )) {
191- // The setting didn't exist until 5.1.0
192- setting ' xpack.security.system_key.required' , ' true'
115+ dependsOn copyTestNodeKeyMaterial
116+ if (version. before(' 6.3.0' )) {
117+ String depVersion = version;
118+ if (project. bwcVersions. unreleased. contains(version)) {
119+ depVersion + = " -SNAPSHOT"
120+ }
121+ mavenPlugin ' x-pack' , " org.elasticsearch.plugin:x-pack:${ depVersion} "
122+
193123 }
194- if (version. onOrAfter(' 6.0.0' )) {
195- keystoreFile ' xpack.watcher.encryption_key' , " ${ mainProject.projectDir} /src/test/resources/system_key"
124+ bwcVersion = version
125+ numBwcNodes = 2
126+ numNodes = 2
127+ clusterName = ' full-cluster-restart'
128+ String usersCli = version. before(' 6.3.0' ) ? ' bin/x-pack/users' : ' bin/elasticsearch-users'
129+ setupCommand ' setupTestUser' , usersCli, ' useradd' , ' test_user' , ' -p' , ' x-pack-test-password' , ' -r' , ' superuser'
130+ waitCondition = waitWithAuth
131+
132+ // some tests rely on the translog not being flushed
133+ setting ' indices.memory.shard_inactive_time' , ' 20m'
134+
135+ setting ' xpack.security.enabled' , ' true'
136+ setting ' xpack.security.transport.ssl.enabled' , ' true'
137+ if (project. inFipsJvm) {
138+ setting ' xpack.security.transport.ssl.key' , ' testnode.pem'
139+ setting ' xpack.security.transport.ssl.certificate' , ' testnode.crt'
140+ keystoreSetting ' xpack.security.transport.ssl.secure_key_passphrase' , ' testnode'
196141 } else {
197- extraConfigFile ' x-pack/system_key' , " ${ mainProject.projectDir} /src/test/resources/system_key"
142+ setting ' xpack.security.transport.ssl.keystore.path' , ' testnode.jks'
143+ setting ' xpack.security.transport.ssl.keystore.password' , ' testnode'
198144 }
145+ setting ' xpack.license.self_generated.type' , ' trial'
146+ dependsOn copyTestNodeKeyMaterial
147+ extraConfigFile ' testnode.pem' , new File (outputDir + ' /testnode.pem' )
148+ extraConfigFile ' testnode.crt' , new File (outputDir + ' /testnode.crt' )
149+ extraConfigFile ' testnode.jks' , new File (outputDir + ' /testnode.jks' )
150+
151+ keystoreFile ' xpack.watcher.encryption_key' , " ${ project.projectDir} /src/test/resources/system_key"
199152 setting ' xpack.watcher.encrypt_sensitive_data' , ' true'
200- }
201153 }
202154
203155 Task oldClusterTestRunner = tasks. getByName(" ${ baseName} #oldClusterTestRunner" )
204156 oldClusterTestRunner. configure {
205- systemProperty ' tests.is_old_cluster' , ' true'
206- systemProperty ' tests.old_cluster_version' , version. toString(). minus(" -SNAPSHOT" )
207- systemProperty ' tests.path.repo' , new File (buildDir, " cluster/shared/repo" )
208- exclude ' org/elasticsearch/upgrades/FullClusterRestartIT.class'
209- exclude ' org/elasticsearch/upgrades/FullClusterRestartSettingsUpgradeIT.class'
210- exclude ' org/elasticsearch/upgrades/QueryBuilderBWCIT.class'
157+ systemProperty ' tests.is_old_cluster' , ' true'
158+ systemProperty ' tests.old_cluster_version' , version. toString(). minus(" -SNAPSHOT" )
159+ systemProperty ' tests.path.repo' , new File (buildDir, " cluster/shared/repo" )
160+ exclude ' org/elasticsearch/upgrades/FullClusterRestartIT.class'
161+ exclude ' org/elasticsearch/upgrades/FullClusterRestartSettingsUpgradeIT.class'
162+ exclude ' org/elasticsearch/upgrades/QueryBuilderBWCIT.class'
211163 }
212164
213165 Task upgradedClusterTest = tasks. create(name : " ${ baseName} #upgradedClusterTest" , type : RestIntegTestTask )
214166
215167 configure(extensions. findByName(" ${ baseName} #upgradedClusterTestCluster" )) {
216- dependsOn oldClusterTestRunner,
217- " ${ baseName} #oldClusterTestCluster#node0.stop" ,
218- " ${ baseName} #oldClusterTestCluster#node1.stop"
219- numNodes = 2
220- clusterName = ' full-cluster-restart'
221- dataDir = { nodeNum -> oldClusterTest. nodes[nodeNum]. dataDir }
222- cleanShared = false // We want to keep snapshots made by the old cluster!
223- setupCommand ' setupTestUser' , ' bin/elasticsearch-users' , ' useradd' , ' test_user' , ' -p' , ' x-pack-test-password' , ' -r' , ' superuser'
224- waitCondition = waitWithAuth
225-
226- // some tests rely on the translog not being flushed
227- setting ' indices.memory.shard_inactive_time' , ' 20m'
228- setting ' xpack.security.enabled' , ' true'
229- if (project. inFipsJvm) {
230- setting ' xpack.security.transport.ssl.key' , ' testnode.pem'
231- setting ' xpack.security.transport.ssl.certificate' , ' testnode.crt'
232- keystoreSetting ' xpack.security.transport.ssl.secure_key_passphrase' , ' testnode'
233- } else {
234- setting ' xpack.security.transport.ssl.keystore.path' , ' testnode.jks'
235- setting ' xpack.security.transport.ssl.keystore.password' , ' testnode'
236- }
237- setting ' xpack.license.self_generated.type' , ' trial'
238- dependsOn copyTestNodeKeyMaterial
239- extraConfigFile ' testnode.jks' , new File (outputDir + ' /testnode.jks' )
240- extraConfigFile ' testnode.pem' , new File (outputDir + ' /testnode.pem' )
241- extraConfigFile ' testnode.crt' , new File (outputDir + ' /testnode.crt' )
242- if (withSystemKey) {
243- setting ' xpack.watcher.encrypt_sensitive_data' , ' true'
244- keystoreFile ' xpack.watcher.encryption_key' , " ${ mainProject.projectDir} /src/test/resources/system_key"
245- }
168+ dependsOn oldClusterTestRunner,
169+ " ${ baseName} #oldClusterTestCluster#node0.stop" ,
170+ " ${ baseName} #oldClusterTestCluster#node1.stop"
171+ numNodes = 2
172+ clusterName = ' full-cluster-restart'
173+ dataDir = { nodeNum -> oldClusterTest. nodes[nodeNum]. dataDir }
174+ cleanShared = false // We want to keep snapshots made by the old cluster!
175+ setupCommand ' setupTestUser' , ' bin/elasticsearch-users' , ' useradd' , ' test_user' , ' -p' , ' x-pack-test-password' , ' -r' , ' superuser'
176+ waitCondition = waitWithAuth
177+
178+ // some tests rely on the translog not being flushed
179+ setting ' indices.memory.shard_inactive_time' , ' 20m'
180+ setting ' xpack.security.enabled' , ' true'
181+ if (project. inFipsJvm) {
182+ setting ' xpack.security.transport.ssl.key' , ' testnode.pem'
183+ setting ' xpack.security.transport.ssl.certificate' , ' testnode.crt'
184+ keystoreSetting ' xpack.security.transport.ssl.secure_key_passphrase' , ' testnode'
185+ } else {
186+ setting ' xpack.security.transport.ssl.keystore.path' , ' testnode.jks'
187+ setting ' xpack.security.transport.ssl.keystore.password' , ' testnode'
188+ }
189+ setting ' xpack.license.self_generated.type' , ' trial'
190+ dependsOn copyTestNodeKeyMaterial
191+ extraConfigFile ' testnode.jks' , new File (outputDir + ' /testnode.jks' )
192+ extraConfigFile ' testnode.pem' , new File (outputDir + ' /testnode.pem' )
193+ extraConfigFile ' testnode.crt' , new File (outputDir + ' /testnode.crt' )
194+
195+ setting ' xpack.watcher.encrypt_sensitive_data' , ' true'
196+ keystoreFile ' xpack.watcher.encryption_key' , " ${ project.projectDir} /src/test/resources/system_key"
246197 }
247198
248199 Task upgradedClusterTestRunner = tasks. getByName(" ${ baseName} #upgradedClusterTestRunner" )
249200 upgradedClusterTestRunner. configure {
250- systemProperty ' tests.is_old_cluster' , ' false'
251- systemProperty ' tests.old_cluster_version' , version. toString(). minus(" -SNAPSHOT" )
252- systemProperty ' tests.path.repo' , new File (buildDir, " cluster/shared/repo" )
253- exclude ' org/elasticsearch/upgrades/FullClusterRestartIT.class'
254- exclude ' org/elasticsearch/upgrades/FullClusterRestartSettingsUpgradeIT.class'
255- exclude ' org/elasticsearch/upgrades/QueryBuilderBWCIT.class'
201+ systemProperty ' tests.is_old_cluster' , ' false'
202+ systemProperty ' tests.old_cluster_version' , version. toString(). minus(" -SNAPSHOT" )
203+ systemProperty ' tests.path.repo' , new File (buildDir, " cluster/shared/repo" )
204+ exclude ' org/elasticsearch/upgrades/FullClusterRestartIT.class'
205+ exclude ' org/elasticsearch/upgrades/FullClusterRestartSettingsUpgradeIT.class'
206+ exclude ' org/elasticsearch/upgrades/QueryBuilderBWCIT.class'
256207 }
257208
258209 Task versionBwcTest = tasks. create(name : " ${ baseName} #bwcTest" ) {
259- dependsOn = [upgradedClusterTest]
210+ dependsOn = [upgradedClusterTest]
260211 }
261212
262213 if (project. bwc_tests_enabled) {
263- bwcTest. dependsOn(versionBwcTest)
214+ bwcTest. dependsOn(versionBwcTest)
264215 }
265- }
266-
267- unitTest. enabled = false // no unit tests for full cluster restarts, only the rest integration test
216+ }
268217
269- // basic integ tests includes testing bwc against the most recent version
270- task bwcTestSnapshots {
218+ // basic integ tests includes testing bwc against the most recent version
219+ task bwcTestSnapshots {
271220 if (project. bwc_tests_enabled) {
272- for (final def version : bwcVersions. unreleasedIndexCompatible) {
273- dependsOn " v${ version} #bwcTest"
274- }
221+ for (final def version : bwcVersions. unreleasedIndexCompatible) {
222+ dependsOn " v${ version} #bwcTest"
223+ }
275224 }
276- }
277-
278- check. dependsOn(bwcTestSnapshots)
225+ }
279226
280- dependencies {
281- // "org.elasticsearch.plugin:x-pack-core:${version}" doesn't work with idea because the testArtifacts are also here
282- testCompile project(path : xpackModule(' core' ), configuration : ' default' )
283- testCompile project(path : xpackModule(' watcher' ), configuration : ' runtime' )
284- testCompile project(path : xpackModule(' core' ), configuration : ' testArtifacts' )
285- testCompile project(path : xpackModule(' security' ), configuration : ' testArtifacts' )
286- }
227+ check. dependsOn(bwcTestSnapshots)
287228
288- // copy x-pack plugin info so it is on the classpath and security manager has the right permissions
289- task copyXPackRestSpec(type : Copy ) {
229+ // copy x-pack plugin info so it is on the classpath and security manager has the right permissions
230+ task copyXPackRestSpec (type : Copy ) {
290231 dependsOn(project. configurations. restSpec, ' processTestResources' )
291232 from project(xpackModule(' core' )). sourceSets. test. resources
292233 include ' rest-api-spec/api/**'
293234 into project. sourceSets. test. output. resourcesDir
294- }
235+ }
295236
296- task copyXPackPluginProps(type : Copy ) {
237+ task copyXPackPluginProps (type : Copy ) {
297238 dependsOn(copyXPackRestSpec)
298239 from project(xpackModule(' core' )). file(' src/main/plugin-metadata' )
299240 from project(xpackModule(' core' )). tasks. pluginProperties
300241 into outputDir
301- }
302- project. sourceSets. test. output. dir(outputDir, builtBy : copyXPackPluginProps)
303-
304- repositories {
305- maven {
306- url " https://artifacts.elastic.co/maven"
307- }
308- maven {
309- url " https://snapshots.elastic.co/maven"
310- }
311- }
312242}
243+ project. sourceSets. test. output. dir(outputDir, builtBy : copyXPackPluginProps)
0 commit comments