From 8615e3675ef5b2c4b2cadb687b42327b22fb01ab Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Thu, 12 Apr 2018 13:49:39 -0400 Subject: [PATCH 1/2] Enable skipping fetching latest for BWC builds The BWC builds always fetch the latest from the elastic/elasticsearch repository for the BWC branches. Yet, there are use-cases for using the local checkout without fetching the latest. This commit enables these use-cases by adding a tests.bwc.git.fetch.latest property to skip the fetches. --- TESTING.asciidoc | 7 +++++++ distribution/bwc/build.gradle | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/TESTING.asciidoc b/TESTING.asciidoc index 97902d56ec8c7..46a2e5143f0b8 100644 --- a/TESTING.asciidoc +++ b/TESTING.asciidoc @@ -498,6 +498,13 @@ will contain your change. . Push both branches to your remote repository. . Run the tests with `./gradlew check -Dtests.bwc.remote=${remote} -Dtests.bwc.refspec.5.x=index_req_bwc_5.x`. +== Skip fetching latest + +For some BWC testing scenarios, you want to use the local clone of the +repository without fetching latest. For these use cases, you can set the system +property `tests.bwc.git.fetch.latest` to `false` and the BWC builds will skip +fetching the latest from the remote. + == Test coverage analysis Generating test coverage reports for Elasticsearch is currently not possible through Gradle. diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index 8d5aa204c487d..bdb14c952f607 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -54,6 +54,16 @@ subprojects { final String remote = System.getProperty("tests.bwc.remote", "elastic") + final boolean gitFetchLatest + final String gitFetchLatestProperty = System.getProperty("tests.bwc.git.fetch.latest", "true") + if ("true".equals(gitFetchLatestProperty)) { + gitFetchLatest = true + } else if ("false".equals(gitFetchLatestProperty)) { + gitFetchLatest = false + } else { + throw new GradleException("tests.bwc.git.fetch.latest must be [true] or [false] but was [" + gitFetchLatestProperty + "]") + } + task createClone(type: LoggedExec) { onlyIf { checkoutDir.exists() == false } commandLine = ['git', 'clone', rootDir, checkoutDir] @@ -83,7 +93,7 @@ subprojects { } task fetchLatest(type: LoggedExec) { - onlyIf { project.gradle.startParameter.isOffline() == false } + onlyIf { project.gradle.startParameter.isOffline() == false && gitFetchLatest } dependsOn addRemote workingDir = checkoutDir commandLine = ['git', 'fetch', '--all'] From 9df355bf1cdbf55fc83525f6f7d8b69bfce15870 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Fri, 13 Apr 2018 09:30:34 -0400 Subject: [PATCH 2/2] Rename --- TESTING.asciidoc | 2 +- distribution/bwc/build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TESTING.asciidoc b/TESTING.asciidoc index 46a2e5143f0b8..2e4a6ede754ad 100644 --- a/TESTING.asciidoc +++ b/TESTING.asciidoc @@ -502,7 +502,7 @@ will contain your change. For some BWC testing scenarios, you want to use the local clone of the repository without fetching latest. For these use cases, you can set the system -property `tests.bwc.git.fetch.latest` to `false` and the BWC builds will skip +property `tests.bwc.git_fetch_latest` to `false` and the BWC builds will skip fetching the latest from the remote. == Test coverage analysis diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index bdb14c952f607..3e6a2028498a8 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -55,13 +55,13 @@ subprojects { final String remote = System.getProperty("tests.bwc.remote", "elastic") final boolean gitFetchLatest - final String gitFetchLatestProperty = System.getProperty("tests.bwc.git.fetch.latest", "true") + final String gitFetchLatestProperty = System.getProperty("tests.bwc.git_fetch_latest", "true") if ("true".equals(gitFetchLatestProperty)) { gitFetchLatest = true } else if ("false".equals(gitFetchLatestProperty)) { gitFetchLatest = false } else { - throw new GradleException("tests.bwc.git.fetch.latest must be [true] or [false] but was [" + gitFetchLatestProperty + "]") + throw new GradleException("tests.bwc.git_fetch_latest must be [true] or [false] but was [" + gitFetchLatestProperty + "]") } task createClone(type: LoggedExec) {