From f79c2cb8c0d747dc0c81768a881fe2bfe22d9e2f Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Fri, 7 Jul 2017 11:18:03 +0200 Subject: [PATCH] Allow BWC Testing against a specific branch (#25510) Some times we need a fix / change to have two parts in two different branches (corresponding to two different ES releases). In order to be able to test these cases you need to run the BWC tests against a local branch rather than then using a branch from `github.com/elastic/elasticsearch`. This commit adds a system property called `tests.bwc.refspec` that allows you to do it. Note that I've chosen to go with the simplest code change for now, at the expense of some user friendliness. --- TESTING.asciidoc | 23 +++++++++++++++++++++++ distribution/bwc/build.gradle | 5 +++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/TESTING.asciidoc b/TESTING.asciidoc index 90fa05e5e1c..db23e24a153 100644 --- a/TESTING.asciidoc +++ b/TESTING.asciidoc @@ -471,6 +471,29 @@ is tested depends on the branch. On master, this will test against the current stable branch. On the stable branch, it will test against the latest release branch. Finally, on a release branch, it will test against the most recent release. +=== BWC Testing against a specific branch + +Sometimes a backward compatibility change spans two versions. A common case is a new functionality +that needs a BWC bridge in and an unreleased versioned of a release branch (for example, 5.x). +To test the changes, you can instruct gradle to build the BWC version from a local branch instead of +pulling the release branch from GitHub. You do so using the `tests.bwc.refspec` system property: + +------------------------------------------------- +gradle check -Dtests.bwc.refspec=origin/index_req_bwc_5.x +------------------------------------------------- + +The branch needs to be available on the local clone that the BWC makes of the repository you run the +tests from. Using the `origin` remote is a handy trick to make sure that a branch is available +and is up to date in the case of multiple runs. + +Example: + +Say you need to make a change to `master` and have a BWC layer in `5.x`. You will need to: +. Create a branch called `index_req_change` off `master`. This will contain your change. +. Create a branch called `index_req_bwc_5.x` off `5.x`. This will contain your bwc layer. +. If not running the tests locally, push both branches to your remote repository. +. Run the tests with `gradle check -Dtests.bwc.refspec=origin/index_req_bwc_5.x` + == Coverage analysis Tests can be run instrumented with jacoco to produce a coverage report in diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index 5ffd513dc06..f2f1609c6b2 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -101,14 +101,15 @@ if (enabled) { onlyIf { project.gradle.startParameter.isOffline() == false } dependsOn addUpstream workingDir = checkoutDir - commandLine = ['git', 'fetch', 'upstream'] + commandLine = ['git', 'fetch'] } // this is an Exec task so that the SHA that is checked out is logged task checkoutBwcBranch(type: Exec) { + def String refspec = System.getProperty("tests.bwc.refspec", "upstream/${bwcBranch}") dependsOn fetchLatest workingDir = checkoutDir - commandLine = ['git', 'checkout', "upstream/${bwcBranch}"] + commandLine = ['git', 'checkout', refspec] } File bwcDeb = file("${checkoutDir}/distribution/deb/build/distributions/elasticsearch-${bwcVersion}.deb")