|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +import org.elasticsearch.gradle.Version |
| 21 | +import org.elasticsearch.gradle.info.BuildParams |
| 22 | +import org.elasticsearch.gradle.testclusters.RestTestRunnerTask |
| 23 | + |
| 24 | +apply plugin: 'elasticsearch.testclusters' |
| 25 | +apply plugin: 'elasticsearch.standalone-test' |
| 26 | + |
| 27 | +tasks.register("bwcTest") { |
| 28 | + description = 'Runs backwards compatibility tests.' |
| 29 | + group = 'verification' |
| 30 | +} |
| 31 | + |
| 32 | +dependencies { |
| 33 | + testCompile project(':client:rest-high-level') |
| 34 | +} |
| 35 | + |
| 36 | +for (Version bwcVersion : bwcVersions.indexCompatible) { |
| 37 | + String baseName = "v${bwcVersion}" |
| 38 | + String oldClusterName = "${baseName}-old" |
| 39 | + String newClusterName = "${baseName}-new" |
| 40 | + |
| 41 | + def clusterSettings = { v -> |
| 42 | + return { |
| 43 | + version = v |
| 44 | + numberOfNodes = 2 |
| 45 | + setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}" |
| 46 | + javaHome = BuildParams.runtimeJavaHome |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + testClusters { |
| 51 | + "${oldClusterName}" clusterSettings(bwcVersion.toString()) |
| 52 | + "${newClusterName}" clusterSettings(project.version) |
| 53 | + } |
| 54 | + |
| 55 | + tasks.register("${baseName}#Step1OldClusterTest", RestTestRunnerTask) { |
| 56 | + useCluster testClusters."${oldClusterName}" |
| 57 | + mustRunAfter(precommit) |
| 58 | + doFirst { |
| 59 | + project.delete("${buildDir}/cluster/shared/repo/${baseName}") |
| 60 | + } |
| 61 | + systemProperty 'tests.rest.suite', 'step1' |
| 62 | + } |
| 63 | + |
| 64 | + tasks.register("${baseName}#Step2NewClusterTest", RestTestRunnerTask) { |
| 65 | + useCluster testClusters."${newClusterName}" |
| 66 | + dependsOn "${baseName}#Step1OldClusterTest" |
| 67 | + systemProperty 'tests.rest.suite', 'step2' |
| 68 | + } |
| 69 | + |
| 70 | + tasks.register("${baseName}#Step3OldClusterTest", RestTestRunnerTask) { |
| 71 | + useCluster testClusters."${oldClusterName}" |
| 72 | + dependsOn "${baseName}#Step2NewClusterTest" |
| 73 | + systemProperty 'tests.rest.suite', 'step3' |
| 74 | + } |
| 75 | + |
| 76 | + tasks.register("${baseName}#Step4NewClusterTest", RestTestRunnerTask) { |
| 77 | + useCluster testClusters."${newClusterName}" |
| 78 | + dependsOn "${baseName}#Step3OldClusterTest" |
| 79 | + systemProperty 'tests.rest.suite', 'step4' |
| 80 | + } |
| 81 | + |
| 82 | + tasks.matching { it.name.startsWith(baseName) && it.name.endsWith("ClusterTest") }.configureEach { |
| 83 | + it.systemProperty 'tests.old_cluster_version', bwcVersion.toString().minus("-SNAPSHOT") |
| 84 | + it.systemProperty 'tests.path.repo', "${buildDir}/cluster/shared/repo/${baseName}" |
| 85 | + def clusterName = it.name.contains("Step2") || it.name.contains("Step4") ? "${newClusterName}" : "${oldClusterName}" |
| 86 | + it.nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${clusterName}".allHttpSocketURI.join(",")}") |
| 87 | + it.nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${clusterName}".getName()}") |
| 88 | + } |
| 89 | + |
| 90 | + if (project.bwc_tests_enabled) { |
| 91 | + bwcTest.dependsOn( |
| 92 | + tasks.register("${baseName}#bwcTest") { |
| 93 | + dependsOn tasks.named("${baseName}#Step4NewClusterTest") |
| 94 | + } |
| 95 | + ) |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +task bwcTestSnapshots { |
| 100 | + if (project.bwc_tests_enabled) { |
| 101 | + for (final def version : bwcVersions.unreleasedIndexCompatible) { |
| 102 | + dependsOn "v${version}#bwcTest" |
| 103 | + } |
| 104 | + } |
| 105 | +} |
| 106 | + |
| 107 | +check.dependsOn(bwcTestSnapshots) |
| 108 | + |
| 109 | +configurations { |
| 110 | + testArtifacts.extendsFrom testRuntime |
| 111 | +} |
| 112 | + |
| 113 | +task testJar(type: Jar) { |
| 114 | + appendix 'test' |
| 115 | + from sourceSets.test.output |
| 116 | +} |
| 117 | + |
| 118 | +artifacts { |
| 119 | + testArtifacts testJar |
| 120 | +} |
| 121 | + |
| 122 | +test.enabled = false |
0 commit comments