Build: Build 5.x version of xpack for bwc tests to use (elastic/x-pack-elasticsearch#885)

This is analagous of the bwc-zip for elasticsearch. The one caveat is
due to the structure of how ES+xpack must be checked out, we end up with
a third clone of elasticsearch (the second being in :distribution:bwc-zip).
But the rolling upgrade integ test passes with this change.

relates elastic/x-pack-elasticsearch#870

Original commit: elastic/x-pack-elasticsearch@34bdce6e99
This commit is contained in:
Ryan Ernst 2017-04-07 22:19:30 -07:00 committed by GitHub
parent 984055392e
commit e8399cfccf
3 changed files with 121 additions and 2 deletions

View File

@ -43,5 +43,8 @@ subprojects {
approvedLicenses = ['Elasticsearch Confidential']
additionalLicense 'ESCON', 'Elasticsearch Confidential', 'ELASTICSEARCH CONFIDENTIAL'
}
ext.projectSubstitutions += [ "org.elasticsearch.plugin:x-pack-api:${version}": ':x-pack-elasticsearch:plugin' ]
ext.projectSubstitutions += [
"org.elasticsearch.plugin:x-pack-api:${version}": ':x-pack-elasticsearch:plugin',
"org.elasticsearch.plugin:x-pack:${bwcVersion}": ':x-pack-elasticsearch:plugin:bwc-zip'
]
}

116
plugin/bwc-zip/build.gradle Normal file
View File

@ -0,0 +1,116 @@
import java.util.regex.Matcher
import org.elasticsearch.gradle.LoggedExec
/**
* 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
* tests in the next major version to test against the next unreleased minor
* version, without relying on snapshots.
*/
apply plugin: 'distribution'
File esCheckoutDir = file("${buildDir}/bwc/checkout-es-5.x")
File xpackCheckoutDir = file("${esCheckoutDir}-extra/x-pack-elasticsearch")
task createElasticsearchClone(type: LoggedExec) {
onlyIf { esCheckoutDir.exists() == false }
commandLine = ['git', 'clone', rootDir, esCheckoutDir]
}
task createXPackClone(type: LoggedExec) {
onlyIf { xpackCheckoutDir.exists() == false }
commandLine = ['git', 'clone', project(':x-pack-elasticsearch').projectDir, xpackCheckoutDir]
}
// we use regular Exec here to ensure we always get output, regardless of logging level
task findElasticsearchUpstream(type: Exec) {
dependsOn createElasticsearchClone
workingDir = esCheckoutDir
commandLine = ['git', 'remote', '-v']
ignoreExitValue = true
ByteArrayOutputStream output = new ByteArrayOutputStream()
standardOutput = output
doLast {
if (execResult.exitValue != 0) {
output.toString('UTF-8').eachLine { line -> logger.error(line) }
execResult.assertNormalExitValue()
}
project.ext.esUpstreamExists = false
output.toString('UTF-8').eachLine {
if (it.contains("upstream")) {
project.ext.esUpstreamExists = true
}
}
}
}
task findXPackUpstream(type: Exec) {
dependsOn createXPackClone
workingDir = xpackCheckoutDir
commandLine = ['git', 'remote', '-v']
ignoreExitValue = true
ByteArrayOutputStream output = new ByteArrayOutputStream()
standardOutput = output
doLast {
if (execResult.exitValue != 0) {
output.toString('UTF-8').eachLine { line -> logger.error(line) }
execResult.assertNormalExitValue()
}
project.ext.xpackUpstreamExists = false
output.toString('UTF-8').eachLine {
if (it.contains("upstream")) {
project.ext.xpackUpstreamExists = true
}
}
}
}
task addElasticsearchUpstream(type: LoggedExec) {
dependsOn findElasticsearchUpstream
onlyIf { project.ext.esUpstreamExists == false }
workingDir = esCheckoutDir
commandLine = ['git', 'remote', 'add', 'upstream', 'git@github.com:elastic/elasticsearch.git']
}
task addXPackUpstream(type: LoggedExec) {
dependsOn findXPackUpstream
onlyIf { project.ext.xpackUpstreamExists == false }
workingDir = xpackCheckoutDir
commandLine = ['git', 'remote', 'add', 'upstream', 'git@github.com:elastic/x-pack-elasticsearch.git']
}
task fetchElasticsearchLatest(type: LoggedExec) {
dependsOn addElasticsearchUpstream
workingDir = esCheckoutDir
commandLine = ['git', 'fetch', 'upstream']
}
task fetchXPackLatest(type: LoggedExec) {
dependsOn addXPackUpstream
workingDir = xpackCheckoutDir
commandLine = ['git', 'fetch', 'upstream']
}
task checkoutElasticsearchBwcBranch(type: LoggedExec) {
dependsOn fetchElasticsearchLatest
workingDir = esCheckoutDir
commandLine = ['git', 'checkout', 'upstream/5.x']
}
task checkoutXPackBwcBranch(type: LoggedExec) {
dependsOn fetchXPackLatest
workingDir = xpackCheckoutDir
commandLine = ['git', 'checkout', 'upstream/5.x']
}
File bwcZip = file("${xpackCheckoutDir}/plugin/build/distributions/x-pack-${bwcVersion}.zip")
task buildBwcVersion(type: GradleBuild) {
dependsOn checkoutXPackBwcBranch, checkoutElasticsearchBwcBranch
dir = xpackCheckoutDir
tasks = [':x-pack-elasticsearch:plugin:assemble']
}
artifacts {
'default' file: bwcZip, name: 'x-pack', type: 'zip', builtBy: buildBwcVersion
}

View File

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