Skip to content

Commit f79c2cb

Browse files
authored
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.
1 parent d368d7c commit f79c2cb

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

TESTING.asciidoc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,29 @@ is tested depends on the branch. On master, this will test against the current
471471
stable branch. On the stable branch, it will test against the latest release
472472
branch. Finally, on a release branch, it will test against the most recent release.
473473

474+
=== BWC Testing against a specific branch
475+
476+
Sometimes a backward compatibility change spans two versions. A common case is a new functionality
477+
that needs a BWC bridge in and an unreleased versioned of a release branch (for example, 5.x).
478+
To test the changes, you can instruct gradle to build the BWC version from a local branch instead of
479+
pulling the release branch from GitHub. You do so using the `tests.bwc.refspec` system property:
480+
481+
-------------------------------------------------
482+
gradle check -Dtests.bwc.refspec=origin/index_req_bwc_5.x
483+
-------------------------------------------------
484+
485+
The branch needs to be available on the local clone that the BWC makes of the repository you run the
486+
tests from. Using the `origin` remote is a handy trick to make sure that a branch is available
487+
and is up to date in the case of multiple runs.
488+
489+
Example:
490+
491+
Say you need to make a change to `master` and have a BWC layer in `5.x`. You will need to:
492+
. Create a branch called `index_req_change` off `master`. This will contain your change.
493+
. Create a branch called `index_req_bwc_5.x` off `5.x`. This will contain your bwc layer.
494+
. If not running the tests locally, push both branches to your remote repository.
495+
. Run the tests with `gradle check -Dtests.bwc.refspec=origin/index_req_bwc_5.x`
496+
474497
== Coverage analysis
475498

476499
Tests can be run instrumented with jacoco to produce a coverage report in

distribution/bwc/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,15 @@ if (enabled) {
101101
onlyIf { project.gradle.startParameter.isOffline() == false }
102102
dependsOn addUpstream
103103
workingDir = checkoutDir
104-
commandLine = ['git', 'fetch', 'upstream']
104+
commandLine = ['git', 'fetch']
105105
}
106106

107107
// this is an Exec task so that the SHA that is checked out is logged
108108
task checkoutBwcBranch(type: Exec) {
109+
def String refspec = System.getProperty("tests.bwc.refspec", "upstream/${bwcBranch}")
109110
dependsOn fetchLatest
110111
workingDir = checkoutDir
111-
commandLine = ['git', 'checkout', "upstream/${bwcBranch}"]
112+
commandLine = ['git', 'checkout', refspec]
112113
}
113114

114115
File bwcDeb = file("${checkoutDir}/distribution/deb/build/distributions/elasticsearch-${bwcVersion}.deb")

0 commit comments

Comments
 (0)