Use new wireCompatVersions property instead of bwcVersion (elastic/x-pack-elasticsearch#1466)

This is the xpack side of elastic/elasticsearch#24748

Original commit: elastic/x-pack-elasticsearch@8b7dd5cdbe
This commit is contained in:
Ryan Ernst 2017-05-17 12:58:51 -07:00 committed by GitHub
parent 05daaa8a3c
commit 573da95e26
3 changed files with 97 additions and 92 deletions

View File

@ -45,6 +45,6 @@ subprojects {
} }
ext.projectSubstitutions += [ ext.projectSubstitutions += [
"org.elasticsearch.plugin:x-pack-api:${version}": ':x-pack-elasticsearch:plugin', "org.elasticsearch.plugin:x-pack-api:${version}": ':x-pack-elasticsearch:plugin',
"org.elasticsearch.plugin:x-pack:${bwcVersion}": ':x-pack-elasticsearch:plugin:bwc-zip' "org.elasticsearch.plugin:x-pack:${wireCompatVersions[-1]}": ':x-pack-elasticsearch:plugin:bwc-zip'
] ]
} }

View File

@ -3,114 +3,119 @@ import org.elasticsearch.gradle.LoggedExec
/** /**
* This is a dummy project which does a local checkout of the previous * This is a dummy project which does a local checkout of the previous
* major version's stable branch, and builds a snapshot. This allows backcompat * wire compat version's branch, and builds a snapshot. This allows backcompat
* tests in the next major version to test against the next unreleased minor * tests to test against the next unreleased version, closest to this version,
* version, without relying on snapshots. * without relying on snapshots.
*/ */
apply plugin: 'distribution' String bwcVersion = wireCompatVersions[-1]
if (bwcVersion.endsWith('-SNAPSHOT')) {
apply plugin: 'distribution'
File esCheckoutDir = file("${buildDir}/bwc/checkout-es-5.x") def (String major, String minor, String bugfix) = bwcVersion.split('\\.')
File xpackCheckoutDir = file("${esCheckoutDir}-extra/x-pack-elasticsearch") String bwcBranch = bugfix == '0-SNAPSHOT' ? "${major}.x" : "${major}.${minor}"
task createElasticsearchClone(type: LoggedExec) {
onlyIf { esCheckoutDir.exists() == false }
commandLine = ['git', 'clone', rootDir, esCheckoutDir]
}
task createXPackClone(type: LoggedExec) { File esCheckoutDir = file("${buildDir}/bwc/checkout-es-${bwcBranch}")
onlyIf { xpackCheckoutDir.exists() == false } File xpackCheckoutDir = file("${esCheckoutDir}-extra/x-pack-elasticsearch")
commandLine = ['git', 'clone', project(':x-pack-elasticsearch').projectDir, xpackCheckoutDir] task createElasticsearchClone(type: LoggedExec) {
} onlyIf { esCheckoutDir.exists() == false }
commandLine = ['git', 'clone', rootDir, esCheckoutDir]
}
// we use regular Exec here to ensure we always get output, regardless of logging level task createXPackClone(type: LoggedExec) {
task findElasticsearchUpstream(type: Exec) { onlyIf { xpackCheckoutDir.exists() == false }
dependsOn createElasticsearchClone commandLine = ['git', 'clone', project(':x-pack-elasticsearch').projectDir, xpackCheckoutDir]
workingDir = esCheckoutDir }
commandLine = ['git', 'remote', '-v']
ignoreExitValue = true // we use regular Exec here to ensure we always get output, regardless of logging level
ByteArrayOutputStream output = new ByteArrayOutputStream() task findElasticsearchUpstream(type: Exec) {
standardOutput = output dependsOn createElasticsearchClone
doLast { workingDir = esCheckoutDir
if (execResult.exitValue != 0) { commandLine = ['git', 'remote', '-v']
output.toString('UTF-8').eachLine { line -> logger.error(line) } ignoreExitValue = true
execResult.assertNormalExitValue() ByteArrayOutputStream output = new ByteArrayOutputStream()
} standardOutput = output
project.ext.esUpstreamExists = false doLast {
output.toString('UTF-8').eachLine { if (execResult.exitValue != 0) {
if (it.contains("upstream")) { output.toString('UTF-8').eachLine { line -> logger.error(line) }
project.ext.esUpstreamExists = true execResult.assertNormalExitValue()
}
project.ext.esUpstreamExists = false
output.toString('UTF-8').eachLine {
if (it.contains("upstream")) {
project.ext.esUpstreamExists = true
}
} }
} }
} }
}
task findXPackUpstream(type: Exec) { task findXPackUpstream(type: Exec) {
dependsOn createXPackClone dependsOn createXPackClone
workingDir = xpackCheckoutDir workingDir = xpackCheckoutDir
commandLine = ['git', 'remote', '-v'] commandLine = ['git', 'remote', '-v']
ignoreExitValue = true ignoreExitValue = true
ByteArrayOutputStream output = new ByteArrayOutputStream() ByteArrayOutputStream output = new ByteArrayOutputStream()
standardOutput = output standardOutput = output
doLast { doLast {
if (execResult.exitValue != 0) { if (execResult.exitValue != 0) {
output.toString('UTF-8').eachLine { line -> logger.error(line) } output.toString('UTF-8').eachLine { line -> logger.error(line) }
execResult.assertNormalExitValue() execResult.assertNormalExitValue()
} }
project.ext.xpackUpstreamExists = false project.ext.xpackUpstreamExists = false
output.toString('UTF-8').eachLine { output.toString('UTF-8').eachLine {
if (it.contains("upstream")) { if (it.contains("upstream")) {
project.ext.xpackUpstreamExists = true project.ext.xpackUpstreamExists = true
}
} }
} }
} }
}
task addElasticsearchUpstream(type: LoggedExec) { task addElasticsearchUpstream(type: LoggedExec) {
dependsOn findElasticsearchUpstream dependsOn findElasticsearchUpstream
onlyIf { project.ext.esUpstreamExists == false } onlyIf { project.ext.esUpstreamExists == false }
workingDir = esCheckoutDir workingDir = esCheckoutDir
commandLine = ['git', 'remote', 'add', 'upstream', 'git@github.com:elastic/elasticsearch.git'] commandLine = ['git', 'remote', 'add', 'upstream', 'git@github.com:elastic/elasticsearch.git']
} }
task addXPackUpstream(type: LoggedExec) { task addXPackUpstream(type: LoggedExec) {
dependsOn findXPackUpstream dependsOn findXPackUpstream
onlyIf { project.ext.xpackUpstreamExists == false } onlyIf { project.ext.xpackUpstreamExists == false }
workingDir = xpackCheckoutDir workingDir = xpackCheckoutDir
commandLine = ['git', 'remote', 'add', 'upstream', 'git@github.com:elastic/x-pack-elasticsearch.git'] commandLine = ['git', 'remote', 'add', 'upstream', 'git@github.com:elastic/x-pack-elasticsearch.git']
} }
task fetchElasticsearchLatest(type: LoggedExec) { task fetchElasticsearchLatest(type: LoggedExec) {
dependsOn addElasticsearchUpstream dependsOn addElasticsearchUpstream
workingDir = esCheckoutDir workingDir = esCheckoutDir
commandLine = ['git', 'fetch', 'upstream'] commandLine = ['git', 'fetch', 'upstream']
} }
task fetchXPackLatest(type: LoggedExec) { task fetchXPackLatest(type: LoggedExec) {
dependsOn addXPackUpstream dependsOn addXPackUpstream
workingDir = xpackCheckoutDir workingDir = xpackCheckoutDir
commandLine = ['git', 'fetch', 'upstream'] commandLine = ['git', 'fetch', 'upstream']
} }
task checkoutElasticsearchBwcBranch(type: LoggedExec) { task checkoutElasticsearchBwcBranch(type: LoggedExec) {
dependsOn fetchElasticsearchLatest dependsOn fetchElasticsearchLatest
workingDir = esCheckoutDir workingDir = esCheckoutDir
commandLine = ['git', 'checkout', 'upstream/5.x'] commandLine = ['git', 'checkout', "upstream/${bwcBranch}"]
} }
task checkoutXPackBwcBranch(type: LoggedExec) { task checkoutXPackBwcBranch(type: LoggedExec) {
dependsOn fetchXPackLatest dependsOn fetchXPackLatest
workingDir = xpackCheckoutDir workingDir = xpackCheckoutDir
commandLine = ['git', 'checkout', 'upstream/5.x'] commandLine = ['git', 'checkout', "upstream/${bwcBranch}"]
} }
File bwcZip = file("${xpackCheckoutDir}/plugin/build/distributions/x-pack-${bwcVersion}.zip") File bwcZip = file("${xpackCheckoutDir}/plugin/build/distributions/x-pack-${bwcVersion}.zip")
task buildBwcVersion(type: GradleBuild) { task buildBwcVersion(type: GradleBuild) {
dependsOn checkoutXPackBwcBranch, checkoutElasticsearchBwcBranch dependsOn checkoutXPackBwcBranch, checkoutElasticsearchBwcBranch
dir = xpackCheckoutDir dir = xpackCheckoutDir
tasks = [':x-pack-elasticsearch:plugin:assemble'] tasks = [':x-pack-elasticsearch:plugin:assemble']
} }
artifacts { artifacts {
'default' file: bwcZip, name: 'x-pack', type: 'zip', builtBy: buildBwcVersion 'default' file: bwcZip, name: 'x-pack', type: 'zip', builtBy: buildBwcVersion
}
} }

View File

@ -56,7 +56,7 @@ task oldClusterTest(type: RestIntegTestTask) {
oldClusterTestCluster { oldClusterTestCluster {
plugin ':x-pack-elasticsearch:plugin' plugin ':x-pack-elasticsearch:plugin'
distribution = 'zip' distribution = 'zip'
bwcVersion = project.bwcVersion // TODO: either randomize, or make this settable with sysprop bwcVersion = project.wireCompatVersions[-1] // TODO: either randomize, or make this settable with sysprop
numBwcNodes = 2 numBwcNodes = 2
numNodes = 2 numNodes = 2
clusterName = 'rolling-upgrade' clusterName = 'rolling-upgrade'