Skip to content

Commit bb3bd10

Browse files
committed
Enable skipping fetching latest for BWC builds (#29497)
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.
1 parent 6a6f2ec commit bb3bd10

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

TESTING.asciidoc

+7
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,13 @@ will contain your change.
498498
. Push both branches to your remote repository.
499499
. Run the tests with `./gradlew check -Dtests.bwc.remote=${remote} -Dtests.bwc.refspec.5.x=index_req_bwc_5.x`.
500500

501+
== Skip fetching latest
502+
503+
For some BWC testing scenarios, you want to use the local clone of the
504+
repository without fetching latest. For these use cases, you can set the system
505+
property `tests.bwc.git_fetch_latest` to `false` and the BWC builds will skip
506+
fetching the latest from the remote.
507+
501508
== Test coverage analysis
502509

503510
Generating test coverage reports for Elasticsearch is currently not possible through Gradle.

distribution/bwc/build.gradle

+11-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ subprojects {
5454

5555
final String remote = System.getProperty("tests.bwc.remote", "elastic")
5656

57+
final boolean gitFetchLatest
58+
final String gitFetchLatestProperty = System.getProperty("tests.bwc.git_fetch_latest", "true")
59+
if ("true".equals(gitFetchLatestProperty)) {
60+
gitFetchLatest = true
61+
} else if ("false".equals(gitFetchLatestProperty)) {
62+
gitFetchLatest = false
63+
} else {
64+
throw new GradleException("tests.bwc.git_fetch_latest must be [true] or [false] but was [" + gitFetchLatestProperty + "]")
65+
}
66+
5767
task createClone(type: LoggedExec) {
5868
onlyIf { checkoutDir.exists() == false }
5969
commandLine = ['git', 'clone', rootDir, checkoutDir]
@@ -83,7 +93,7 @@ subprojects {
8393
}
8494

8595
task fetchLatest(type: LoggedExec) {
86-
onlyIf { project.gradle.startParameter.isOffline() == false }
96+
onlyIf { project.gradle.startParameter.isOffline() == false && gitFetchLatest }
8797
dependsOn addRemote
8898
workingDir = checkoutDir
8999
commandLine = ['git', 'fetch', '--all']

0 commit comments

Comments
 (0)