From d50a7e43fc83267020bb6f0b43c176911e52f334 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 21 Nov 2017 08:26:45 +0000 Subject: [PATCH 01/23] Unused imports --- build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.gradle b/build.gradle index 4484d3fc14c0e..0392408758a67 100644 --- a/build.gradle +++ b/build.gradle @@ -19,8 +19,6 @@ import java.nio.file.Path import java.util.regex.Matcher -import org.eclipse.jgit.lib.Repository -import org.eclipse.jgit.lib.RepositoryBuilder import org.gradle.plugins.ide.eclipse.model.SourceFolder import org.apache.tools.ant.taskdefs.condition.Os import org.elasticsearch.gradle.BuildPlugin From d232d2f28c36588899f2eadb8e65325d2a190d7f Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 21 Nov 2017 08:27:13 +0000 Subject: [PATCH 02/23] Typo --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0392408758a67..e208bec57b61a 100644 --- a/build.gradle +++ b/build.gradle @@ -65,7 +65,7 @@ configure(subprojects.findAll { it.projectDir.toPath().startsWith(rootPath) }) { } } -/* Introspect all versions of ES that may be tested agains for backwards +/* Introspect all versions of ES that may be tested against for backwards * compatibility. It is *super* important that this logic is the same as the * logic in VersionUtils.java, throwing out alphas because they don't have any * backwards compatibility guarantees and only keeping the latest beta or rc From d858eb4ad38aa97fbdeef35f40626c23a113fcc6 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 21 Nov 2017 08:47:08 +0000 Subject: [PATCH 03/23] Rename version number component 'bugfix' to 'revision' It's called `revision` in `Version.java` and `bugfix` in `Version.groovy` which is a source of some confusion. `revision` seems more correct - it's not just about fixing bugs. --- build.gradle | 26 +++++++++---------- .../org/elasticsearch/gradle/Version.groovy | 10 +++---- distribution/bwc/build.gradle | 10 +++---- qa/full-cluster-restart/build.gradle | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/build.gradle b/build.gradle index e208bec57b61a..262358d4d0e58 100644 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,7 @@ List versions = [] // keep track of the previous major version's last minor, so we know where wire compat begins int prevMinorIndex = -1 // index in the versions list of the last minor from the prev major int lastPrevMinor = -1 // the minor version number from the prev major we most recently seen -int prevBugfixIndex = -1 // index in the versions list of the last bugfix release from the prev major +int prevRevisionIndex = -1 // index in the versions list of the last release from the prev major for (String line : versionLines) { /* Note that this skips alphas and betas which is fine because they aren't * compatible with anything. */ @@ -87,9 +87,9 @@ for (String line : versionLines) { if (match.matches()) { int major = Integer.parseInt(match.group(1)) int minor = Integer.parseInt(match.group(2)) - int bugfix = Integer.parseInt(match.group(3)) + int revision = Integer.parseInt(match.group(3)) String suffix = (match.group(4) ?: '').replace('_', '-') - Version foundVersion = new Version(major, minor, bugfix, suffix, false) + Version foundVersion = new Version(major, minor, revision, suffix, false) if (currentVersion != foundVersion && (major == prevMajor || major == currentVersion.major)) { if (versions.isEmpty() || versions.last() != foundVersion) { @@ -108,7 +108,7 @@ for (String line : versionLines) { } } if (major == prevMajor) { - prevBugfixIndex = versions.size() - 1 + prevRevisionIndex = versions.size() - 1 } } } @@ -116,20 +116,20 @@ if (versions.toSorted { it.id } != versions) { println "Versions: ${versions}" throw new GradleException("Versions.java contains out of order version constants") } -if (prevBugfixIndex != -1) { - versions[prevBugfixIndex] = new Version(versions[prevBugfixIndex].major, versions[prevBugfixIndex].minor, - versions[prevBugfixIndex].bugfix, versions[prevBugfixIndex].suffix, true) +if (prevRevisionIndex != -1) { + versions[prevRevisionIndex] = new Version(versions[prevRevisionIndex].major, versions[prevRevisionIndex].minor, + versions[prevRevisionIndex].revision, versions[prevRevisionIndex].suffix, true) } -if (currentVersion.bugfix == 0) { - // If on a release branch, after the initial release of that branch, the bugfix version will +if (currentVersion.revision == 0) { + // If on a release branch, after the initial release of that branch, the revision version will // be bumped, and will be != 0. On master and N.x branches, we want to test against the // unreleased version of closest branch. So for those cases, the version includes -SNAPSHOT, // and the bwc distribution will checkout and build that version. Version last = versions[-1] - versions[-1] = new Version(last.major, last.minor, last.bugfix, last.suffix, true) - if (last.bugfix == 0) { + versions[-1] = new Version(last.major, last.minor, last.revision, last.suffix, true) + if (last.revision == 0) { versions[-2] = new Version( - versions[-2].major, versions[-2].minor, versions[-2].bugfix, versions[-2].suffix, true) + versions[-2].major, versions[-2].minor, versions[-2].revision, versions[-2].suffix, true) } } @@ -255,7 +255,7 @@ subprojects { /* The last and second to last versions can be snapshots. Rather than use * snapshots built by CI we connect these versions to projects that build * those those versions from the HEAD of the appropriate branch. */ - if (indexCompatVersions[-1].bugfix == 0) { + if (indexCompatVersions[-1].revision == 0) { ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot' ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot' ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot' diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy index ee28dd8a99469..637fb44191e99 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy @@ -31,7 +31,7 @@ public class Version { final int major final int minor - final int bugfix + final int revision final int id final boolean snapshot /** @@ -41,14 +41,14 @@ public class Version { */ final String suffix - public Version(int major, int minor, int bugfix, + public Version(int major, int minor, int revision, String suffix, boolean snapshot) { this.major = major this.minor = minor - this.bugfix = bugfix + this.revision = revision this.snapshot = snapshot this.suffix = suffix - this.id = major * 100000 + minor * 1000 + bugfix * 10 + + this.id = major * 100000 + minor * 1000 + revision * 10 + (snapshot ? 1 : 0) } @@ -64,7 +64,7 @@ public class Version { @Override public String toString() { String snapshotStr = snapshot ? '-SNAPSHOT' : '' - return "${major}.${minor}.${bugfix}${suffix}${snapshotStr}" + return "${major}.${minor}.${revision}${suffix}${snapshotStr}" } public boolean before(String compareTo) { diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index f4cc2628df9e0..dda038cb65dae 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -30,11 +30,11 @@ String bwcVersion boolean enabled = true if (project.name == 'bwc-stable-snapshot') { /* bwc-stable is only used if the last version is on a stable branch instead - * of a bugfix branch */ - enabled = indexCompatVersions[-1].bugfix == 0 + * of a revision branch */ + enabled = indexCompatVersions[-1].revision == 0 bwcVersion = indexCompatVersions[-1] } else if (project.name == 'bwc-release-snapshot') { - if (indexCompatVersions[-1].bugfix == 0) { + if (indexCompatVersions[-1].revision == 0) { /* The last version is on a stable branch so it is handled by the bwc-stable * project. This project will instead handle the version before that which * *should* be on a stable branch. */ @@ -53,8 +53,8 @@ if (enabled) { tasks.remove(assemble) build.dependsOn.remove('assemble') - def (String major, String minor, String bugfix) = bwcVersion.split('\\.') - def (String currentMajor, String currentMinor, String currentBugfix) = version.split('\\.') + def (String major, String minor, String revision) = bwcVersion.split('\\.') + def (String currentMajor, String currentMinor, String currentRevision) = version.split('\\.') String bwcBranch if (project.name == 'bwc-stable-snapshot' && major != currentMajor) { bwcBranch = "${major}.x" diff --git a/qa/full-cluster-restart/build.gradle b/qa/full-cluster-restart/build.gradle index f271dae5cfda1..67b7f6d68d832 100644 --- a/qa/full-cluster-restart/build.gradle +++ b/qa/full-cluster-restart/build.gradle @@ -105,7 +105,7 @@ test.enabled = false // no unit tests for rolling upgrades, only the rest integr task integTest { if (project.bwc_tests_enabled) { dependsOn "v${indexCompatVersions[-1]}#bwcTest" - if (indexCompatVersions[-1].bugfix == 0) { + if (indexCompatVersions[-1].revision == 0) { dependsOn "v${indexCompatVersions[-2]}#bwcTest" } } From dd5eb22aedb2f01fb10359221f77fcd5a894b159 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 21 Nov 2017 10:40:22 +0000 Subject: [PATCH 04/23] Extract logic for reading `Version.java` out of `build.gradle` --- build.gradle | 86 ++++------------ .../org/elasticsearch/gradle/Version.groovy | 12 +++ .../elasticsearch/gradle/VersionUtils.groovy | 99 +++++++++++++++++++ 3 files changed, 128 insertions(+), 69 deletions(-) create mode 100644 buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionUtils.groovy diff --git a/build.gradle b/build.gradle index 262358d4d0e58..524a2a5c5f1a6 100644 --- a/build.gradle +++ b/build.gradle @@ -17,13 +17,15 @@ * under the License. */ -import java.nio.file.Path -import java.util.regex.Matcher -import org.gradle.plugins.ide.eclipse.model.SourceFolder + import org.apache.tools.ant.taskdefs.condition.Os import org.elasticsearch.gradle.BuildPlugin -import org.elasticsearch.gradle.VersionProperties import org.elasticsearch.gradle.Version +import org.elasticsearch.gradle.VersionProperties +import org.elasticsearch.gradle.VersionUtils +import org.gradle.plugins.ide.eclipse.model.SourceFolder + +import java.nio.file.Path // common maven publishing configuration subprojects { @@ -71,67 +73,8 @@ configure(subprojects.findAll { it.projectDir.toPath().startsWith(rootPath) }) { * backwards compatibility guarantees and only keeping the latest beta or rc * in a branch if there are only betas and rcs in the branch so we have * *something* to test against. */ -Version currentVersion = Version.fromString(VersionProperties.elasticsearch.minus('-SNAPSHOT')) -int prevMajor = currentVersion.major - 1 -File versionFile = file('core/src/main/java/org/elasticsearch/Version.java') -List versionLines = versionFile.readLines('UTF-8') -List versions = [] -// keep track of the previous major version's last minor, so we know where wire compat begins -int prevMinorIndex = -1 // index in the versions list of the last minor from the prev major -int lastPrevMinor = -1 // the minor version number from the prev major we most recently seen -int prevRevisionIndex = -1 // index in the versions list of the last release from the prev major -for (String line : versionLines) { - /* Note that this skips alphas and betas which is fine because they aren't - * compatible with anything. */ - Matcher match = line =~ /\W+public static final Version V_(\d+)_(\d+)_(\d+)(_beta\d+|_rc\d+)? .*/ - if (match.matches()) { - int major = Integer.parseInt(match.group(1)) - int minor = Integer.parseInt(match.group(2)) - int revision = Integer.parseInt(match.group(3)) - String suffix = (match.group(4) ?: '').replace('_', '-') - Version foundVersion = new Version(major, minor, revision, suffix, false) - if (currentVersion != foundVersion - && (major == prevMajor || major == currentVersion.major)) { - if (versions.isEmpty() || versions.last() != foundVersion) { - versions.add(foundVersion) - } else { - // Replace the earlier betas with later ones - Version last = versions.set(versions.size() - 1, foundVersion) - if (last.suffix == '') { - throw new InvalidUserDataException("Found two equal versions but" - + " the first one [$last] wasn't a beta.") - } - } - if (major == prevMajor && minor > lastPrevMinor) { - prevMinorIndex = versions.size() - 1 - lastPrevMinor = minor - } - } - if (major == prevMajor) { - prevRevisionIndex = versions.size() - 1 - } - } -} -if (versions.toSorted { it.id } != versions) { - println "Versions: ${versions}" - throw new GradleException("Versions.java contains out of order version constants") -} -if (prevRevisionIndex != -1) { - versions[prevRevisionIndex] = new Version(versions[prevRevisionIndex].major, versions[prevRevisionIndex].minor, - versions[prevRevisionIndex].revision, versions[prevRevisionIndex].suffix, true) -} -if (currentVersion.revision == 0) { - // If on a release branch, after the initial release of that branch, the revision version will - // be bumped, and will be != 0. On master and N.x branches, we want to test against the - // unreleased version of closest branch. So for those cases, the version includes -SNAPSHOT, - // and the bwc distribution will checkout and build that version. - Version last = versions[-1] - versions[-1] = new Version(last.major, last.minor, last.revision, last.suffix, true) - if (last.revision == 0) { - versions[-2] = new Version( - versions[-2].major, versions[-2].minor, versions[-2].revision, versions[-2].suffix, true) - } -} +List versions = VersionUtils.parseVersions(file('core/src/main/java/org/elasticsearch/Version.java').readLines('UTF-8')) +Version currentVersion = versions[-1] // build metadata from previous build, contains eg hashes for bwc builds String buildMetadataValue = System.getenv('BUILD_METADATA') @@ -149,9 +92,14 @@ allprojects { // for ide hacks... isEclipse = System.getProperty("eclipse.launcher") != null || gradle.startParameter.taskNames.contains('eclipse') || gradle.startParameter.taskNames.contains('cleanEclipse') isIdea = System.getProperty("idea.active") != null || gradle.startParameter.taskNames.contains('idea') || gradle.startParameter.taskNames.contains('cleanIdea') - // for backcompat testing - indexCompatVersions = versions - wireCompatVersions = versions.subList(prevMinorIndex, versions.size()) + + // for BWC testing + final String minimumIndexCompatibilityVersion = VersionUtils.getMinimumIndexCompatibilityVersion(versions).toString() + indexCompatVersions = versions.findAll { it.onOrAfter(minimumIndexCompatibilityVersion) && it != currentVersion } + + final String minimumWireCompatibilityVersion = VersionUtils.getMinimumWireCompatibilityVersion(versions).toString() + wireCompatVersions = versions.findAll { it.onOrAfter(minimumWireCompatibilityVersion) && it != currentVersion } + buildMetadata = buildMetadataMap } } @@ -169,7 +117,7 @@ task verifyVersions { Set knownVersions = new TreeSet<>(xml.versioning.versions.version.collect { it.text() }.findAll { it ==~ /\d\.\d\.\d/ }.collect { Version.fromString(it) }) // Limit the known versions to those that should be index compatible, and are not future versions - knownVersions = knownVersions.findAll { it.major >= prevMajor && it.before(VersionProperties.elasticsearch) } + knownVersions = knownVersions.findAll { it.major >= currentVersion.major - 1 && it.before(VersionProperties.elasticsearch) } /* Limit the listed versions to those that have been marked as released. * Versions not marked as released don't get the same testing and we want diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy index 637fb44191e99..63a1c86d098a9 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy @@ -82,4 +82,16 @@ public class Version { public boolean after(String compareTo) { return id > fromString(compareTo).id } + + public boolean onOrBeforeIncludingSuffix(Version otherVersion) { + if (id != otherVersion.id) { + return id < otherVersion.id + } + + if (suffix == '') { + return otherVersion.suffix == '' + } + + return otherVersion.suffix == '' || suffix < otherVersion.suffix + } } diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionUtils.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionUtils.groovy new file mode 100644 index 0000000000000..31d07822c1ac5 --- /dev/null +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionUtils.groovy @@ -0,0 +1,99 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.gradle + +import org.gradle.api.GradleException + +import java.util.regex.Matcher + +class VersionUtils { + + /** + * Extract the declared version constants from Version.java, for use in BWC testing. + * @param versionLines The lines of Version.java + * @return The collection of versions found, in ascending order, excluding any superseded _alpha, _beta or _rc versions. + * Unreleased versions are marked as -SNAPSHOT versions. + */ + static List parseVersions(List versionLines) { + final List versions = [] + for (final String line : versionLines) { + final Matcher match = line =~ /\W+public static final Version V_(\d+)_(\d+)_(\d+)(_alpha\d+|_beta\d+|_rc\d+)? .*/ + if (match.matches()) { + final Version foundVersion = new Version( + Integer.parseInt(match.group(1)), Integer.parseInt(match.group(2)), + Integer.parseInt(match.group(3)), (match.group(4) ?: '').replace('_', '-'), false) + + if (versions.size() > 0 && foundVersion.onOrBeforeIncludingSuffix(versions[-1])) { + throw new GradleException("Versions.java contains out of order version constants:" + + " ${foundVersion} should come before ${versions[-1]}") + } + + // Only keep the last alpha/beta/rc in the series + if (versions.size() > 0 && versions[-1].id == foundVersion.id) { + versions[-1] = foundVersion + } else { + versions.add(foundVersion) + } + } + } + + // The tip of each minor series (>= 5.6) is unreleased, so set their 'snapshot' flags + Version prevConsideredVersion = null + for (final int versionIndex = versions.size() - 1; versionIndex >= 0; versionIndex--) { + final Version currConsideredVersion = versions[versionIndex] + + if (prevConsideredVersion == null + || currConsideredVersion.major != prevConsideredVersion.major + || currConsideredVersion.minor != prevConsideredVersion.minor) { + + versions[versionIndex] = new Version( + currConsideredVersion.major, currConsideredVersion.minor, + currConsideredVersion.revision, currConsideredVersion.suffix, true) + } + + if (currConsideredVersion.onOrBefore("5.6.0")) { + break + } + + prevConsideredVersion = currConsideredVersion + } + if (versions[-1].toString() != VersionProperties.elasticsearch) { + throw new GradleException("The last version in Versions.java [${versions[-1]}] does not match " + + "VersionProperties.elasticsearch [${VersionProperties.elasticsearch}]") + } + + return versions + } + + static Version getMinimumIndexCompatibilityVersion(List versions) { + final Version currentVersion = versions[-1] + return versions.find { it.major >= currentVersion.major - 1 } + } + + static Version getMinimumWireCompatibilityVersion(List versions) { + final Version currentVersion = versions[-1] + final int firstIndexOfThisMajor = versions.findIndexOf { it.major == currentVersion.major } + if (firstIndexOfThisMajor == 0) { + return versions[0] + } + final Version lastVersionOfEarlierMajor = versions[firstIndexOfThisMajor - 1] + return versions.find { it.major == lastVersionOfEarlierMajor.major && it.minor == lastVersionOfEarlierMajor.minor } + } +} From d9a1564c051569d4c3acc511f5c777de0665d519 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 21 Nov 2017 12:38:32 +0000 Subject: [PATCH 05/23] Add calculations of snapshots for BWC testing --- .../org/elasticsearch/gradle/VersionUtils.groovy | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionUtils.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionUtils.groovy index 31d07822c1ac5..fa07f163f89a0 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionUtils.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionUtils.groovy @@ -96,4 +96,20 @@ class VersionUtils { final Version lastVersionOfEarlierMajor = versions[firstIndexOfThisMajor - 1] return versions.find { it.major == lastVersionOfEarlierMajor.major && it.minor == lastVersionOfEarlierMajor.minor } } + + static Version getBWCSnapshotForCurrentMajor(List versions) { + return getLastSnapshotWithMajor(versions, versions[-1].major) + } + + static Version getBWCSnapshotForPreviousMajor(List versions) { + return getLastSnapshotWithMajor(versions, versions[-1].major - 1) + } + + static Version getLastSnapshotWithMajor(List versions, int targetMajor) { + def currentVersion = versions[-1].toString() + final int snapshotIndex = versions.findLastIndexOf { + it.major == targetMajor && it.before(currentVersion) && it.snapshot + } + return snapshotIndex == -1 ? null : versions[snapshotIndex] + } } From 53b0e5730d16722c00f1a3587e853e94b5b5a38c Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 21 Nov 2017 13:30:52 +0000 Subject: [PATCH 06/23] Convert VersionUtils into VersionCollection, encapsulating the list of versions --- build.gradle | 15 ++-- ...nUtils.groovy => VersionCollection.groovy} | 79 +++++++++++-------- 2 files changed, 54 insertions(+), 40 deletions(-) rename buildSrc/src/main/groovy/org/elasticsearch/gradle/{VersionUtils.groovy => VersionCollection.groovy} (67%) diff --git a/build.gradle b/build.gradle index 524a2a5c5f1a6..1bc86a551fb80 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ import org.apache.tools.ant.taskdefs.condition.Os import org.elasticsearch.gradle.BuildPlugin import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.VersionProperties -import org.elasticsearch.gradle.VersionUtils +import org.elasticsearch.gradle.VersionCollection import org.gradle.plugins.ide.eclipse.model.SourceFolder import java.nio.file.Path @@ -73,8 +73,7 @@ configure(subprojects.findAll { it.projectDir.toPath().startsWith(rootPath) }) { * backwards compatibility guarantees and only keeping the latest beta or rc * in a branch if there are only betas and rcs in the branch so we have * *something* to test against. */ -List versions = VersionUtils.parseVersions(file('core/src/main/java/org/elasticsearch/Version.java').readLines('UTF-8')) -Version currentVersion = versions[-1] +VersionCollection versions = new VersionCollection(file('core/src/main/java/org/elasticsearch/Version.java').readLines('UTF-8')) // build metadata from previous build, contains eg hashes for bwc builds String buildMetadataValue = System.getenv('BUILD_METADATA') @@ -94,11 +93,9 @@ allprojects { isIdea = System.getProperty("idea.active") != null || gradle.startParameter.taskNames.contains('idea') || gradle.startParameter.taskNames.contains('cleanIdea') // for BWC testing - final String minimumIndexCompatibilityVersion = VersionUtils.getMinimumIndexCompatibilityVersion(versions).toString() - indexCompatVersions = versions.findAll { it.onOrAfter(minimumIndexCompatibilityVersion) && it != currentVersion } - - final String minimumWireCompatibilityVersion = VersionUtils.getMinimumWireCompatibilityVersion(versions).toString() - wireCompatVersions = versions.findAll { it.onOrAfter(minimumWireCompatibilityVersion) && it != currentVersion } + versionCollection = versions + indexCompatVersions = versions.getVersionsIndexCompatibleWithCurrent() + wireCompatVersions = versions.getVersionsWireCompatibleWithCurrent() buildMetadata = buildMetadataMap } @@ -117,7 +114,7 @@ task verifyVersions { Set knownVersions = new TreeSet<>(xml.versioning.versions.version.collect { it.text() }.findAll { it ==~ /\d\.\d\.\d/ }.collect { Version.fromString(it) }) // Limit the known versions to those that should be index compatible, and are not future versions - knownVersions = knownVersions.findAll { it.major >= currentVersion.major - 1 && it.before(VersionProperties.elasticsearch) } + knownVersions = knownVersions.findAll { it.major >= versions.getCurrentVersion().major - 1 && it.before(VersionProperties.elasticsearch) } /* Limit the listed versions to those that have been marked as released. * Versions not marked as released don't get the same testing and we want diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionUtils.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy similarity index 67% rename from buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionUtils.groovy rename to buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy index fa07f163f89a0..6ddded95568b4 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionUtils.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy @@ -23,16 +23,17 @@ import org.gradle.api.GradleException import java.util.regex.Matcher -class VersionUtils { - - /** - * Extract the declared version constants from Version.java, for use in BWC testing. - * @param versionLines The lines of Version.java - * @return The collection of versions found, in ascending order, excluding any superseded _alpha, _beta or _rc versions. - * Unreleased versions are marked as -SNAPSHOT versions. - */ - static List parseVersions(List versionLines) { - final List versions = [] +/** + * The collection of version constants declared in Version.java, for use in BWC testing. + */ +class VersionCollection { + + private final List versions + + VersionCollection(List versionLines) { + + List versions = [] + for (final String line : versionLines) { final Matcher match = line =~ /\W+public static final Version V_(\d+)_(\d+)_(\d+)(_alpha\d+|_beta\d+|_rc\d+)? .*/ if (match.matches()) { @@ -74,42 +75,58 @@ class VersionUtils { prevConsideredVersion = currConsideredVersion } - if (versions[-1].toString() != VersionProperties.elasticsearch) { + + this.versions = Collections.unmodifiableList(versions) + + if (getCurrentVersion().toString() != VersionProperties.elasticsearch) { throw new GradleException("The last version in Versions.java [${versions[-1]}] does not match " + "VersionProperties.elasticsearch [${VersionProperties.elasticsearch}]") } + } - return versions + Version getCurrentVersion() { + return versions[-1] } - static Version getMinimumIndexCompatibilityVersion(List versions) { - final Version currentVersion = versions[-1] - return versions.find { it.major >= currentVersion.major - 1 } + Version getBWCSnapshotForCurrentMajor() { + return getLastSnapshotWithMajor(versions, getCurrentVersion().major) } - static Version getMinimumWireCompatibilityVersion(List versions) { - final Version currentVersion = versions[-1] - final int firstIndexOfThisMajor = versions.findIndexOf { it.major == currentVersion.major } - if (firstIndexOfThisMajor == 0) { - return versions[0] + Version getBWCSnapshotForPreviousMajor() { + return getLastSnapshotWithMajor(versions, getCurrentVersion().major - 1) + } + + private Version getLastSnapshotWithMajor(int targetMajor) { + final def currentVersion = getCurrentVersion().toString() + final int snapshotIndex = versions.findLastIndexOf { + it.major == targetMajor && it.before(currentVersion) && it.snapshot } - final Version lastVersionOfEarlierMajor = versions[firstIndexOfThisMajor - 1] - return versions.find { it.major == lastVersionOfEarlierMajor.major && it.minor == lastVersionOfEarlierMajor.minor } + return snapshotIndex == -1 ? null : versions[snapshotIndex] } - static Version getBWCSnapshotForCurrentMajor(List versions) { - return getLastSnapshotWithMajor(versions, versions[-1].major) + private List versionsOnOrAfterExceptCurrent(Version minVersion) { + final def minVersionString = minVersion.toString(); + return Collections.unmodifiableList(versions.findAll { + it.onOrAfter(minVersionString) && it != getCurrentVersion() + }) } - static Version getBWCSnapshotForPreviousMajor(List versions) { - return getLastSnapshotWithMajor(versions, versions[-1].major - 1) + List getVersionsIndexCompatibleWithCurrent() { + final def firstVersionOfCurrentMajor = versions.find { it.major >= getCurrentVersion().major - 1 } + return versionsOnOrAfterExceptCurrent(firstVersionOfCurrentMajor) } - static Version getLastSnapshotWithMajor(List versions, int targetMajor) { - def currentVersion = versions[-1].toString() - final int snapshotIndex = versions.findLastIndexOf { - it.major == targetMajor && it.before(currentVersion) && it.snapshot + private Version getMinimumWireCompatibilityVersion() { + final def currentVersion = getCurrentVersion() + final def firstIndexOfThisMajor = versions.findIndexOf { it.major == currentVersion.major } + if (firstIndexOfThisMajor == 0) { + return versions[0] } - return snapshotIndex == -1 ? null : versions[snapshotIndex] + final def lastVersionOfEarlierMajor = versions[firstIndexOfThisMajor - 1] + return versions.find { it.major == lastVersionOfEarlierMajor.major && it.minor == lastVersionOfEarlierMajor.minor } + } + + List getVersionsWireCompatibleWithCurrent() { + return versionsOnOrAfterExceptCurrent(getMinimumWireCompatibilityVersion()) } } From 1e6060573e65ff68e5dbb749a8c128d51b6e94c3 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 21 Nov 2017 14:57:55 +0000 Subject: [PATCH 07/23] Get rid of indexCompatVersions and wireCompatVersions and simply use versionCollection where needed --- build.gradle | 42 +++++++------------ buildSrc/build.gradle | 7 +++- .../gradle/VersionCollection.groovy | 28 +++++++++---- .../gradle/vagrant/VagrantTestPlugin.groovy | 3 +- .../test/VersionCollectionTests.java | 23 ++++++++++ distribution/bwc/build.gradle | 29 ++++--------- qa/full-cluster-restart/build.gradle | 10 ++--- qa/mixed-cluster/build.gradle | 6 +-- qa/query-builder-bwc/build.gradle | 6 ++- qa/rolling-upgrade/build.gradle | 6 ++- qa/verify-version-constants/build.gradle | 6 ++- test/framework/build.gradle | 4 +- 12 files changed, 98 insertions(+), 72 deletions(-) create mode 100644 buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java diff --git a/build.gradle b/build.gradle index 1bc86a551fb80..d8541b316a653 100644 --- a/build.gradle +++ b/build.gradle @@ -94,8 +94,6 @@ allprojects { // for BWC testing versionCollection = versions - indexCompatVersions = versions.getVersionsIndexCompatibleWithCurrent() - wireCompatVersions = versions.getVersionsWireCompatibleWithCurrent() buildMetadata = buildMetadataMap } @@ -120,7 +118,7 @@ task verifyVersions { * Versions not marked as released don't get the same testing and we want * to make sure that we flip all unreleased versions to released as soon * as possible after release. */ - Set actualVersions = new TreeSet<>(indexCompatVersions.findAll { false == it.snapshot }) + Set actualVersions = new TreeSet<>(versions.versionsIndexCompatibleWithCurrent.findAll { false == it.snapshot }) // Finally, compare! if (knownVersions.equals(actualVersions) == false) { @@ -196,30 +194,22 @@ subprojects { "org.elasticsearch.plugin:percolator-client:${version}": ':modules:percolator', "org.elasticsearch.plugin:aggs-composite-client:${version}": ':modules:aggs-composite', ] - if (indexCompatVersions[-1].snapshot) { - /* The last and second to last versions can be snapshots. Rather than use - * snapshots built by CI we connect these versions to projects that build - * those those versions from the HEAD of the appropriate branch. */ - if (indexCompatVersions[-1].revision == 0) { - ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot' - ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot' - ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot' - if (indexCompatVersions.size() > 1) { - ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot' - ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot' - ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot' - } - } else { - ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot' - ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot' - ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot' - } - } else if (indexCompatVersions[-2].snapshot) { - /* This is a terrible hack for the bump to 6.0.1 which will be fixed by #27397 */ - ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot' - ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot' - ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot' + + final def bwcStableSnapshot = versionCollection.BWCSnapshotForPreviousMajor + if (bwcStableSnapshot != null) { + ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-stable-snapshot' + ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-stable-snapshot' + ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-stable-snapshot' } + final def bwcReleaseSnapshot = versionCollection.BWCSnapshotForCurrentMajor + if (bwcReleaseSnapshot != null) { + ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${bwcReleaseSnapshot}"] = ':distribution:bwc-release-snapshot' + ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${bwcReleaseSnapshot}"] = ':distribution:bwc-release-snapshot' + ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${bwcReleaseSnapshot}"] = ':distribution:bwc-release-snapshot' + } + // TODO there might be another one to test: if CURRENT == 6.2.0 and 6.1.0 is not released + // then we need to test against 6.1.0-SNAPSHOT, 6.0.max-SNAPSHOT and 5.6.max-SNAPSHOT + project.afterEvaluate { configurations.all { resolutionStrategy.dependencySubstitution { DependencySubstitutions subs -> diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 7c6f3002f708f..9e092618669e0 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -121,6 +121,7 @@ if (project == rootProject) { } mavenCentral() } + compileTestJava.enabled = false test.exclude 'org/elasticsearch/test/NamingConventionsCheckBadClasses*' } @@ -146,7 +147,11 @@ if (project != rootProject) { thirdPartyAudit.enabled = false // test for elasticsearch.build tries to run with ES... - test.enabled = false + dependencies { + testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" + testCompile "junit:junit:${versions.junit}" + testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}" + } // TODO: re-enable once randomizedtesting gradle code is published and removed from here licenseHeaders.enabled = false diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy index 6ddded95568b4..71dba6db08484 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy @@ -89,15 +89,15 @@ class VersionCollection { } Version getBWCSnapshotForCurrentMajor() { - return getLastSnapshotWithMajor(versions, getCurrentVersion().major) + return getLastSnapshotWithMajor(currentVersion.major) } Version getBWCSnapshotForPreviousMajor() { - return getLastSnapshotWithMajor(versions, getCurrentVersion().major - 1) + return getLastSnapshotWithMajor(currentVersion.major - 1) } private Version getLastSnapshotWithMajor(int targetMajor) { - final def currentVersion = getCurrentVersion().toString() + final def currentVersion = currentVersion.toString() final int snapshotIndex = versions.findLastIndexOf { it.major == targetMajor && it.before(currentVersion) && it.snapshot } @@ -107,17 +107,16 @@ class VersionCollection { private List versionsOnOrAfterExceptCurrent(Version minVersion) { final def minVersionString = minVersion.toString(); return Collections.unmodifiableList(versions.findAll { - it.onOrAfter(minVersionString) && it != getCurrentVersion() + it.onOrAfter(minVersionString) && it != currentVersion }) } List getVersionsIndexCompatibleWithCurrent() { - final def firstVersionOfCurrentMajor = versions.find { it.major >= getCurrentVersion().major - 1 } + final def firstVersionOfCurrentMajor = versions.find { it.major >= currentVersion.major - 1 } return versionsOnOrAfterExceptCurrent(firstVersionOfCurrentMajor) } private Version getMinimumWireCompatibilityVersion() { - final def currentVersion = getCurrentVersion() final def firstIndexOfThisMajor = versions.findIndexOf { it.major == currentVersion.major } if (firstIndexOfThisMajor == 0) { return versions[0] @@ -127,6 +126,21 @@ class VersionCollection { } List getVersionsWireCompatibleWithCurrent() { - return versionsOnOrAfterExceptCurrent(getMinimumWireCompatibilityVersion()) + return versionsOnOrAfterExceptCurrent(minimumWireCompatibilityVersion) + } + + List getBasicIntegrationTestVersions() { + // TODO these are the versions checked by `gradle check` for BWC tests. Their choice seems a litle arbitrary. + List result = [] + def v1 = BWCSnapshotForCurrentMajor + if (v1 != null) { // TODO remove null check. Should never be null? + result.add(v1) + if (v1.revision == 0) { + final def v2 = BWCSnapshotForPreviousMajor + result.add(v2) + } + } + + return Collections.unmodifiableList(result); } } diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy index 59a7359a6391b..2510620ac712b 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy @@ -107,7 +107,8 @@ class VagrantTestPlugin implements Plugin { if (upgradeFromVersion == null) { String firstPartOfSeed = project.rootProject.testSeed.tokenize(':').get(0) final long seed = Long.parseUnsignedLong(firstPartOfSeed, 16) - upgradeFromVersion = project.indexCompatVersions[new Random(seed).nextInt(project.indexCompatVersions.size())] + final def indexCompatVersions = project.versionCollection.versionsIndexCompatibleWithCurrent + upgradeFromVersion = indexCompatVersions[new Random(seed).nextInt(indexCompatVersions.size())] } DISTRIBUTION_ARCHIVES.each { diff --git a/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java b/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java new file mode 100644 index 0000000000000..8c7b849bb3d21 --- /dev/null +++ b/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java @@ -0,0 +1,23 @@ +package org.elasticsearch.test;/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import com.carrotsearch.randomizedtesting.RandomizedTest; + +public class VersionCollectionTests extends RandomizedTest { +} diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index dda038cb65dae..1110b1ba832d6 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -19,6 +19,7 @@ import org.elasticsearch.gradle.LoggedExec +import org.elasticsearch.gradle.Version /** * This is a dummy project which does a local checkout of the previous @@ -26,40 +27,26 @@ import org.elasticsearch.gradle.LoggedExec * tests to test against the next unreleased version, closest to this version, * without relying on snapshots. */ -String bwcVersion -boolean enabled = true +Version bwcVersion if (project.name == 'bwc-stable-snapshot') { - /* bwc-stable is only used if the last version is on a stable branch instead - * of a revision branch */ - enabled = indexCompatVersions[-1].revision == 0 - bwcVersion = indexCompatVersions[-1] + bwcVersion = versionCollection.BWCSnapshotForPreviousMajor } else if (project.name == 'bwc-release-snapshot') { - if (indexCompatVersions[-1].revision == 0) { - /* The last version is on a stable branch so it is handled by the bwc-stable - * project. This project will instead handle the version before that which - * *should* be on a stable branch. */ - bwcVersion = indexCompatVersions[-2] - } else { - // The last version is on a release branch so it is handled by this project - bwcVersion = indexCompatVersions[-1] - } + bwcVersion = versionCollection.BWCSnapshotForCurrentMajor } else { throw new InvalidUserDataException("Unsupport project name ${project.name}") } -if (enabled) { +if (bwcVersion != null) { apply plugin: 'distribution' // Not published so no need to assemble tasks.remove(assemble) build.dependsOn.remove('assemble') - def (String major, String minor, String revision) = bwcVersion.split('\\.') - def (String currentMajor, String currentMinor, String currentRevision) = version.split('\\.') String bwcBranch - if (project.name == 'bwc-stable-snapshot' && major != currentMajor) { - bwcBranch = "${major}.x" + if (project.name == 'bwc-stable-snapshot' && bwcVersion.major != versionCollection.currentVersion.major) { + bwcBranch = "${bwcVersion.major}.x" } else { - bwcBranch = "${major}.${minor}" + bwcBranch = "${bwcVersion.major}.${bwcVersion.minor}" } File checkoutDir = file("${buildDir}/bwc/checkout-${bwcBranch}") diff --git a/qa/full-cluster-restart/build.gradle b/qa/full-cluster-restart/build.gradle index 67b7f6d68d832..123b217a38af3 100644 --- a/qa/full-cluster-restart/build.gradle +++ b/qa/full-cluster-restart/build.gradle @@ -17,8 +17,9 @@ * under the License. */ -import org.elasticsearch.gradle.test.RestIntegTestTask + import org.elasticsearch.gradle.Version +import org.elasticsearch.gradle.test.RestIntegTestTask apply plugin: 'elasticsearch.standalone-test' @@ -29,7 +30,7 @@ task bwcTest { group = 'verification' } -for (Version version : indexCompatVersions) { +for (Version version : versionCollection.versionsIndexCompatibleWithCurrent) { String baseName = "v${version}" Task oldClusterTest = tasks.create(name: "${baseName}#oldClusterTest", type: RestIntegTestTask) { @@ -104,9 +105,8 @@ test.enabled = false // no unit tests for rolling upgrades, only the rest integr // basic integ tests includes testing bwc against the most recent version task integTest { if (project.bwc_tests_enabled) { - dependsOn "v${indexCompatVersions[-1]}#bwcTest" - if (indexCompatVersions[-1].revision == 0) { - dependsOn "v${indexCompatVersions[-2]}#bwcTest" + for (final def version : versionCollection.basicIntegrationTestVersions) { + dependsOn "v${version}#bwcTest" } } } diff --git a/qa/mixed-cluster/build.gradle b/qa/mixed-cluster/build.gradle index 66cad0c6eb678..c5806b3546c7c 100644 --- a/qa/mixed-cluster/build.gradle +++ b/qa/mixed-cluster/build.gradle @@ -29,7 +29,7 @@ task bwcTest { group = 'verification' } -for (Version version : wireCompatVersions) { +for (Version version : versionCollection.versionsWireCompatibleWithCurrent) { String baseName = "v${version}" Task mixedClusterTest = tasks.create(name: "${baseName}#mixedClusterTest", type: RestIntegTestTask) { @@ -68,8 +68,8 @@ test.enabled = false // no unit tests for rolling upgrades, only the rest integr // basic integ tests includes testing bwc against the most recent version task integTest { - if (project.bwc_tests_enabled) { - dependsOn = ["v${wireCompatVersions[-1]}#bwcTest"] + for (final def version : versionCollection.basicIntegrationTestVersions) { + dependsOn "v${version}#bwcTest" } } diff --git a/qa/query-builder-bwc/build.gradle b/qa/query-builder-bwc/build.gradle index f1e7ad6f640f0..16e9f6298feac 100644 --- a/qa/query-builder-bwc/build.gradle +++ b/qa/query-builder-bwc/build.gradle @@ -30,7 +30,7 @@ task bwcTest { group = 'verification' } -for (Version version : indexCompatVersions) { +for (Version version : versionCollection.versionsIndexCompatibleWithCurrent) { String baseName = "v${version}" Task oldQueryBuilderTest = tasks.create(name: "${baseName}#oldQueryBuilderTest", type: RestIntegTestTask) { @@ -83,7 +83,9 @@ test.enabled = false // no unit tests for rolling upgrades, only the rest integr // basic integ tests includes testing bwc against the most recent version task integTest { if (project.bwc_tests_enabled) { - dependsOn = ["v${indexCompatVersions[-1]}#bwcTest"] + for (final def version : versionCollection.basicIntegrationTestVersions) { + dependsOn "v${version}#bwcTest" + } } } diff --git a/qa/rolling-upgrade/build.gradle b/qa/rolling-upgrade/build.gradle index fc3cf88b272f1..13cccbd006232 100644 --- a/qa/rolling-upgrade/build.gradle +++ b/qa/rolling-upgrade/build.gradle @@ -29,7 +29,7 @@ task bwcTest { group = 'verification' } -for (Version version : wireCompatVersions) { +for (Version version : versionCollection.versionsWireCompatibleWithCurrent) { String baseName = "v${version}" Task oldClusterTest = tasks.create(name: "${baseName}#oldClusterTest", type: RestIntegTestTask) { @@ -111,7 +111,9 @@ test.enabled = false // no unit tests for rolling upgrades, only the rest integr // basic integ tests includes testing bwc against the most recent version task integTest { if (project.bwc_tests_enabled) { - dependsOn = ["v${wireCompatVersions[-1]}#bwcTest"] + for (final def version : versionCollection.basicIntegrationTestVersions) { + dependsOn "v${version}#bwcTest" + } } } diff --git a/qa/verify-version-constants/build.gradle b/qa/verify-version-constants/build.gradle index b501ffe168ba3..111c4ccf20e50 100644 --- a/qa/verify-version-constants/build.gradle +++ b/qa/verify-version-constants/build.gradle @@ -31,7 +31,7 @@ task bwcTest { group = 'verification' } -for (Version version : indexCompatVersions) { +for (Version version : versionCollection.versionsIndexCompatibleWithCurrent) { String baseName = "v${version}" Task oldClusterTest = tasks.create(name: "${baseName}#oldClusterTest", type: RestIntegTestTask) { mustRunAfter(precommit) @@ -57,7 +57,9 @@ for (Version version : indexCompatVersions) { test.enabled = false task integTest { - dependsOn = ["v${indexCompatVersions[-1]}#bwcTest"] + for (final def version : versionCollection.basicIntegrationTestVersions) { + dependsOn "v${version}#bwcTest" + } } task verifyDocsLuceneVersion { diff --git a/test/framework/build.gradle b/test/framework/build.gradle index 558bb2c851cb4..bbdbab5b2337a 100644 --- a/test/framework/build.gradle +++ b/test/framework/build.gradle @@ -69,6 +69,6 @@ task namingConventionsMain(type: org.elasticsearch.gradle.precommit.NamingConven precommit.dependsOn namingConventionsMain test.configure { - systemProperty 'tests.gradle_index_compat_versions', indexCompatVersions.join(',') - systemProperty 'tests.gradle_wire_compat_versions', wireCompatVersions.join(',') + systemProperty 'tests.gradle_index_compat_versions', versionCollection.versionsIndexCompatibleWithCurrent.join(',') + systemProperty 'tests.gradle_wire_compat_versions', versionCollection.versionsWireCompatibleWithCurrent.join(',') } From 403debd7c94d6834d66aa78091a6a815cc2a7bdd Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 21 Nov 2017 16:32:41 +0000 Subject: [PATCH 08/23] Add hack for testing vs different Version.java files --- build.gradle | 7 +++- buildSrc/build.gradle | 4 +- .../gradle/VersionCollection.groovy | 39 +++++++++++++------ .../test/VersionCollectionTests.java | 6 +++ 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index d8541b316a653..e8aac4d92c4cf 100644 --- a/build.gradle +++ b/build.gradle @@ -73,7 +73,12 @@ configure(subprojects.findAll { it.projectDir.toPath().startsWith(rootPath) }) { * backwards compatibility guarantees and only keeping the latest beta or rc * in a branch if there are only betas and rcs in the branch so we have * *something* to test against. */ -VersionCollection versions = new VersionCollection(file('core/src/main/java/org/elasticsearch/Version.java').readLines('UTF-8')) +def versionJava = System.getProperty("path.to.version.java") // TODO get rid of this and replace with proper testing, once testing is possible +if (versionJava == null) { + versionJava = 'core/src/main/java/org/elasticsearch/Version.java' +} + +VersionCollection versions = new VersionCollection(file(versionJava).readLines('UTF-8')) // build metadata from previous build, contains eg hashes for bwc builds String buildMetadataValue = System.getenv('BUILD_METADATA') diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 9e092618669e0..1083a59690b03 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -163,13 +163,13 @@ if (project != rootProject) { } namingConventions { - testClass = 'org.elasticsearch.test.NamingConventionsCheckBadClasses$UnitTestCase' + testClass = 'com.carrotsearch.randomizedtesting.RandomizedTest' integTestClass = 'org.elasticsearch.test.NamingConventionsCheckBadClasses$IntegTestCase' } task namingConventionsMain(type: org.elasticsearch.gradle.precommit.NamingConventionsTask) { checkForTestsInMain = true - testClass = namingConventions.testClass + testClass = 'org.elasticsearch.test.NamingConventionsCheckBadClasses$UnitTestCase' integTestClass = namingConventions.integTestClass } precommit.dependsOn namingConventionsMain diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy index 71dba6db08484..8f3ddc252cf8a 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy @@ -78,6 +78,16 @@ class VersionCollection { this.versions = Collections.unmodifiableList(versions) + // TODO remove and replace with testing, once testing is possible + println "VersionCollection: ${versions}" + println "currentVersion: ${currentVersion}" + println "BWCSnapshotForCurrentMajor: ${BWCSnapshotForCurrentMajor}" + println "BWCSnapshotForPreviousMinorOfCurrentMajor: ${BWCSnapshotForPreviousMinorOfCurrentMajor}" + println "BWCSnapshotForPreviousMajor: ${BWCSnapshotForPreviousMajor}" + println "versionsIndexCompatibleWithCurrent: ${versionsIndexCompatibleWithCurrent}" + println "versionsWireCompatibleWithCurrent: ${versionsWireCompatibleWithCurrent}" + println "basicIntegrationTestVersions: ${basicIntegrationTestVersions}" + if (getCurrentVersion().toString() != VersionProperties.elasticsearch) { throw new GradleException("The last version in Versions.java [${versions[-1]}] does not match " + "VersionProperties.elasticsearch [${VersionProperties.elasticsearch}]") @@ -93,7 +103,19 @@ class VersionCollection { } Version getBWCSnapshotForPreviousMajor() { - return getLastSnapshotWithMajor(currentVersion.major - 1) + def version = getLastSnapshotWithMajor(currentVersion.major - 1) + assert version != null : "getBWCSnapshotForPreviousMajor(): found no versions in the previous major" + return version + } + + Version getBWCSnapshotForPreviousMinorOfCurrentMajor() { + // If we are at 6.2.0 but 6.1.0 has not yet been released then we + // need to test against 6.0.1-SNAPSHOT too + final def v = BWCSnapshotForCurrentMajor + if (v == null || v.revision != 0 || v.minor == 0) { + return null + } + return versions.find { it.major == v.major && it.minor == v.minor - 1 && it.snapshot } } private Version getLastSnapshotWithMajor(int targetMajor) { @@ -112,6 +134,8 @@ class VersionCollection { } List getVersionsIndexCompatibleWithCurrent() { + // TODO this will yield 6.0.1-SNAPSHOT (etc.) on 6.x, and this will mean we're testing BWC vs 6.0.1-SNAPSHOT + // even after we're certain we're never going to release it. Does this need fixing? final def firstVersionOfCurrentMajor = versions.find { it.major >= currentVersion.major - 1 } return versionsOnOrAfterExceptCurrent(firstVersionOfCurrentMajor) } @@ -131,16 +155,7 @@ class VersionCollection { List getBasicIntegrationTestVersions() { // TODO these are the versions checked by `gradle check` for BWC tests. Their choice seems a litle arbitrary. - List result = [] - def v1 = BWCSnapshotForCurrentMajor - if (v1 != null) { // TODO remove null check. Should never be null? - result.add(v1) - if (v1.revision == 0) { - final def v2 = BWCSnapshotForPreviousMajor - result.add(v2) - } - } - - return Collections.unmodifiableList(result); + List result = [BWCSnapshotForPreviousMajor, BWCSnapshotForCurrentMajor] + return Collections.unmodifiableList(result.findAll { it != null }) } } diff --git a/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java b/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java index 8c7b849bb3d21..1e4792700d27c 100644 --- a/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java @@ -18,6 +18,12 @@ */ import com.carrotsearch.randomizedtesting.RandomizedTest; +import org.elasticsearch.gradle.VersionCollection; + +import java.util.Arrays; public class VersionCollectionTests extends RandomizedTest { + public void testFoo() { + new VersionCollection(Arrays.asList("public static final Version V_5_0_0_alpha2", "public static final Version V_5_0_0_alpha1")); + } } From 1c66e9ab530e8750575bdd0c6d4e4103cab3be4a Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 21 Nov 2017 16:43:56 +0000 Subject: [PATCH 09/23] Fail if versionCollection.BWCSnapshotForPreviousMinorOfCurrentMajor was required --- build.gradle | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index e8aac4d92c4cf..e0bc4d2b2adae 100644 --- a/build.gradle +++ b/build.gradle @@ -21,9 +21,10 @@ import org.apache.tools.ant.taskdefs.condition.Os import org.elasticsearch.gradle.BuildPlugin import org.elasticsearch.gradle.Version -import org.elasticsearch.gradle.VersionProperties import org.elasticsearch.gradle.VersionCollection +import org.elasticsearch.gradle.VersionProperties import org.gradle.plugins.ide.eclipse.model.SourceFolder +import sun.reflect.generics.reflectiveObjects.NotImplementedException import java.nio.file.Path @@ -117,7 +118,7 @@ task verifyVersions { Set knownVersions = new TreeSet<>(xml.versioning.versions.version.collect { it.text() }.findAll { it ==~ /\d\.\d\.\d/ }.collect { Version.fromString(it) }) // Limit the known versions to those that should be index compatible, and are not future versions - knownVersions = knownVersions.findAll { it.major >= versions.getCurrentVersion().major - 1 && it.before(VersionProperties.elasticsearch) } + knownVersions = knownVersions.findAll { it.major >= versions.currentVersion.major - 1 && it.before(VersionProperties.elasticsearch) } /* Limit the listed versions to those that have been marked as released. * Versions not marked as released don't get the same testing and we want @@ -206,14 +207,17 @@ subprojects { ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-stable-snapshot' ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-stable-snapshot' } - final def bwcReleaseSnapshot = versionCollection.BWCSnapshotForCurrentMajor + final def bwcReleaseSnapshot = versionCollection.BWCSnapshotForCurrentMajor if (bwcReleaseSnapshot != null) { ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${bwcReleaseSnapshot}"] = ':distribution:bwc-release-snapshot' ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${bwcReleaseSnapshot}"] = ':distribution:bwc-release-snapshot' ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${bwcReleaseSnapshot}"] = ':distribution:bwc-release-snapshot' } - // TODO there might be another one to test: if CURRENT == 6.2.0 and 6.1.0 is not released - // then we need to test against 6.1.0-SNAPSHOT, 6.0.max-SNAPSHOT and 5.6.max-SNAPSHOT + final def bwcPreviousReleaseSnapshot = versionCollection.BWCSnapshotForPreviousMinorOfCurrentMajor + if (bwcPreviousReleaseSnapshot != null) { + throw new NotImplementedException( + "A third BWC snapshot test (against ${bwcPreviousReleaseSnapshot}) is required but not yet implemented."); + } project.afterEvaluate { configurations.all { From ef0fa0ec79e26f0351550bfacf838f82e7d678cc Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 22 Nov 2017 14:43:46 +0000 Subject: [PATCH 10/23] Add tests of VersionCollection --- build.gradle | 4 + .../org/elasticsearch/gradle/Version.groovy | 27 ++++ .../gradle/VersionCollection.groovy | 21 +-- .../test/VersionCollectionTests.java | 140 +++++++++++++++++- 4 files changed, 175 insertions(+), 17 deletions(-) diff --git a/build.gradle b/build.gradle index e0bc4d2b2adae..eb016ec52794e 100644 --- a/build.gradle +++ b/build.gradle @@ -80,6 +80,10 @@ if (versionJava == null) { } VersionCollection versions = new VersionCollection(file(versionJava).readLines('UTF-8')) +if (versions.currentVersion.toString() != VersionProperties.elasticsearch) { + throw new GradleException("The last version in Versions.java [${versions.currentVersion}] does not match " + + "VersionProperties.elasticsearch [${VersionProperties.elasticsearch}]") +} // build metadata from previous build, contains eg hashes for bwc builds String buildMetadataValue = System.getenv('BUILD_METADATA') diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy index 63a1c86d098a9..5ec1726c64e4e 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy @@ -94,4 +94,31 @@ public class Version { return otherVersion.suffix == '' || suffix < otherVersion.suffix } + + boolean equals(o) { + if (this.is(o)) return true + if (getClass() != o.class) return false + + Version version = (Version) o + + if (id != version.id) return false + if (major != version.major) return false + if (minor != version.minor) return false + if (revision != version.revision) return false + if (snapshot != version.snapshot) return false + if (suffix != version.suffix) return false + + return true + } + + int hashCode() { + int result + result = major + result = 31 * result + minor + result = 31 * result + revision + result = 31 * result + id + result = 31 * result + (snapshot ? 1 : 0) + result = 31 * result + (suffix != null ? suffix.hashCode() : 0) + return result + } } diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy index 8f3ddc252cf8a..761b488898bde 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy @@ -55,6 +55,10 @@ class VersionCollection { } } + if (versions.empty) { + throw new GradleException("Unexpectedly found no version constants in Versions.java"); + } + // The tip of each minor series (>= 5.6) is unreleased, so set their 'snapshot' flags Version prevConsideredVersion = null for (final int versionIndex = versions.size() - 1; versionIndex >= 0; versionIndex--) { @@ -77,21 +81,10 @@ class VersionCollection { } this.versions = Collections.unmodifiableList(versions) + } - // TODO remove and replace with testing, once testing is possible - println "VersionCollection: ${versions}" - println "currentVersion: ${currentVersion}" - println "BWCSnapshotForCurrentMajor: ${BWCSnapshotForCurrentMajor}" - println "BWCSnapshotForPreviousMinorOfCurrentMajor: ${BWCSnapshotForPreviousMinorOfCurrentMajor}" - println "BWCSnapshotForPreviousMajor: ${BWCSnapshotForPreviousMajor}" - println "versionsIndexCompatibleWithCurrent: ${versionsIndexCompatibleWithCurrent}" - println "versionsWireCompatibleWithCurrent: ${versionsWireCompatibleWithCurrent}" - println "basicIntegrationTestVersions: ${basicIntegrationTestVersions}" - - if (getCurrentVersion().toString() != VersionProperties.elasticsearch) { - throw new GradleException("The last version in Versions.java [${versions[-1]}] does not match " + - "VersionProperties.elasticsearch [${VersionProperties.elasticsearch}]") - } + List getVersions() { + return Collections.unmodifiableList(versions); } Version getCurrentVersion() { diff --git a/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java b/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java index 1e4792700d27c..f6157501678c2 100644 --- a/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java @@ -18,12 +18,146 @@ */ import com.carrotsearch.randomizedtesting.RandomizedTest; +import org.elasticsearch.gradle.Version; import org.elasticsearch.gradle.VersionCollection; +import org.gradle.api.GradleException; +import org.junit.Test; -import java.util.Arrays; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; public class VersionCollectionTests extends RandomizedTest { - public void testFoo() { - new VersionCollection(Arrays.asList("public static final Version V_5_0_0_alpha2", "public static final Version V_5_0_0_alpha1")); + + private VersionCollection makeVersionCollection(String... constants) { + List sourceLines = new ArrayList<>(constants.length); + for (final String constant : constants) { + sourceLines.add(" public static final Version V_" + constant + " "); + } + return new VersionCollection(sourceLines); + } + + private void expectThrowsGradleException(String expectedMessage, Runnable r) { + try { + r.run(); + } catch (GradleException e) { + assertEquals("Exception message", expectedMessage, e.getMessage()); + return; + } + fail("Expected to throw [" + expectedMessage + "] but nothing was thrown."); + } + + @Test + public void testDetectsEmptyCollection() { + expectThrowsGradleException("Unexpectedly found no version constants in Versions.java", + () -> makeVersionCollection()); + } + + @Test + public void testDetectsOutOfOrderVersions() { + expectThrowsGradleException("Versions.java contains out of order version constants: 5.0.0 should come before 5.0.1", + () -> makeVersionCollection("5_0_1", "5_0_0")); + } + + @Test + public void testDetectsOutOfOrderSuffixes() { + expectThrowsGradleException("Versions.java contains out of order version constants: 5.0.0-alpha1 should come before 5.0.0-alpha2", + () -> makeVersionCollection("5_0_0_alpha2", "5_0_0_alpha1")); + } + + @Test + public void testDetectsSuffixedVersionAfterNon() { + expectThrowsGradleException("Versions.java contains out of order version constants: 5.0.0-alpha1 should come before 5.0.0", + () -> makeVersionCollection("5_0_0", "5_0_0_alpha1")); + } + + @Test + public void testDropsObsoletedSuffixedVersions() { + VersionCollection vc = makeVersionCollection("5_0_0_alpha1", "5_0_0_alpha2", "6_0_0_alpha1"); + assertArrayEquals(new Version[]{Version.fromString("5.0.0-alpha2-SNAPSHOT"), Version.fromString("6.0.0-alpha1-SNAPSHOT")}, + vc.getVersions().toArray()); + assertEquals(Version.fromString("6.0.0-alpha1-SNAPSHOT"), vc.getCurrentVersion()); + } + + @Test + public void testSnapshotVersionsAreLabelled() { + VersionCollection vc = makeVersionCollection("5_4_0", "5_4_1", "5_5_0", "5_5_1", "5_5_2", "5_6_0", "5_6_1", "5_6_2", "5_6_3", + "6_0_0", "6_0_1", "6_0_2", "6_1_0", "6_2_0", "7_0_0_alpha1"); + assertArrayEquals(new Version[]{ + Version.fromString("5.4.0"), Version.fromString("5.4.1"), Version.fromString("5.5.0"), Version.fromString("5.5.1"), + Version.fromString("5.5.2"), Version.fromString("5.6.0"), Version.fromString("5.6.1"), Version.fromString("5.6.2"), + Version.fromString("5.6.3-SNAPSHOT"), Version.fromString("6.0.0"), Version.fromString("6.0.1"), + Version.fromString("6.0.2-SNAPSHOT"), Version.fromString("6.1.0-SNAPSHOT"), Version.fromString("6.2.0-SNAPSHOT"), + Version.fromString("7.0.0-alpha1-SNAPSHOT")}, vc.getVersions().toArray()); + assertEquals(Version.fromString("7.0.0-alpha1-SNAPSHOT"), vc.getCurrentVersion()); + } + + @Test + public void testBWCSnapshotsOn6xBranchBeforeReleaseOf_6_1_0() { + VersionCollection vc = makeVersionCollection("5_6_3", "6_0_0", "6_0_1", "6_0_2", "6_1_0", "6_2_0"); + assertEquals(Version.fromString("6.1.0-SNAPSHOT"), vc.getBWCSnapshotForCurrentMajor()); + assertEquals(Version.fromString("6.0.2-SNAPSHOT"), vc.getBWCSnapshotForPreviousMinorOfCurrentMajor()); + assertEquals(Version.fromString("5.6.3-SNAPSHOT"), vc.getBWCSnapshotForPreviousMajor()); + assertArrayEquals(new Version[]{ + Version.fromString("5.6.3-SNAPSHOT"), Version.fromString("6.1.0-SNAPSHOT")}, vc.getBasicIntegrationTestVersions().toArray()); + } + + @Test + public void testBWCSnapshotsOn6xBranchAfterReleaseOf_6_1_0() { + VersionCollection vc = makeVersionCollection("5_6_3", "6_0_0", "6_0_1", "6_0_2", "6_1_0", "6_1_1", "6_2_0"); + assertEquals(Version.fromString("6.1.1-SNAPSHOT"), vc.getBWCSnapshotForCurrentMajor()); + assertNull(vc.getBWCSnapshotForPreviousMinorOfCurrentMajor()); + assertEquals(Version.fromString("5.6.3-SNAPSHOT"), vc.getBWCSnapshotForPreviousMajor()); + assertArrayEquals(new Version[]{ + Version.fromString("5.6.3-SNAPSHOT"), Version.fromString("6.1.1-SNAPSHOT")}, vc.getBasicIntegrationTestVersions().toArray()); + } + + @Test + public void testBWCSnapshotsOn7xBranchBeforeAnyReleases() { + VersionCollection vc = makeVersionCollection("5_6_3", "6_0_0", "6_0_1", "6_0_2", "6_1_0", "6_1_1", "6_2_0", "7_0_0_alpha1"); + assertNull(vc.getBWCSnapshotForCurrentMajor()); + assertNull(vc.getBWCSnapshotForPreviousMinorOfCurrentMajor()); + assertEquals(Version.fromString("6.2.0-SNAPSHOT"), vc.getBWCSnapshotForPreviousMajor()); + assertArrayEquals(new Version[]{Version.fromString("6.2.0-SNAPSHOT")}, vc.getBasicIntegrationTestVersions().toArray()); + } + + @Test + public void testCompatibleVersionsOn6xBranchBeforeReleaseOf_6_1_0() { + VersionCollection vc = makeVersionCollection("5_5_1", "5_6_0", "5_6_2", "5_6_3", "6_0_0", "6_0_1", "6_0_2", "6_1_0", "6_2_0"); + assertArrayEquals(new Version[]{ + Version.fromString("5.5.1"), Version.fromString("5.6.0"), Version.fromString("5.6.2"), + Version.fromString("5.6.3-SNAPSHOT"), + Version.fromString("6.0.0"), Version.fromString("6.0.1"), Version.fromString("6.0.2-SNAPSHOT"), + Version.fromString("6.1.0-SNAPSHOT")}, + vc.getVersionsIndexCompatibleWithCurrent().toArray()); + assertArrayEquals(new Version[]{Version.fromString("5.6.0"), Version.fromString("5.6.2"), Version.fromString("5.6.3-SNAPSHOT"), + Version.fromString("6.0.0"), Version.fromString("6.0.1"), Version.fromString("6.0.2-SNAPSHOT"), + Version.fromString("6.1.0-SNAPSHOT")}, vc.getVersionsWireCompatibleWithCurrent().toArray()); + } + + @Test + public void testCompatibleVersionsOn6xBranchAfterReleaseOf_6_1_0() { + VersionCollection vc = makeVersionCollection( + "5_5_1", "5_6_0", "5_6_2", "5_6_3", "6_0_0", "6_0_1", "6_0_2", "6_1_0", "6_1_1", "6_2_0"); + assertArrayEquals(new Version[]{ + Version.fromString("5.5.1"), Version.fromString("5.6.0"), Version.fromString("5.6.2"), + Version.fromString("5.6.3-SNAPSHOT"), + Version.fromString("6.0.0"), Version.fromString("6.0.1"), Version.fromString("6.0.2-SNAPSHOT"), + Version.fromString("6.1.0"), Version.fromString("6.1.1-SNAPSHOT")}, + vc.getVersionsIndexCompatibleWithCurrent().toArray()); + assertArrayEquals(new Version[]{Version.fromString("5.6.0"), Version.fromString("5.6.2"), Version.fromString("5.6.3-SNAPSHOT"), + Version.fromString("6.0.0"), Version.fromString("6.0.1"), Version.fromString("6.0.2-SNAPSHOT"), + Version.fromString("6.1.0"), Version.fromString("6.1.1-SNAPSHOT")}, vc.getVersionsWireCompatibleWithCurrent().toArray()); + } + + @Test + public void testCompatibleVersionsOn7xBranchBeforeAnyReleases() { + VersionCollection vc = makeVersionCollection("5_6_3", "6_0_0", "6_0_1", "6_0_2", "6_1_0", "6_1_1", "6_2_0", "7_0_0_alpha1"); + assertArrayEquals(new Version[]{ + Version.fromString("6.0.0"), Version.fromString("6.0.1"), + Version.fromString("6.0.2-SNAPSHOT"), Version.fromString("6.1.0"), Version.fromString("6.1.1-SNAPSHOT"), + Version.fromString("6.2.0-SNAPSHOT")}, vc.getVersionsIndexCompatibleWithCurrent().toArray()); + assertArrayEquals(new Version[]{Version.fromString("6.2.0-SNAPSHOT")}, vc.getVersionsWireCompatibleWithCurrent().toArray()); } } From 9e1dc828e3a98af88be1833da05af3503dff2797 Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 22 Nov 2017 15:07:23 +0000 Subject: [PATCH 11/23] Expand import * --- .../java/org/elasticsearch/test/VersionCollectionTests.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java b/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java index f6157501678c2..ec0d5d01353fa 100644 --- a/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java @@ -26,7 +26,10 @@ import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.*; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; public class VersionCollectionTests extends RandomizedTest { From e5919193e72e8586e5325412fa776637491ecde4 Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 22 Nov 2017 15:35:41 +0000 Subject: [PATCH 12/23] Get rid of tests for VersionCollection --- buildSrc/build.gradle | 11 +- .../test/VersionCollectionTests.java | 166 ------------------ 2 files changed, 3 insertions(+), 174 deletions(-) delete mode 100644 buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 1083a59690b03..7c6f3002f708f 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -121,7 +121,6 @@ if (project == rootProject) { } mavenCentral() } - compileTestJava.enabled = false test.exclude 'org/elasticsearch/test/NamingConventionsCheckBadClasses*' } @@ -147,11 +146,7 @@ if (project != rootProject) { thirdPartyAudit.enabled = false // test for elasticsearch.build tries to run with ES... - dependencies { - testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" - testCompile "junit:junit:${versions.junit}" - testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}" - } + test.enabled = false // TODO: re-enable once randomizedtesting gradle code is published and removed from here licenseHeaders.enabled = false @@ -163,13 +158,13 @@ if (project != rootProject) { } namingConventions { - testClass = 'com.carrotsearch.randomizedtesting.RandomizedTest' + testClass = 'org.elasticsearch.test.NamingConventionsCheckBadClasses$UnitTestCase' integTestClass = 'org.elasticsearch.test.NamingConventionsCheckBadClasses$IntegTestCase' } task namingConventionsMain(type: org.elasticsearch.gradle.precommit.NamingConventionsTask) { checkForTestsInMain = true - testClass = 'org.elasticsearch.test.NamingConventionsCheckBadClasses$UnitTestCase' + testClass = namingConventions.testClass integTestClass = namingConventions.integTestClass } precommit.dependsOn namingConventionsMain diff --git a/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java b/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java deleted file mode 100644 index ec0d5d01353fa..0000000000000 --- a/buildSrc/src/test/java/org/elasticsearch/test/VersionCollectionTests.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.elasticsearch.test;/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import com.carrotsearch.randomizedtesting.RandomizedTest; -import org.elasticsearch.gradle.Version; -import org.elasticsearch.gradle.VersionCollection; -import org.gradle.api.GradleException; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - -public class VersionCollectionTests extends RandomizedTest { - - private VersionCollection makeVersionCollection(String... constants) { - List sourceLines = new ArrayList<>(constants.length); - for (final String constant : constants) { - sourceLines.add(" public static final Version V_" + constant + " "); - } - return new VersionCollection(sourceLines); - } - - private void expectThrowsGradleException(String expectedMessage, Runnable r) { - try { - r.run(); - } catch (GradleException e) { - assertEquals("Exception message", expectedMessage, e.getMessage()); - return; - } - fail("Expected to throw [" + expectedMessage + "] but nothing was thrown."); - } - - @Test - public void testDetectsEmptyCollection() { - expectThrowsGradleException("Unexpectedly found no version constants in Versions.java", - () -> makeVersionCollection()); - } - - @Test - public void testDetectsOutOfOrderVersions() { - expectThrowsGradleException("Versions.java contains out of order version constants: 5.0.0 should come before 5.0.1", - () -> makeVersionCollection("5_0_1", "5_0_0")); - } - - @Test - public void testDetectsOutOfOrderSuffixes() { - expectThrowsGradleException("Versions.java contains out of order version constants: 5.0.0-alpha1 should come before 5.0.0-alpha2", - () -> makeVersionCollection("5_0_0_alpha2", "5_0_0_alpha1")); - } - - @Test - public void testDetectsSuffixedVersionAfterNon() { - expectThrowsGradleException("Versions.java contains out of order version constants: 5.0.0-alpha1 should come before 5.0.0", - () -> makeVersionCollection("5_0_0", "5_0_0_alpha1")); - } - - @Test - public void testDropsObsoletedSuffixedVersions() { - VersionCollection vc = makeVersionCollection("5_0_0_alpha1", "5_0_0_alpha2", "6_0_0_alpha1"); - assertArrayEquals(new Version[]{Version.fromString("5.0.0-alpha2-SNAPSHOT"), Version.fromString("6.0.0-alpha1-SNAPSHOT")}, - vc.getVersions().toArray()); - assertEquals(Version.fromString("6.0.0-alpha1-SNAPSHOT"), vc.getCurrentVersion()); - } - - @Test - public void testSnapshotVersionsAreLabelled() { - VersionCollection vc = makeVersionCollection("5_4_0", "5_4_1", "5_5_0", "5_5_1", "5_5_2", "5_6_0", "5_6_1", "5_6_2", "5_6_3", - "6_0_0", "6_0_1", "6_0_2", "6_1_0", "6_2_0", "7_0_0_alpha1"); - assertArrayEquals(new Version[]{ - Version.fromString("5.4.0"), Version.fromString("5.4.1"), Version.fromString("5.5.0"), Version.fromString("5.5.1"), - Version.fromString("5.5.2"), Version.fromString("5.6.0"), Version.fromString("5.6.1"), Version.fromString("5.6.2"), - Version.fromString("5.6.3-SNAPSHOT"), Version.fromString("6.0.0"), Version.fromString("6.0.1"), - Version.fromString("6.0.2-SNAPSHOT"), Version.fromString("6.1.0-SNAPSHOT"), Version.fromString("6.2.0-SNAPSHOT"), - Version.fromString("7.0.0-alpha1-SNAPSHOT")}, vc.getVersions().toArray()); - assertEquals(Version.fromString("7.0.0-alpha1-SNAPSHOT"), vc.getCurrentVersion()); - } - - @Test - public void testBWCSnapshotsOn6xBranchBeforeReleaseOf_6_1_0() { - VersionCollection vc = makeVersionCollection("5_6_3", "6_0_0", "6_0_1", "6_0_2", "6_1_0", "6_2_0"); - assertEquals(Version.fromString("6.1.0-SNAPSHOT"), vc.getBWCSnapshotForCurrentMajor()); - assertEquals(Version.fromString("6.0.2-SNAPSHOT"), vc.getBWCSnapshotForPreviousMinorOfCurrentMajor()); - assertEquals(Version.fromString("5.6.3-SNAPSHOT"), vc.getBWCSnapshotForPreviousMajor()); - assertArrayEquals(new Version[]{ - Version.fromString("5.6.3-SNAPSHOT"), Version.fromString("6.1.0-SNAPSHOT")}, vc.getBasicIntegrationTestVersions().toArray()); - } - - @Test - public void testBWCSnapshotsOn6xBranchAfterReleaseOf_6_1_0() { - VersionCollection vc = makeVersionCollection("5_6_3", "6_0_0", "6_0_1", "6_0_2", "6_1_0", "6_1_1", "6_2_0"); - assertEquals(Version.fromString("6.1.1-SNAPSHOT"), vc.getBWCSnapshotForCurrentMajor()); - assertNull(vc.getBWCSnapshotForPreviousMinorOfCurrentMajor()); - assertEquals(Version.fromString("5.6.3-SNAPSHOT"), vc.getBWCSnapshotForPreviousMajor()); - assertArrayEquals(new Version[]{ - Version.fromString("5.6.3-SNAPSHOT"), Version.fromString("6.1.1-SNAPSHOT")}, vc.getBasicIntegrationTestVersions().toArray()); - } - - @Test - public void testBWCSnapshotsOn7xBranchBeforeAnyReleases() { - VersionCollection vc = makeVersionCollection("5_6_3", "6_0_0", "6_0_1", "6_0_2", "6_1_0", "6_1_1", "6_2_0", "7_0_0_alpha1"); - assertNull(vc.getBWCSnapshotForCurrentMajor()); - assertNull(vc.getBWCSnapshotForPreviousMinorOfCurrentMajor()); - assertEquals(Version.fromString("6.2.0-SNAPSHOT"), vc.getBWCSnapshotForPreviousMajor()); - assertArrayEquals(new Version[]{Version.fromString("6.2.0-SNAPSHOT")}, vc.getBasicIntegrationTestVersions().toArray()); - } - - @Test - public void testCompatibleVersionsOn6xBranchBeforeReleaseOf_6_1_0() { - VersionCollection vc = makeVersionCollection("5_5_1", "5_6_0", "5_6_2", "5_6_3", "6_0_0", "6_0_1", "6_0_2", "6_1_0", "6_2_0"); - assertArrayEquals(new Version[]{ - Version.fromString("5.5.1"), Version.fromString("5.6.0"), Version.fromString("5.6.2"), - Version.fromString("5.6.3-SNAPSHOT"), - Version.fromString("6.0.0"), Version.fromString("6.0.1"), Version.fromString("6.0.2-SNAPSHOT"), - Version.fromString("6.1.0-SNAPSHOT")}, - vc.getVersionsIndexCompatibleWithCurrent().toArray()); - assertArrayEquals(new Version[]{Version.fromString("5.6.0"), Version.fromString("5.6.2"), Version.fromString("5.6.3-SNAPSHOT"), - Version.fromString("6.0.0"), Version.fromString("6.0.1"), Version.fromString("6.0.2-SNAPSHOT"), - Version.fromString("6.1.0-SNAPSHOT")}, vc.getVersionsWireCompatibleWithCurrent().toArray()); - } - - @Test - public void testCompatibleVersionsOn6xBranchAfterReleaseOf_6_1_0() { - VersionCollection vc = makeVersionCollection( - "5_5_1", "5_6_0", "5_6_2", "5_6_3", "6_0_0", "6_0_1", "6_0_2", "6_1_0", "6_1_1", "6_2_0"); - assertArrayEquals(new Version[]{ - Version.fromString("5.5.1"), Version.fromString("5.6.0"), Version.fromString("5.6.2"), - Version.fromString("5.6.3-SNAPSHOT"), - Version.fromString("6.0.0"), Version.fromString("6.0.1"), Version.fromString("6.0.2-SNAPSHOT"), - Version.fromString("6.1.0"), Version.fromString("6.1.1-SNAPSHOT")}, - vc.getVersionsIndexCompatibleWithCurrent().toArray()); - assertArrayEquals(new Version[]{Version.fromString("5.6.0"), Version.fromString("5.6.2"), Version.fromString("5.6.3-SNAPSHOT"), - Version.fromString("6.0.0"), Version.fromString("6.0.1"), Version.fromString("6.0.2-SNAPSHOT"), - Version.fromString("6.1.0"), Version.fromString("6.1.1-SNAPSHOT")}, vc.getVersionsWireCompatibleWithCurrent().toArray()); - } - - @Test - public void testCompatibleVersionsOn7xBranchBeforeAnyReleases() { - VersionCollection vc = makeVersionCollection("5_6_3", "6_0_0", "6_0_1", "6_0_2", "6_1_0", "6_1_1", "6_2_0", "7_0_0_alpha1"); - assertArrayEquals(new Version[]{ - Version.fromString("6.0.0"), Version.fromString("6.0.1"), - Version.fromString("6.0.2-SNAPSHOT"), Version.fromString("6.1.0"), Version.fromString("6.1.1-SNAPSHOT"), - Version.fromString("6.2.0-SNAPSHOT")}, vc.getVersionsIndexCompatibleWithCurrent().toArray()); - assertArrayEquals(new Version[]{Version.fromString("6.2.0-SNAPSHOT")}, vc.getVersionsWireCompatibleWithCurrent().toArray()); - } -} From f93e7bc6f87ea474380ffbd32dfc7af4c72705a9 Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 22 Nov 2017 16:51:06 +0000 Subject: [PATCH 13/23] Resolve TODO: only check out the known snapshots --- .../org/elasticsearch/gradle/VersionCollection.groovy | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy index 761b488898bde..30b32720631b3 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy @@ -120,15 +120,17 @@ class VersionCollection { } private List versionsOnOrAfterExceptCurrent(Version minVersion) { - final def minVersionString = minVersion.toString(); + final def minVersionString = minVersion.toString() + final def snapshot1 = BWCSnapshotForCurrentMajor + final def snapshot2 = BWCSnapshotForPreviousMinorOfCurrentMajor + final def snapshot3 = BWCSnapshotForPreviousMajor return Collections.unmodifiableList(versions.findAll { - it.onOrAfter(minVersionString) && it != currentVersion + it.onOrAfter(minVersionString) && it != currentVersion && + (false == it.snapshot || it == snapshot1 || it == snapshot2 || it == snapshot3) }) } List getVersionsIndexCompatibleWithCurrent() { - // TODO this will yield 6.0.1-SNAPSHOT (etc.) on 6.x, and this will mean we're testing BWC vs 6.0.1-SNAPSHOT - // even after we're certain we're never going to release it. Does this need fixing? final def firstVersionOfCurrentMajor = versions.find { it.major >= currentVersion.major - 1 } return versionsOnOrAfterExceptCurrent(firstVersionOfCurrentMajor) } From 05c69562382dc2c4aa559d5c9d6eb78dd6f3f52c Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 22 Nov 2017 16:58:31 +0000 Subject: [PATCH 14/23] Add comments --- .../gradle/VersionCollection.groovy | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy index 30b32720631b3..6689227b47fde 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy @@ -30,6 +30,10 @@ class VersionCollection { private final List versions + /** + * Construct a VersionCollection from the lines of the Version.java file. + * @param versionLines The lines of the Version.java file. + */ VersionCollection(List versionLines) { List versions = [] @@ -83,24 +87,40 @@ class VersionCollection { this.versions = Collections.unmodifiableList(versions) } + /** + * @return The list of versions read from the Version.java file + */ List getVersions() { return Collections.unmodifiableList(versions); } + /** + * @return The latest version in the Version.java file, which must be the current version of the system. + */ Version getCurrentVersion() { return versions[-1] } + /** + * @return The snapshot at the end of the previous minor series in the current major series, or null if this is the first minor series. + */ Version getBWCSnapshotForCurrentMajor() { return getLastSnapshotWithMajor(currentVersion.major) } + /** + * @return The snapshot at the end of the previous major series, which must not be null. + */ Version getBWCSnapshotForPreviousMajor() { def version = getLastSnapshotWithMajor(currentVersion.major - 1) assert version != null : "getBWCSnapshotForPreviousMajor(): found no versions in the previous major" return version } + /** + * @return The snapshot at the end of the previous-but-one minor series in the current major series, if the previous minor series + * exists and has not yet been released. Otherwise null. + */ Version getBWCSnapshotForPreviousMinorOfCurrentMajor() { // If we are at 6.2.0 but 6.1.0 has not yet been released then we // need to test against 6.0.1-SNAPSHOT too @@ -130,6 +150,9 @@ class VersionCollection { }) } + /** + * @return All earlier versions that should be tested for index BWC with the current version. + */ List getVersionsIndexCompatibleWithCurrent() { final def firstVersionOfCurrentMajor = versions.find { it.major >= currentVersion.major - 1 } return versionsOnOrAfterExceptCurrent(firstVersionOfCurrentMajor) @@ -144,10 +167,17 @@ class VersionCollection { return versions.find { it.major == lastVersionOfEarlierMajor.major && it.minor == lastVersionOfEarlierMajor.minor } } + /** + * @return All earlier versions that should be tested for wire BWC with the current version. + */ List getVersionsWireCompatibleWithCurrent() { return versionsOnOrAfterExceptCurrent(minimumWireCompatibilityVersion) } + /** + * `gradle check` does not run all BWC tests. This defines which tests it does run. + * @return Versions to test for BWC during gradle check. + */ List getBasicIntegrationTestVersions() { // TODO these are the versions checked by `gradle check` for BWC tests. Their choice seems a litle arbitrary. List result = [BWCSnapshotForPreviousMajor, BWCSnapshotForCurrentMajor] From ee1ce49a0e5ec1a7151ad7b5599fb82b8cc14271 Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 22 Nov 2017 17:09:29 +0000 Subject: [PATCH 15/23] Explicit types --- build.gradle | 13 ++++-------- .../gradle/VersionCollection.groovy | 20 +++++++++---------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/build.gradle b/build.gradle index dd8bd25cdd97a..f31f6684f0557 100644 --- a/build.gradle +++ b/build.gradle @@ -74,12 +74,7 @@ configure(subprojects.findAll { it.projectDir.toPath().startsWith(rootPath) }) { * backwards compatibility guarantees and only keeping the latest beta or rc * in a branch if there are only betas and rcs in the branch so we have * *something* to test against. */ -def versionJava = System.getProperty("path.to.version.java") // TODO get rid of this and replace with proper testing, once testing is possible -if (versionJava == null) { - versionJava = 'core/src/main/java/org/elasticsearch/Version.java' -} - -VersionCollection versions = new VersionCollection(file(versionJava).readLines('UTF-8')) +VersionCollection versions = new VersionCollection(file('core/src/main/java/org/elasticsearch/Version.java').readLines('UTF-8')) if (versions.currentVersion.toString() != VersionProperties.elasticsearch) { throw new GradleException("The last version in Versions.java [${versions.currentVersion}] does not match " + "VersionProperties.elasticsearch [${VersionProperties.elasticsearch}]") @@ -204,19 +199,19 @@ subprojects { "org.elasticsearch.plugin:percolator-client:${version}": ':modules:percolator', ] - final def bwcStableSnapshot = versionCollection.BWCSnapshotForPreviousMajor + final Version bwcStableSnapshot = versionCollection.BWCSnapshotForPreviousMajor if (bwcStableSnapshot != null) { ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-stable-snapshot' ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-stable-snapshot' ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-stable-snapshot' } - final def bwcReleaseSnapshot = versionCollection.BWCSnapshotForCurrentMajor + final Version bwcReleaseSnapshot = versionCollection.BWCSnapshotForCurrentMajor if (bwcReleaseSnapshot != null) { ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${bwcReleaseSnapshot}"] = ':distribution:bwc-release-snapshot' ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${bwcReleaseSnapshot}"] = ':distribution:bwc-release-snapshot' ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${bwcReleaseSnapshot}"] = ':distribution:bwc-release-snapshot' } - final def bwcPreviousReleaseSnapshot = versionCollection.BWCSnapshotForPreviousMinorOfCurrentMajor + final Version bwcPreviousReleaseSnapshot = versionCollection.BWCSnapshotForPreviousMinorOfCurrentMajor if (bwcPreviousReleaseSnapshot != null) { throw new NotImplementedException( "A third BWC snapshot test (against ${bwcPreviousReleaseSnapshot}) is required but not yet implemented."); diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy index 6689227b47fde..a8b6a2e91bf12 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy @@ -112,7 +112,7 @@ class VersionCollection { * @return The snapshot at the end of the previous major series, which must not be null. */ Version getBWCSnapshotForPreviousMajor() { - def version = getLastSnapshotWithMajor(currentVersion.major - 1) + Version version = getLastSnapshotWithMajor(currentVersion.major - 1) assert version != null : "getBWCSnapshotForPreviousMajor(): found no versions in the previous major" return version } @@ -124,7 +124,7 @@ class VersionCollection { Version getBWCSnapshotForPreviousMinorOfCurrentMajor() { // If we are at 6.2.0 but 6.1.0 has not yet been released then we // need to test against 6.0.1-SNAPSHOT too - final def v = BWCSnapshotForCurrentMajor + final Version v = BWCSnapshotForCurrentMajor if (v == null || v.revision != 0 || v.minor == 0) { return null } @@ -132,7 +132,7 @@ class VersionCollection { } private Version getLastSnapshotWithMajor(int targetMajor) { - final def currentVersion = currentVersion.toString() + final String currentVersion = currentVersion.toString() final int snapshotIndex = versions.findLastIndexOf { it.major == targetMajor && it.before(currentVersion) && it.snapshot } @@ -140,10 +140,10 @@ class VersionCollection { } private List versionsOnOrAfterExceptCurrent(Version minVersion) { - final def minVersionString = minVersion.toString() - final def snapshot1 = BWCSnapshotForCurrentMajor - final def snapshot2 = BWCSnapshotForPreviousMinorOfCurrentMajor - final def snapshot3 = BWCSnapshotForPreviousMajor + final String minVersionString = minVersion.toString() + final Version snapshot1 = BWCSnapshotForCurrentMajor + final Version snapshot2 = BWCSnapshotForPreviousMinorOfCurrentMajor + final Version snapshot3 = BWCSnapshotForPreviousMajor return Collections.unmodifiableList(versions.findAll { it.onOrAfter(minVersionString) && it != currentVersion && (false == it.snapshot || it == snapshot1 || it == snapshot2 || it == snapshot3) @@ -154,16 +154,16 @@ class VersionCollection { * @return All earlier versions that should be tested for index BWC with the current version. */ List getVersionsIndexCompatibleWithCurrent() { - final def firstVersionOfCurrentMajor = versions.find { it.major >= currentVersion.major - 1 } + final Version firstVersionOfCurrentMajor = versions.find { it.major >= currentVersion.major - 1 } return versionsOnOrAfterExceptCurrent(firstVersionOfCurrentMajor) } private Version getMinimumWireCompatibilityVersion() { - final def firstIndexOfThisMajor = versions.findIndexOf { it.major == currentVersion.major } + final int firstIndexOfThisMajor = versions.findIndexOf { it.major == currentVersion.major } if (firstIndexOfThisMajor == 0) { return versions[0] } - final def lastVersionOfEarlierMajor = versions[firstIndexOfThisMajor - 1] + final Version lastVersionOfEarlierMajor = versions[firstIndexOfThisMajor - 1] return versions.find { it.major == lastVersionOfEarlierMajor.major && it.minor == lastVersionOfEarlierMajor.minor } } From 3fac5d76971abf308a8cb4e3b859f5c2adc38e69 Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 22 Nov 2017 17:13:23 +0000 Subject: [PATCH 16/23] Stop failing on versionCollection.BWCSnapshotForPreviousMinorOfCurrentMajor not yet being a project --- build.gradle | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index f31f6684f0557..60e2477c1c303 100644 --- a/build.gradle +++ b/build.gradle @@ -211,11 +211,12 @@ subprojects { ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${bwcReleaseSnapshot}"] = ':distribution:bwc-release-snapshot' ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${bwcReleaseSnapshot}"] = ':distribution:bwc-release-snapshot' } - final Version bwcPreviousReleaseSnapshot = versionCollection.BWCSnapshotForPreviousMinorOfCurrentMajor - if (bwcPreviousReleaseSnapshot != null) { - throw new NotImplementedException( - "A third BWC snapshot test (against ${bwcPreviousReleaseSnapshot}) is required but not yet implemented."); - } + /* TODO Add the third BWC snapshot build (against ${bwcPreviousReleaseSnapshot}): + final Version bwcPreviousReleaseSnapshot = versionCollection.BWCSnapshotForPreviousMinorOfCurrentMajor + if (bwcPreviousReleaseSnapshot != null) { + } + Without this, the full BWC builds will not work + */ project.afterEvaluate { configurations.all { From 353465b1dbacddcb99fac7dc948ef5a11aefae63 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 23 Nov 2017 08:45:37 +0000 Subject: [PATCH 17/23] Added one project for each historical branch for BWC testing --- build.gradle | 7 ++++--- distribution/bwc/build.gradle | 20 +++++++------------- settings.gradle | 19 +++++++++++-------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/build.gradle b/build.gradle index 60e2477c1c303..20ee3beb73442 100644 --- a/build.gradle +++ b/build.gradle @@ -201,9 +201,10 @@ subprojects { final Version bwcStableSnapshot = versionCollection.BWCSnapshotForPreviousMajor if (bwcStableSnapshot != null) { - ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-stable-snapshot' - ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-stable-snapshot' - ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-stable-snapshot' + project(':distribution:bwc-snapshot-6.x').ext.bwcVersion = bwcStableSnapshot + ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-snapshot-6.x' + ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-snapshot-6.x' + ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-snapshot-6.x' } final Version bwcReleaseSnapshot = versionCollection.BWCSnapshotForCurrentMajor if (bwcReleaseSnapshot != null) { diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index 1110b1ba832d6..ed5f32c7bf9f3 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -20,6 +20,7 @@ import org.elasticsearch.gradle.LoggedExec import org.elasticsearch.gradle.Version +import java.util.regex.Matcher /** * This is a dummy project which does a local checkout of the previous @@ -27,27 +28,20 @@ import org.elasticsearch.gradle.Version * tests to test against the next unreleased version, closest to this version, * without relying on snapshots. */ -Version bwcVersion -if (project.name == 'bwc-stable-snapshot') { - bwcVersion = versionCollection.BWCSnapshotForPreviousMajor -} else if (project.name == 'bwc-release-snapshot') { - bwcVersion = versionCollection.BWCSnapshotForCurrentMajor -} else { +final Matcher match = project.name =~ /bwc-snapshot-(\d+\.(\d+|x))/ +if (!match.matches()) { throw new InvalidUserDataException("Unsupport project name ${project.name}") } +String bwcBranch = match.group(1) + +if (project.hasProperty('ext.bwcVersion')) { + Version bwcVersion = project.ext.bwcVersion -if (bwcVersion != null) { apply plugin: 'distribution' // Not published so no need to assemble tasks.remove(assemble) build.dependsOn.remove('assemble') - String bwcBranch - if (project.name == 'bwc-stable-snapshot' && bwcVersion.major != versionCollection.currentVersion.major) { - bwcBranch = "${bwcVersion.major}.x" - } else { - bwcBranch = "${bwcVersion.major}.${bwcVersion.minor}" - } File checkoutDir = file("${buildDir}/bwc/checkout-${bwcBranch}") final String remote = System.getProperty("tests.bwc.remote", "elastic") diff --git a/settings.gradle b/settings.gradle index 997f3b30da5fe..b9696b2fc13cd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -16,8 +16,6 @@ List projects = [ 'client:benchmark', 'benchmarks', 'distribution:integ-test-zip', - 'distribution:bwc-release-snapshot', - 'distribution:bwc-stable-snapshot', 'distribution:zip', 'distribution:tar', 'distribution:deb', @@ -97,6 +95,12 @@ for (File example : examplePluginsDir.listFiles()) { examplePlugins.add(example.name) } +/* Create projects for building BWC snapshot distributions from the heads of other branches */ +final List branches = ['5.6', '6.0', '6.1', '6.x'] +for (final String branch : branches) { + projects.add("distribution:bwc-snapshot-${branch}".toString()) +} + boolean isEclipse = System.getProperty("eclipse.launcher") != null || gradle.startParameter.taskNames.contains('eclipse') || gradle.startParameter.taskNames.contains('cleanEclipse') if (isEclipse) { // eclipse cannot handle an intermediate dependency between main and test, so we must create separate projects @@ -113,12 +117,11 @@ for (String example : examplePlugins) { project(":example-plugins:${example}").projectDir = new File(rootProject.projectDir, "plugins/examples/${example}") } -/* bwc and bwc-unreleased share the same build directory and build file, but - * apply to different backwards compatibility branches. */ -project(':distribution:bwc-release-snapshot').projectDir = - new File(rootProject.projectDir, 'distribution/bwc') -project(':distribution:bwc-stable-snapshot').projectDir = - new File(rootProject.projectDir, 'distribution/bwc') +/* The BWC snapshot projects share the same build directory and build file, + * but apply to different backwards compatibility branches. */ +for (final String branch : branches) { + project(":distribution:bwc-snapshot-${branch}").projectDir = new File(rootProject.projectDir, 'distribution/bwc') +} if (isEclipse) { project(":core").projectDir = new File(rootProject.projectDir, 'core/src/main') From e9e591524b34b8c5aaaff89c920e78b9ad2e9a89 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 23 Nov 2017 09:21:36 +0000 Subject: [PATCH 18/23] Create bwc-snapshot projects for all branches --- build.gradle | 22 ++++-------------- .../org/elasticsearch/gradle/Version.groovy | 6 +++-- .../gradle/VersionCollection.groovy | 23 ++++++++++++------- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/build.gradle b/build.gradle index 20ee3beb73442..c3722a8dfcb0f 100644 --- a/build.gradle +++ b/build.gradle @@ -199,25 +199,11 @@ subprojects { "org.elasticsearch.plugin:percolator-client:${version}": ':modules:percolator', ] - final Version bwcStableSnapshot = versionCollection.BWCSnapshotForPreviousMajor - if (bwcStableSnapshot != null) { - project(':distribution:bwc-snapshot-6.x').ext.bwcVersion = bwcStableSnapshot - ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-snapshot-6.x' - ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-snapshot-6.x' - ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${bwcStableSnapshot}"] = ':distribution:bwc-snapshot-6.x' - } - final Version bwcReleaseSnapshot = versionCollection.BWCSnapshotForCurrentMajor - if (bwcReleaseSnapshot != null) { - ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${bwcReleaseSnapshot}"] = ':distribution:bwc-release-snapshot' - ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${bwcReleaseSnapshot}"] = ':distribution:bwc-release-snapshot' - ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${bwcReleaseSnapshot}"] = ':distribution:bwc-release-snapshot' - } - /* TODO Add the third BWC snapshot build (against ${bwcPreviousReleaseSnapshot}): - final Version bwcPreviousReleaseSnapshot = versionCollection.BWCSnapshotForPreviousMinorOfCurrentMajor - if (bwcPreviousReleaseSnapshot != null) { + for (final Version version : versionCollection.versionsIndexCompatibleWithCurrent) { + if (version.branch != null) { + project(":distribution:bwc-snapshot-${version.branch}").ext.bwcVersion = version } - Without this, the full BWC builds will not work - */ + } project.afterEvaluate { configurations.all { diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy index 5ec1726c64e4e..7dbd943b62d6a 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy @@ -34,6 +34,7 @@ public class Version { final int revision final int id final boolean snapshot + final String branch /** * Suffix on the version name. Unlike Version.java the build does not * consider alphas and betas different versions, it just preserves the @@ -42,12 +43,13 @@ public class Version { final String suffix public Version(int major, int minor, int revision, - String suffix, boolean snapshot) { + String suffix, boolean snapshot, String branch) { this.major = major this.minor = minor this.revision = revision this.snapshot = snapshot this.suffix = suffix + this.branch = branch this.id = major * 100000 + minor * 1000 + revision * 10 + (snapshot ? 1 : 0) } @@ -58,7 +60,7 @@ public class Version { throw new InvalidUserDataException("Invalid version [${s}]") } return new Version(m.group(1) as int, m.group(2) as int, - m.group(3) as int, m.group(4) ?: '', m.group(5) != null) + m.group(3) as int, m.group(4) ?: '', m.group(5) != null, null) } @Override diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy index a8b6a2e91bf12..7ba0dc19e4999 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy @@ -43,7 +43,7 @@ class VersionCollection { if (match.matches()) { final Version foundVersion = new Version( Integer.parseInt(match.group(1)), Integer.parseInt(match.group(2)), - Integer.parseInt(match.group(3)), (match.group(4) ?: '').replace('_', '-'), false) + Integer.parseInt(match.group(3)), (match.group(4) ?: '').replace('_', '-'), false, null) if (versions.size() > 0 && foundVersion.onOrBeforeIncludingSuffix(versions[-1])) { throw new GradleException("Versions.java contains out of order version constants:" + @@ -65,6 +65,7 @@ class VersionCollection { // The tip of each minor series (>= 5.6) is unreleased, so set their 'snapshot' flags Version prevConsideredVersion = null + boolean found6xSnapshot = false for (final int versionIndex = versions.size() - 1; versionIndex >= 0; versionIndex--) { final Version currConsideredVersion = versions[versionIndex] @@ -72,9 +73,19 @@ class VersionCollection { || currConsideredVersion.major != prevConsideredVersion.major || currConsideredVersion.minor != prevConsideredVersion.minor) { + // This is a snapshot version. Work out its branch. NB this doesn't name the current branch correctly, but this doesn't + // matter as we don't BWC test against it. + String branch = "${currConsideredVersion.major}.${currConsideredVersion.minor}" + + if (false == found6xSnapshot && currConsideredVersion.major == 6) { + // TODO needs generalising to deal with when 7.x is cut, and when 6.x is deleted, and so on... + branch = "6.x" + found6xSnapshot = true + } + versions[versionIndex] = new Version( currConsideredVersion.major, currConsideredVersion.minor, - currConsideredVersion.revision, currConsideredVersion.suffix, true) + currConsideredVersion.revision, currConsideredVersion.suffix, true, branch) } if (currConsideredVersion.onOrBefore("5.6.0")) { @@ -91,7 +102,7 @@ class VersionCollection { * @return The list of versions read from the Version.java file */ List getVersions() { - return Collections.unmodifiableList(versions); + return Collections.unmodifiableList(versions) } /** @@ -141,12 +152,8 @@ class VersionCollection { private List versionsOnOrAfterExceptCurrent(Version minVersion) { final String minVersionString = minVersion.toString() - final Version snapshot1 = BWCSnapshotForCurrentMajor - final Version snapshot2 = BWCSnapshotForPreviousMinorOfCurrentMajor - final Version snapshot3 = BWCSnapshotForPreviousMajor return Collections.unmodifiableList(versions.findAll { - it.onOrAfter(minVersionString) && it != currentVersion && - (false == it.snapshot || it == snapshot1 || it == snapshot2 || it == snapshot3) + it.onOrAfter(minVersionString) && it != currentVersion }) } From ee7de8fbf6db070e05fc8f458253e1b6796eafec Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 23 Nov 2017 09:25:39 +0000 Subject: [PATCH 19/23] Also need to set up the project substitutions, oops --- build.gradle | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index c3722a8dfcb0f..67d4b993cd478 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,6 @@ import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.VersionCollection import org.elasticsearch.gradle.VersionProperties import org.gradle.plugins.ide.eclipse.model.SourceFolder -import sun.reflect.generics.reflectiveObjects.NotImplementedException import java.nio.file.Path @@ -201,7 +200,11 @@ subprojects { for (final Version version : versionCollection.versionsIndexCompatibleWithCurrent) { if (version.branch != null) { - project(":distribution:bwc-snapshot-${version.branch}").ext.bwcVersion = version + String snapshotProject = ":distribution:bwc-snapshot-${version.branch}" + project(snapshotProject).ext.bwcVersion = version + ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${version}"] = snapshotProject + ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${version}"] = snapshotProject + ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${version}"] = snapshotProject } } From 807592b7c248604a621a44e607338df97ab0610e Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 23 Nov 2017 09:31:08 +0000 Subject: [PATCH 20/23] Apparently you need to omit the "ext." qualifier here --- distribution/bwc/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index ed5f32c7bf9f3..49d320ef67672 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -34,7 +34,7 @@ if (!match.matches()) { } String bwcBranch = match.group(1) -if (project.hasProperty('ext.bwcVersion')) { +if (project.hasProperty('bwcVersion')) { Version bwcVersion = project.ext.bwcVersion apply plugin: 'distribution' From d439370ab44cfaccf7711d042740b39bd7527391 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 23 Nov 2017 10:20:45 +0000 Subject: [PATCH 21/23] Create dummy projects for each branch within each plugin too --- build.gradle | 2 +- settings.gradle | 28 ++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 67d4b993cd478..99404c15e3a22 100644 --- a/build.gradle +++ b/build.gradle @@ -200,7 +200,7 @@ subprojects { for (final Version version : versionCollection.versionsIndexCompatibleWithCurrent) { if (version.branch != null) { - String snapshotProject = ":distribution:bwc-snapshot-${version.branch}" + final String snapshotProject = ":distribution:bwc-snapshot-${version.branch}" project(snapshotProject).ext.bwcVersion = version ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${version}"] = snapshotProject ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${version}"] = snapshotProject diff --git a/settings.gradle b/settings.gradle index b9696b2fc13cd..e26b38a30a228 100644 --- a/settings.gradle +++ b/settings.gradle @@ -136,18 +136,30 @@ if (isEclipse) { * of the dir hierarchy to have a build.gradle. Otherwise we would have to iterate * all files/directories in the source tree to find all projects. */ -void addSubProjects(String path, File dir) { +void addSubProjects(String path, File dir, List projects, List branches) { if (dir.isDirectory() == false) return; if (dir.name == 'buildSrc') return; if (new File(dir, 'build.gradle').exists() == false) return; - String projectName = "${path}:${dir.name}" + final String projectName = "${path}:${dir.name}" include projectName - if (path.isEmpty()) { - project(projectName).projectDir = dir - } - for (File subdir : dir.listFiles()) { - addSubProjects(projectName, subdir) + + if (dir.name == 'bwc') { + final File dummyProject = new File(dir, "snapshot") + for (final String branch : branches) { + final String snapshotProjectName = "${projectName}:bwc-snapshot-${branch}" + projects.add(snapshotProjectName) + include snapshotProjectName + project("${snapshotProjectName}").projectDir = dummyProject + } + // TODO do we want to assert that there's nothing else in the bwc directory? + } else { + if (path.isEmpty()) { + project(projectName).projectDir = dir + } + for (File subdir : dir.listFiles()) { + addSubProjects(projectName, subdir, projects, branches) + } } } @@ -155,6 +167,6 @@ void addSubProjects(String path, File dir) { File extraProjects = new File(rootProject.projectDir.parentFile, "${dirName}-extra") if (extraProjects.exists()) { for (File extraProjectDir : extraProjects.listFiles()) { - addSubProjects('', extraProjectDir) + addSubProjects('', extraProjectDir, projects, branches) } } From c75b874631e0ed8a53882de6c3a15f01c6c53d26 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 23 Nov 2017 10:43:56 +0000 Subject: [PATCH 22/23] Choose a name that's less likely to clash --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index e26b38a30a228..00ef98905cfff 100644 --- a/settings.gradle +++ b/settings.gradle @@ -144,7 +144,7 @@ void addSubProjects(String path, File dir, List projects, List b final String projectName = "${path}:${dir.name}" include projectName - if (dir.name == 'bwc') { + if (dir.name == 'bwc-snapshot-dummy-projects') { final File dummyProject = new File(dir, "snapshot") for (final String branch : branches) { final String snapshotProjectName = "${projectName}:bwc-snapshot-${branch}" From 27810c3ecc44c3cc89bfcd3bc8348c67f8040179 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 23 Nov 2017 13:12:40 +0000 Subject: [PATCH 23/23] Just check out into the dummy project directory, no need for an extra layer --- settings.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/settings.gradle b/settings.gradle index 00ef98905cfff..cdac374198b5e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -145,12 +145,11 @@ void addSubProjects(String path, File dir, List projects, List b include projectName if (dir.name == 'bwc-snapshot-dummy-projects') { - final File dummyProject = new File(dir, "snapshot") for (final String branch : branches) { final String snapshotProjectName = "${projectName}:bwc-snapshot-${branch}" projects.add(snapshotProjectName) include snapshotProjectName - project("${snapshotProjectName}").projectDir = dummyProject + project("${snapshotProjectName}").projectDir = dir } // TODO do we want to assert that there's nothing else in the bwc directory? } else {