From 70a38ec54574110ca8590551f946e1e012a32f31 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Wed, 25 Oct 2017 22:39:58 -0400 Subject: [PATCH] Enable BWC testing against other remotes This commit enables BWC testing against remotes on GitHub other than elastic/elasticsearch.git and elastic/x-pack-elasticsearch.git. Relates elastic/x-pack-elasticsearch#2707 Original commit: elastic/x-pack-elasticsearch@9028f2e08914f036e78a175f6b30ab6a788df49a --- plugin/bwc/build.gradle | 42 +++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/plugin/bwc/build.gradle b/plugin/bwc/build.gradle index fb9fd8d2287..e5a003b53a5 100644 --- a/plugin/bwc/build.gradle +++ b/plugin/bwc/build.gradle @@ -47,6 +47,8 @@ subprojects { File esCheckoutDir = file("${buildDir}/bwc/checkout-es-${bwcBranch}") File xpackCheckoutDir = file("${esCheckoutDir}-extra/x-pack-elasticsearch") + final String remote = System.getProperty("tests.bwc.remote", "elastic") + task createElasticsearchClone(type: LoggedExec) { onlyIf { esCheckoutDir.exists() == false } commandLine = ['git', 'clone', rootDir, esCheckoutDir] @@ -58,7 +60,7 @@ subprojects { } // we use regular Exec here to ensure we always get output, regardless of logging level - task findElasticsearchUpstream(type: Exec) { + task findElasticsearchRemote(type: Exec) { dependsOn createElasticsearchClone workingDir = esCheckoutDir commandLine = ['git', 'remote', '-v'] @@ -70,16 +72,16 @@ subprojects { output.toString('UTF-8').eachLine { line -> logger.error(line) } execResult.assertNormalExitValue() } - project.ext.esUpstreamExists = false + project.ext.esRemoteExists = false output.toString('UTF-8').eachLine { - if (it.contains("upstream")) { - project.ext.esUpstreamExists = true + if (it.contains("${remote}\tgit@github.com:${remote}/elasticsearch.git")) { + project.ext.esRemoteExists = true } } } } - task findXPackUpstream(type: Exec) { + task findXPackRemote(type: Exec) { dependsOn createXPackClone workingDir = xpackCheckoutDir commandLine = ['git', 'remote', '-v'] @@ -91,37 +93,37 @@ subprojects { output.toString('UTF-8').eachLine { line -> logger.error(line) } execResult.assertNormalExitValue() } - project.ext.xpackUpstreamExists = false + project.ext.xpackRemoteExists = false output.toString('UTF-8').eachLine { - if (it.contains("upstream")) { - project.ext.xpackUpstreamExists = true + if (it.contains("${remote}\tgit@github.com:${remote}/x-pack-elasticsearch.git")) { + project.ext.xpackRemoteExists = true } } } } - task addElasticsearchUpstream(type: LoggedExec) { - dependsOn findElasticsearchUpstream - onlyIf { project.ext.esUpstreamExists == false } + task addElasticsearchRemote(type: LoggedExec) { + dependsOn findElasticsearchRemote + onlyIf { project.ext.esRemoteExists == false } workingDir = esCheckoutDir - commandLine = ['git', 'remote', 'add', 'upstream', 'git@github.com:elastic/elasticsearch.git'] + commandLine = ['git', 'remote', 'add', "${remote}", "git@github.com:${remote}/elasticsearch.git"] } - task addXPackUpstream(type: LoggedExec) { - dependsOn findXPackUpstream - onlyIf { project.ext.xpackUpstreamExists == false } + task addXPackRemote(type: LoggedExec) { + dependsOn findXPackRemote + onlyIf { project.ext.xpackRemoteExists == false } workingDir = xpackCheckoutDir - commandLine = ['git', 'remote', 'add', 'upstream', 'git@github.com:elastic/x-pack-elasticsearch.git'] + commandLine = ['git', 'remote', 'add', "${remote}", "git@github.com:${remote}/x-pack-elasticsearch.git"] } task fetchElasticsearchLatest(type: LoggedExec) { - dependsOn addElasticsearchUpstream + dependsOn addElasticsearchRemote workingDir = esCheckoutDir commandLine = ['git', 'fetch', '--all'] } task fetchXPackLatest(type: LoggedExec) { - dependsOn addXPackUpstream + dependsOn addXPackRemote workingDir = xpackCheckoutDir commandLine = ['git', 'fetch', '--all'] } @@ -129,7 +131,7 @@ subprojects { String esBuildMetadataKey = "bwc_refspec_${project.path.substring(1)}_elasticsearch" task checkoutElasticsearchBwcBranch(type: LoggedExec) { dependsOn fetchElasticsearchLatest - def String refspec = System.getProperty("tests.bwc.refspec", buildMetadata.get(esBuildMetadataKey, "upstream/${bwcBranch}")) + def String refspec = System.getProperty("tests.bwc.refspec", buildMetadata.get(esBuildMetadataKey, "${remote}/${bwcBranch}")) workingDir = esCheckoutDir commandLine = ['git', 'checkout', refspec] } @@ -137,7 +139,7 @@ subprojects { String xpackBuildMetadataKey = "bwc_refspec_${project.path.substring(1)}_xpack" task checkoutXPackBwcBranch(type: LoggedExec) { dependsOn fetchXPackLatest - def String refspec = System.getProperty("tests.bwc.refspec", buildMetadata.get(xpackBuildMetadataKey, "upstream/${bwcBranch}")) + def String refspec = System.getProperty("tests.bwc.refspec", buildMetadata.get(xpackBuildMetadataKey, "${remote}/${bwcBranch}")) workingDir = xpackCheckoutDir commandLine = ['git', 'checkout', refspec] }