From 664dd2bf732fe6d209a2edbb41579563a3676f88 Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Sun, 2 Jul 2017 16:37:23 +0200 Subject: [PATCH 1/4] allow to run bwc test against a local branch --- distribution/bwc/build.gradle | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index 5ffd513dc0673..6a63bee8e47c8 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -64,8 +64,12 @@ if (enabled) { File checkoutDir = file("${buildDir}/bwc/checkout-${bwcBranch}") task createClone(type: LoggedExec) { - onlyIf { checkoutDir.exists() == false } - commandLine = ['git', 'clone', rootDir, checkoutDir] + if (checkoutDir.exists() == false) { + commandLine = ['git', 'clone', rootDir, checkoutDir] + } else { + commandLine = ['git', 'fetch', 'origin'] + workingDir = checkoutDir + } } // we use regular Exec here to ensure we always get output, regardless of logging level @@ -106,9 +110,14 @@ if (enabled) { // this is an Exec task so that the SHA that is checked out is logged task checkoutBwcBranch(type: Exec) { - dependsOn fetchLatest + def String branch = System.getProperty("tests.bwc.branch", "upstream/${bwcBranch}") + if (branch.startsWith('upstream')) { + dependsOn fetchLatest + } else { + dependsOn createClone + } workingDir = checkoutDir - commandLine = ['git', 'checkout', "upstream/${bwcBranch}"] + commandLine = ['git', 'checkout', branch] } File bwcDeb = file("${checkoutDir}/distribution/deb/build/distributions/elasticsearch-${bwcVersion}.deb") From cf8c557c11a05c3f4a1f7d92302d4ffe71ad169c Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Mon, 3 Jul 2017 08:49:58 +0200 Subject: [PATCH 2/4] add docs --- TESTING.asciidoc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/TESTING.asciidoc b/TESTING.asciidoc index d9fb3daac98c7..712058ee0fd6b 100644 --- a/TESTING.asciidoc +++ b/TESTING.asciidoc @@ -470,6 +470,30 @@ 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 you can instruct gradle build that BWC version from a local branch instead of pulling the +release branch from GitHub. You do so using the `tests.bwc.branch` system property: + +------------------------------------------------- +gradle check -Dtests.bwc.branch=origin/index_req_bwc_5.x +------------------------------------------------- + +The branch needs to be available on 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.branch=origin/index_req_bwc_5.x` + + == Coverage analysis Tests can be run instrumented with jacoco to produce a coverage report in From 61c3e5630824a59548e1080df2e84b1ba1b146cf Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Mon, 3 Jul 2017 08:52:31 +0200 Subject: [PATCH 3/4] text tweaks --- TESTING.asciidoc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/TESTING.asciidoc b/TESTING.asciidoc index 712058ee0fd6b..060b31c78847b 100644 --- a/TESTING.asciidoc +++ b/TESTING.asciidoc @@ -474,14 +474,14 @@ branch. Finally, on a release branch, it will test against the most recent relea 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 you can instruct gradle build that BWC version from a local branch instead of pulling the -release branch from GitHub. You do so using the `tests.bwc.branch` system property: +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.branch` system property: ------------------------------------------------- gradle check -Dtests.bwc.branch=origin/index_req_bwc_5.x ------------------------------------------------- -The branch needs to be available on local clone that the BWC makes of the repository you run the +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. @@ -490,10 +490,9 @@ 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 +. If not running the tests locally, push both branches to your remote repository. . Run the tests with `gradle check -Dtests.bwc.branch=origin/index_req_bwc_5.x` - == Coverage analysis Tests can be run instrumented with jacoco to produce a coverage report in From 5d8024c65db867c2657ecc79099eb226e16388a6 Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Thu, 6 Jul 2017 21:44:23 +0200 Subject: [PATCH 4/4] bwc infra feedback --- TESTING.asciidoc | 6 +++--- distribution/bwc/build.gradle | 20 ++++++-------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/TESTING.asciidoc b/TESTING.asciidoc index 3911db70a3287..db23e24a1537b 100644 --- a/TESTING.asciidoc +++ b/TESTING.asciidoc @@ -476,10 +476,10 @@ branch. Finally, on a release branch, it will test against the most recent relea 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.branch` system property: +pulling the release branch from GitHub. You do so using the `tests.bwc.refspec` system property: ------------------------------------------------- -gradle check -Dtests.bwc.branch=origin/index_req_bwc_5.x +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 @@ -492,7 +492,7 @@ Say you need to make a change to `master` and have a BWC layer in `5.x`. You wil . 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.branch=origin/index_req_bwc_5.x` +. Run the tests with `gradle check -Dtests.bwc.refspec=origin/index_req_bwc_5.x` == Coverage analysis diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index 6a63bee8e47c8..f2f1609c6b288 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -64,12 +64,8 @@ if (enabled) { File checkoutDir = file("${buildDir}/bwc/checkout-${bwcBranch}") task createClone(type: LoggedExec) { - if (checkoutDir.exists() == false) { - commandLine = ['git', 'clone', rootDir, checkoutDir] - } else { - commandLine = ['git', 'fetch', 'origin'] - workingDir = checkoutDir - } + onlyIf { checkoutDir.exists() == false } + commandLine = ['git', 'clone', rootDir, checkoutDir] } // we use regular Exec here to ensure we always get output, regardless of logging level @@ -105,19 +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 branch = System.getProperty("tests.bwc.branch", "upstream/${bwcBranch}") - if (branch.startsWith('upstream')) { - dependsOn fetchLatest - } else { - dependsOn createClone - } + def String refspec = System.getProperty("tests.bwc.refspec", "upstream/${bwcBranch}") + dependsOn fetchLatest workingDir = checkoutDir - commandLine = ['git', 'checkout', branch] + commandLine = ['git', 'checkout', refspec] } File bwcDeb = file("${checkoutDir}/distribution/deb/build/distributions/elasticsearch-${bwcVersion}.deb")