Consolidate duplication of BWC testing task setup in script plugin (#53079)

(cherry picked from commit 33fc8e7ebfac8d47a5f9f026b3836bb47bea141a)
This commit is contained in:
Mark Vieira 2020-03-03 14:40:55 -08:00
parent 3fcf598b92
commit 4b528d97ad
No known key found for this signature in database
GPG Key ID: CA947EF7E6D4B105
10 changed files with 55 additions and 201 deletions

30
gradle/bwc-test.gradle Normal file
View File

@ -0,0 +1,30 @@
import org.elasticsearch.gradle.Version
ext.bwcTaskName = { Version version ->
return "v${version}#bwcTest"
}
def bwcTestSnapshots = tasks.register("bwcTestSnapshots") {
if (project.bwc_tests_enabled) {
dependsOn tasks.matching { task -> bwcVersions.unreleased.any { version -> bwcTaskName(version) == task.name } }
}
}
tasks.register("bwcTest") {
description = 'Runs backwards compatibility tests.'
group = 'verification'
if (project.bwc_tests_enabled) {
dependsOn tasks.matching { it.name ==~ /v[0-9\.]+#bwcTest/ }
}
}
tasks.withType(Test).configureEach {
onlyIf { project.bwc_tests_enabled }
}
tasks.named("check").configure {
dependsOn(bwcTestSnapshots)
}
test.enabled = false

View File

@ -25,11 +25,7 @@ import org.elasticsearch.gradle.testclusters.TestDistribution
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test'
tasks.register("bwcTest") {
description = 'Runs backwards compatibility tests.'
group = 'verification'
}
apply from : "$rootDir/gradle/bwc-test.gradle"
for (Version bwcVersion : bwcVersions.indexCompatible) {
String baseName = "v${bwcVersion}"
@ -71,25 +67,11 @@ for (Version bwcVersion : bwcVersions.indexCompatible) {
it.nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
}
if (project.bwc_tests_enabled) {
bwcTest.dependsOn(
tasks.register("${baseName}#bwcTest") {
dependsOn tasks.named("${baseName}#upgradedClusterTest")
}
)
tasks.register(bwcTaskName(bwcVersion)) {
dependsOn tasks.named("${baseName}#upgradedClusterTest")
}
}
task bwcTestSnapshots {
if (project.bwc_tests_enabled) {
for (final def version : bwcVersions.unreleasedIndexCompatible) {
dependsOn "v${version}#bwcTest"
}
}
}
check.dependsOn(bwcTestSnapshots)
configurations {
testArtifacts.extendsFrom testRuntime
}
@ -102,5 +84,3 @@ task testJar(type: Jar) {
artifacts {
testArtifacts testJar
}
test.enabled = false

View File

@ -24,11 +24,7 @@ import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test'
tasks.register("bwcTest") {
description = 'Runs backwards compatibility tests.'
group = 'verification'
}
apply from : "$rootDir/gradle/bwc-test.gradle"
restResources {
restTests {
@ -76,23 +72,7 @@ for (Version bwcVersion : bwcVersions.wireCompatible) {
onlyIf { project.bwc_tests_enabled }
}
tasks.register("${baseName}#bwcTest") {
tasks.register(bwcTaskName(bwcVersion)) {
dependsOn "${baseName}#mixedClusterTest"
}
tasks.bwcTest.dependsOn "${baseName}#bwcTest"
}
task bwcTestSnapshots {
if (project.bwc_tests_enabled) {
for (Version bwcVersion : bwcVersions.unreleasedWireCompatible) {
if (bwcVersion != VersionProperties.getElasticsearchVersion()) {
dependsOn "v${bwcVersion}#bwcTest"
}
}
}
}
check.dependsOn(bwcTestSnapshots)
test.enabled = false

View File

@ -23,11 +23,7 @@ import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test'
tasks.register("bwcTest") {
description = 'Runs backwards compatibility tests.'
group = 'verification'
}
apply from : "$rootDir/gradle/bwc-test.gradle"
dependencies {
testCompile project(':client:rest-high-level')
@ -86,25 +82,11 @@ for (Version bwcVersion : bwcVersions.indexCompatible) {
it.nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${clusterName}".getName()}")
}
if (project.bwc_tests_enabled) {
bwcTest.dependsOn(
tasks.register("${baseName}#bwcTest") {
dependsOn tasks.named("${baseName}#Step4NewClusterTest")
}
)
tasks.register(bwcTaskName(bwcVersion)) {
dependsOn tasks.named("${baseName}#Step4NewClusterTest")
}
}
task bwcTestSnapshots {
if (project.bwc_tests_enabled) {
for (final def version : bwcVersions.unreleasedIndexCompatible) {
dependsOn "v${version}#bwcTest"
}
}
}
check.dependsOn(bwcTestSnapshots)
configurations {
testArtifacts.extendsFrom testRuntime
}
@ -117,5 +99,3 @@ task testJar(type: Jar) {
artifacts {
testArtifacts testJar
}
test.enabled = false

View File

@ -23,13 +23,7 @@ import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test'
// This is a top level task which we will add dependencies to below.
// It is a single task that can be used to backcompat tests against all versions.
task bwcTest {
description = 'Runs backwards compatibility tests.'
group = 'verification'
}
apply from : "$rootDir/gradle/bwc-test.gradle"
for (Version bwcVersion : bwcVersions.wireCompatible) {
/*
@ -108,26 +102,7 @@ for (Version bwcVersion : bwcVersions.wireCompatible) {
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
}
if (project.bwc_tests_enabled) {
bwcTest.dependsOn(
tasks.register("${baseName}#bwcTest") {
dependsOn tasks.named("${baseName}#upgradedClusterTest")
}
)
tasks.register(bwcTaskName(bwcVersion)) {
dependsOn tasks.named("${baseName}#upgradedClusterTest")
}
}
test.enabled = false // no unit tests for rolling upgrades, only the rest integration test
// basic integ tests includes testing bwc against the most recent version
task bwcTestSnapshots {
if (project.bwc_tests_enabled) {
for (final def version : bwcVersions.unreleasedWireCompatible) {
dependsOn "v${version}#bwcTest"
}
}
}
check.dependsOn(bwcTestSnapshots)
test.enabled = false

View File

@ -24,11 +24,7 @@ import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test'
tasks.register("bwcTest") {
description = 'Runs backwards compatibility tests.'
group = 'verification'
}
apply from : "$rootDir/gradle/bwc-test.gradle"
for (Version bwcVersion : bwcVersions.indexCompatible) {
String baseName = "v${bwcVersion}"
@ -46,22 +42,12 @@ for (Version bwcVersion : bwcVersions.indexCompatible) {
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
}
tasks.register("${baseName}#bwcTest") {
tasks.register(bwcTaskName(bwcVersion)) {
dependsOn "${baseName}#integTest"
}
bwcTest.dependsOn("${baseName}#bwcTest")
}
task bwcTestSnapshots {
if (project.bwc_tests_enabled) {
for (version in bwcVersions.unreleasedIndexCompatible) {
dependsOn "v${version}#bwcTest"
}
}
}
task verifyDocsLuceneVersion {
tasks.register("verifyDocsLuceneVersion") {
doFirst {
File docsVersionsFile = rootProject.file('docs/Versions.asciidoc')
List<String> versionLines = docsVersionsFile.readLines('UTF-8')
@ -83,6 +69,6 @@ task verifyDocsLuceneVersion {
}
}
check.dependsOn bwcTestSnapshots, verifyDocsLuceneVersion
test.enabled = false
tasks.named("check").configure {
dependsOn verifyDocsLuceneVersion
}

View File

@ -3,6 +3,7 @@ import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test'
apply from : "$rootDir/gradle/bwc-test.gradle"
dependencies {
// TODO: Remove core dependency and change tests to not use builders that are part of xpack-core.
@ -23,11 +24,6 @@ forbiddenPatterns {
String outputDir = "${buildDir}/generated-resources/${project.name}"
tasks.register("bwcTest") {
description = 'Runs backwards compatibility tests.'
group = 'verification'
}
tasks.register("copyTestNodeKeyMaterial", Copy) {
from project(':x-pack:plugin:core')
.files(
@ -104,23 +100,7 @@ for (Version bwcVersion : bwcVersions.indexCompatible) {
it.nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
}
tasks.register("${baseName}#bwcTest") {
tasks.register(bwcTaskName(bwcVersion)) {
dependsOn "${baseName}#upgradedClusterTest"
}
if (project.bwc_tests_enabled) {
bwcTest.dependsOn("${baseName}#bwcTest")
}
}
task bwcTestSnapshots {
if (project.bwc_tests_enabled) {
for (final def version : bwcVersions.unreleasedIndexCompatible) {
dependsOn "v${version}#bwcTest"
}
}
}
check.dependsOn(bwcTestSnapshots)
test.enabled = false

View File

@ -3,16 +3,12 @@ import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test'
apply from : "$rootDir/gradle/bwc-test.gradle"
dependencies {
testCompile project(':x-pack:qa')
}
tasks.register("bwcTest") {
description = 'Runs backwards compatibility tests.'
group = 'verification'
}
for (Version bwcVersion : bwcVersions.wireCompatible) {
String baseName = "v${bwcVersion}"
@ -79,24 +75,9 @@ for (Version bwcVersion : bwcVersions.wireCompatible) {
systemProperty 'tests.upgrade_from_version', bwcVersion.toString().replace('-SNAPSHOT', '')
}
tasks.register("${baseName}#bwcTest") {
tasks.register(bwcTaskName(bwcVersion)) {
dependsOn "${baseName}#upgradedClusterTest"
}
if (project.bwc_tests_enabled) {
bwcTest.dependsOn("${baseName}#bwcTest")
}
}
task bwcTestSnapshots {
if (project.bwc_tests_enabled) {
for (final def version : bwcVersions.unreleasedWireCompatible) {
dependsOn "v${version}#bwcTest"
}
}
}
check.dependsOn(bwcTestSnapshots)
compileTestJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked"
test.enabled = false

View File

@ -3,16 +3,12 @@ import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test'
apply from : "$rootDir/gradle/bwc-test.gradle"
dependencies {
testCompile project(':x-pack:qa')
}
tasks.register("bwcTest") {
description = 'Runs backwards compatibility tests.'
group = 'verification'
}
for (Version bwcVersion : bwcVersions.wireCompatible) {
String baseName = "v${bwcVersion}"
@ -94,22 +90,7 @@ for (Version bwcVersion : bwcVersions.wireCompatible) {
dependsOn "${baseName}#follower#upgradedClusterTest"
}
tasks.register("${baseName}#bwcTest") {
tasks.register(bwcTaskName(bwcVersion)) {
dependsOn "${baseName}#leader#upgradedClusterTest"
}
if (project.bwc_tests_enabled) {
bwcTest.dependsOn("${baseName}#bwcTest")
}
}
task bwcTestSnapshots {
if (project.bwc_tests_enabled) {
for (final def version : bwcVersions.unreleasedWireCompatible) {
dependsOn "v${version}#bwcTest"
}
}
}
check.dependsOn(bwcTestSnapshots)
test.enabled = false

View File

@ -3,6 +3,7 @@ import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test'
apply from : "$rootDir/gradle/bwc-test.gradle"
dependencies {
testCompile project(':x-pack:qa')
@ -22,11 +23,6 @@ forbiddenPatterns {
String outputDir = "${buildDir}/generated-resources/${project.name}"
tasks.register("bwcTest") {
description = 'Runs backwards compatibility tests.'
group = 'verification'
}
task copyTestNodeKeyMaterial(type: Copy) {
from project(':x-pack:plugin:core').files('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem',
'src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt')
@ -200,22 +196,7 @@ for (Version bwcVersion : bwcVersions.wireCompatible) {
}
}
tasks.register("${baseName}#bwcTest") {
tasks.register(bwcTaskName(bwcVersion)) {
dependsOn "${baseName}#upgradedClusterTest"
}
if (project.bwc_tests_enabled) {
bwcTest.dependsOn("${baseName}#bwcTest")
}
}
task bwcTestSnapshots {
if (project.bwc_tests_enabled) {
for (final def version : bwcVersions.unreleasedWireCompatible) {
dependsOn "v${version}#bwcTest"
}
}
}
check.dependsOn(bwcTestSnapshots)
test.enabled = false