Skip to content

Commit

Permalink
Consolidate duplication of BWC testing task setup in script plugin (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira committed Mar 3, 2020
1 parent e720f11 commit 7309024
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 201 deletions.
30 changes: 30 additions & 0 deletions gradle/bwc-test.gradle
Original file line number Diff line number Diff line change
@@ -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
26 changes: 3 additions & 23 deletions qa/full-cluster-restart/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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")
}
)
}
}

task bwcTestSnapshots {
if (project.bwc_tests_enabled) {
for (final def version : bwcVersions.unreleasedIndexCompatible) {
dependsOn "v${version}#bwcTest"
}
tasks.register(bwcTaskName(bwcVersion)) {
dependsOn tasks.named("${baseName}#upgradedClusterTest")
}
}

check.dependsOn(bwcTestSnapshots)

configurations {
testArtifacts.extendsFrom testRuntime
}
Expand All @@ -102,5 +84,3 @@ task testJar(type: Jar) {
artifacts {
testArtifacts testJar
}

test.enabled = false
24 changes: 2 additions & 22 deletions qa/mixed-cluster/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
26 changes: 3 additions & 23 deletions qa/repository-multi-version/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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")
}
)
}
}

task bwcTestSnapshots {
if (project.bwc_tests_enabled) {
for (final def version : bwcVersions.unreleasedIndexCompatible) {
dependsOn "v${version}#bwcTest"
}
tasks.register(bwcTaskName(bwcVersion)) {
dependsOn tasks.named("${baseName}#Step4NewClusterTest")
}
}

check.dependsOn(bwcTestSnapshots)

configurations {
testArtifacts.extendsFrom testRuntime
}
Expand All @@ -117,5 +99,3 @@ task testJar(type: Jar) {
artifacts {
testArtifacts testJar
}

test.enabled = false
31 changes: 3 additions & 28 deletions qa/rolling-upgrade/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
/*
Expand Down Expand Up @@ -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
26 changes: 6 additions & 20 deletions qa/verify-version-constants/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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')
Expand All @@ -83,6 +69,6 @@ task verifyDocsLuceneVersion {
}
}

check.dependsOn bwcTestSnapshots, verifyDocsLuceneVersion

test.enabled = false
tasks.named("check").configure {
dependsOn verifyDocsLuceneVersion
}
24 changes: 2 additions & 22 deletions x-pack/qa/full-cluster-restart/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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(
Expand Down Expand Up @@ -103,23 +99,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
23 changes: 2 additions & 21 deletions x-pack/qa/rolling-upgrade-basic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down Expand Up @@ -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
23 changes: 2 additions & 21 deletions x-pack/qa/rolling-upgrade-multi-cluster/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down Expand Up @@ -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
Loading

0 comments on commit 7309024

Please sign in to comment.