parent
0f89427eb6
commit
7dcc191aa8
|
@ -21,7 +21,7 @@ import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
||||||
import org.apache.tools.ant.taskdefs.condition.Os
|
import org.apache.tools.ant.taskdefs.condition.Os
|
||||||
import org.elasticsearch.gradle.BuildPlugin
|
import org.elasticsearch.gradle.BuildPlugin
|
||||||
import org.elasticsearch.gradle.Version
|
import org.elasticsearch.gradle.Version
|
||||||
import org.elasticsearch.gradle.VersionCollection
|
import org.elasticsearch.gradle.BwcVersions
|
||||||
import org.elasticsearch.gradle.VersionProperties
|
import org.elasticsearch.gradle.VersionProperties
|
||||||
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
|
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
|
||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
|
@ -105,7 +105,7 @@ subprojects {
|
||||||
* backwards compatibility guarantees and only keeping the latest beta or rc
|
* 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
|
* in a branch if there are only betas and rcs in the branch so we have
|
||||||
* *something* to test against. */
|
* *something* to test against. */
|
||||||
VersionCollection versions = new VersionCollection(file('server/src/main/java/org/elasticsearch/Version.java').readLines('UTF-8'))
|
BwcVersions versions = new BwcVersions(file('server/src/main/java/org/elasticsearch/Version.java').readLines('UTF-8'))
|
||||||
|
|
||||||
// build metadata from previous build, contains eg hashes for bwc builds
|
// build metadata from previous build, contains eg hashes for bwc builds
|
||||||
String buildMetadataValue = System.getenv('BUILD_METADATA')
|
String buildMetadataValue = System.getenv('BUILD_METADATA')
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
|
||||||
import org.elasticsearch.gradle.BuildPlugin
|
import org.elasticsearch.gradle.BuildPlugin
|
||||||
import org.elasticsearch.gradle.LoggedExec
|
import org.elasticsearch.gradle.LoggedExec
|
||||||
import org.elasticsearch.gradle.Version
|
import org.elasticsearch.gradle.Version
|
||||||
import org.elasticsearch.gradle.VersionCollection
|
import org.elasticsearch.gradle.BwcVersions
|
||||||
import org.elasticsearch.gradle.VersionProperties
|
import org.elasticsearch.gradle.VersionProperties
|
||||||
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
|
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
|
||||||
import org.elasticsearch.gradle.plugin.PluginPropertiesExtension
|
import org.elasticsearch.gradle.plugin.PluginPropertiesExtension
|
||||||
|
@ -210,7 +210,7 @@ class ClusterFormationTasks {
|
||||||
snapshotProject = "oss-" + snapshotProject
|
snapshotProject = "oss-" + snapshotProject
|
||||||
}
|
}
|
||||||
boolean internalBuild = project.hasProperty('bwcVersions')
|
boolean internalBuild = project.hasProperty('bwcVersions')
|
||||||
VersionCollection.UnreleasedVersionInfo unreleasedInfo = null
|
BwcVersions.UnreleasedVersionInfo unreleasedInfo = null
|
||||||
if (project.hasProperty('bwcVersions')) {
|
if (project.hasProperty('bwcVersions')) {
|
||||||
// NOTE: leniency is needed for external plugin authors using build-tools. maybe build the version compat info into build-tools?
|
// NOTE: leniency is needed for external plugin authors using build-tools. maybe build the version compat info into build-tools?
|
||||||
unreleasedInfo = project.bwcVersions.unreleasedInfo(version)
|
unreleasedInfo = project.bwcVersions.unreleasedInfo(version)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
|
||||||
import org.elasticsearch.gradle.FileContentsTask
|
import org.elasticsearch.gradle.FileContentsTask
|
||||||
import org.elasticsearch.gradle.LoggedExec
|
import org.elasticsearch.gradle.LoggedExec
|
||||||
import org.elasticsearch.gradle.Version
|
import org.elasticsearch.gradle.Version
|
||||||
import org.elasticsearch.gradle.VersionCollection
|
import org.elasticsearch.gradle.BwcVersions
|
||||||
import org.gradle.api.*
|
import org.gradle.api.*
|
||||||
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
||||||
import org.gradle.api.execution.TaskExecutionAdapter
|
import org.gradle.api.execution.TaskExecutionAdapter
|
||||||
|
@ -194,7 +194,7 @@ class VagrantTestPlugin implements Plugin<Project> {
|
||||||
if (project.ext.bwc_tests_enabled) {
|
if (project.ext.bwc_tests_enabled) {
|
||||||
// The version of elasticsearch that we upgrade *from*
|
// The version of elasticsearch that we upgrade *from*
|
||||||
// we only add them as dependencies if the bwc tests are enabled, so we don't trigger builds otherwise
|
// we only add them as dependencies if the bwc tests are enabled, so we don't trigger builds otherwise
|
||||||
VersionCollection.UnreleasedVersionInfo unreleasedInfo = project.bwcVersions.unreleasedInfo(upgradeFromVersion)
|
BwcVersions.UnreleasedVersionInfo unreleasedInfo = project.bwcVersions.unreleasedInfo(upgradeFromVersion)
|
||||||
if (unreleasedInfo != null) {
|
if (unreleasedInfo != null) {
|
||||||
// handle snapshots pointing to bwc build
|
// handle snapshots pointing to bwc build
|
||||||
UPGRADE_FROM_ARCHIVES.each {
|
UPGRADE_FROM_ARCHIVES.each {
|
||||||
|
|
|
@ -26,6 +26,8 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -80,7 +82,7 @@ import static java.util.Collections.unmodifiableList;
|
||||||
* We are then able to map the unreleased version to branches in git and Gradle projects that are capable of checking
|
* We are then able to map the unreleased version to branches in git and Gradle projects that are capable of checking
|
||||||
* out and building them, so we can include these in the testing plan as well.
|
* out and building them, so we can include these in the testing plan as well.
|
||||||
*/
|
*/
|
||||||
public class VersionCollection {
|
public class BwcVersions {
|
||||||
|
|
||||||
private static final Pattern LINE_PATTERN = Pattern.compile(
|
private static final Pattern LINE_PATTERN = Pattern.compile(
|
||||||
"\\W+public static final Version V_(\\d+)_(\\d+)_(\\d+)(_alpha\\d+|_beta\\d+|_rc\\d+)? .*"
|
"\\W+public static final Version V_(\\d+)_(\\d+)_(\\d+)(_alpha\\d+|_beta\\d+|_rc\\d+)? .*"
|
||||||
|
@ -102,12 +104,12 @@ public class VersionCollection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public VersionCollection(List<String> versionLines) {
|
public BwcVersions(List<String> versionLines) {
|
||||||
this(versionLines, Version.fromString(VersionProperties.getElasticsearch()));
|
this(versionLines, Version.fromString(VersionProperties.getElasticsearch()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VersionCollection(List<String> versionLines, Version currentVersionProperty) {
|
protected BwcVersions(List<String> versionLines, Version currentVersionProperty) {
|
||||||
groupByMajor = versionLines.stream()
|
SortedSet<Version> allVersions = versionLines.stream()
|
||||||
.map(LINE_PATTERN::matcher)
|
.map(LINE_PATTERN::matcher)
|
||||||
.filter(Matcher::matches)
|
.filter(Matcher::matches)
|
||||||
.map(match -> new Version(
|
.map(match -> new Version(
|
||||||
|
@ -115,19 +117,19 @@ public class VersionCollection {
|
||||||
Integer.parseInt(match.group(2)),
|
Integer.parseInt(match.group(2)),
|
||||||
Integer.parseInt(match.group(3))
|
Integer.parseInt(match.group(3))
|
||||||
))
|
))
|
||||||
.sorted()
|
.collect(Collectors.toCollection(TreeSet::new));
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.groupingBy(Version::getMajor, Collectors.toList()));
|
|
||||||
|
|
||||||
if (groupByMajor.isEmpty()) {
|
if (allVersions.isEmpty()) {
|
||||||
throw new IllegalArgumentException("Could not parse any versions");
|
throw new IllegalArgumentException("Could not parse any versions");
|
||||||
}
|
}
|
||||||
|
|
||||||
currentVersion = getLatestVersionByKey(
|
currentVersion = allVersions.last();
|
||||||
groupByMajor,
|
|
||||||
groupByMajor.keySet().stream().max(Integer::compareTo)
|
groupByMajor = allVersions.stream()
|
||||||
.orElseThrow(() -> new IllegalStateException("Unexpected number of versions in collection"))
|
// We only care about the last 2 majors when it comes to BWC.
|
||||||
);
|
// It might take us time to remove the older ones from versionLines, so we allow them to exist.
|
||||||
|
.filter(version -> version.getMajor() > currentVersion.getMajor() - 2)
|
||||||
|
.collect(Collectors.groupingBy(Version::getMajor, Collectors.toList()));
|
||||||
|
|
||||||
assertCurrentVersionMatchesParsed(currentVersionProperty);
|
assertCurrentVersionMatchesParsed(currentVersionProperty);
|
||||||
|
|
|
@ -33,7 +33,7 @@ import static java.util.Collections.singletonList;
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
public class VersionCollectionTests extends GradleUnitTestCase {
|
public class BwcVersionsTests extends GradleUnitTestCase {
|
||||||
|
|
||||||
private static final Map<String, List<String>> sampleVersions = new HashMap<>();
|
private static final Map<String, List<String>> sampleVersions = new HashMap<>();
|
||||||
|
|
||||||
|
@ -88,17 +88,17 @@ public class VersionCollectionTests extends GradleUnitTestCase {
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void testExceptionOnEmpty() {
|
public void testExceptionOnEmpty() {
|
||||||
new VersionCollection(asList("foo", "bar"), Version.fromString("7.0.0"));
|
new BwcVersions(asList("foo", "bar"), Version.fromString("7.0.0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalStateException.class)
|
@Test(expected = IllegalStateException.class)
|
||||||
public void testExceptionOnNonCurrent() {
|
public void testExceptionOnNonCurrent() {
|
||||||
new VersionCollection(singletonList(formatVersionToLine("6.5.0")), Version.fromString("7.0.0"));
|
new BwcVersions(singletonList(formatVersionToLine("6.5.0")), Version.fromString("7.0.0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalStateException.class)
|
@Test(expected = IllegalStateException.class)
|
||||||
public void testExceptionOnTooManyMajors() {
|
public void testExceptionOnTooManyMajors() {
|
||||||
new VersionCollection(
|
new BwcVersions(
|
||||||
asList(
|
asList(
|
||||||
formatVersionToLine("5.6.12"),
|
formatVersionToLine("5.6.12"),
|
||||||
formatVersionToLine("6.5.0"),
|
formatVersionToLine("6.5.0"),
|
||||||
|
@ -348,7 +348,7 @@ public class VersionCollectionTests extends GradleUnitTestCase {
|
||||||
.map(Version::fromString)
|
.map(Version::fromString)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
VersionCollection vc = new VersionCollection(
|
BwcVersions vc = new BwcVersions(
|
||||||
listOfVersions.stream()
|
listOfVersions.stream()
|
||||||
.map(this::formatVersionToLine)
|
.map(this::formatVersionToLine)
|
||||||
.collect(Collectors.toList()),
|
.collect(Collectors.toList()),
|
||||||
|
@ -363,7 +363,7 @@ public class VersionCollectionTests extends GradleUnitTestCase {
|
||||||
.map(Version::fromString)
|
.map(Version::fromString)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
VersionCollection vc = new VersionCollection(
|
BwcVersions vc = new BwcVersions(
|
||||||
listOfVersions.stream()
|
listOfVersions.stream()
|
||||||
.map(this::formatVersionToLine)
|
.map(this::formatVersionToLine)
|
||||||
.collect(Collectors.toList()),
|
.collect(Collectors.toList()),
|
||||||
|
@ -379,7 +379,7 @@ public class VersionCollectionTests extends GradleUnitTestCase {
|
||||||
List<Version> authoritativeReleasedVersions = Stream.of("7.0.0", "7.0.1")
|
List<Version> authoritativeReleasedVersions = Stream.of("7.0.0", "7.0.1")
|
||||||
.map(Version::fromString)
|
.map(Version::fromString)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
VersionCollection vc = new VersionCollection(
|
BwcVersions vc = new BwcVersions(
|
||||||
listOfVersions.stream()
|
listOfVersions.stream()
|
||||||
.map(this::formatVersionToLine)
|
.map(this::formatVersionToLine)
|
||||||
.collect(Collectors.toList()),
|
.collect(Collectors.toList()),
|
||||||
|
@ -390,17 +390,17 @@ public class VersionCollectionTests extends GradleUnitTestCase {
|
||||||
vc.compareToAuthoritative(authoritativeReleasedVersions);
|
vc.compareToAuthoritative(authoritativeReleasedVersions);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertUnreleasedGradleProjectPaths(List<String> expectedNAmes, VersionCollection versionCollection) {
|
private void assertUnreleasedGradleProjectPaths(List<String> expectedNAmes, BwcVersions bwcVersions) {
|
||||||
List<String> actualNames = new ArrayList<>();
|
List<String> actualNames = new ArrayList<>();
|
||||||
versionCollection.forPreviousUnreleased(unreleasedVersion ->
|
bwcVersions.forPreviousUnreleased(unreleasedVersion ->
|
||||||
actualNames.add(unreleasedVersion.gradleProjectPath)
|
actualNames.add(unreleasedVersion.gradleProjectPath)
|
||||||
);
|
);
|
||||||
assertEquals(expectedNAmes, actualNames);
|
assertEquals(expectedNAmes, actualNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertUnreleasedBranchNames(List<String> expectedBranches, VersionCollection versionCollection) {
|
private void assertUnreleasedBranchNames(List<String> expectedBranches, BwcVersions bwcVersions) {
|
||||||
List<String> actualBranches = new ArrayList<>();
|
List<String> actualBranches = new ArrayList<>();
|
||||||
versionCollection.forPreviousUnreleased(unreleasedVersionInfo ->
|
bwcVersions.forPreviousUnreleased(unreleasedVersionInfo ->
|
||||||
actualBranches.add(unreleasedVersionInfo.branch)
|
actualBranches.add(unreleasedVersionInfo.branch)
|
||||||
);
|
);
|
||||||
assertEquals(expectedBranches, actualBranches);
|
assertEquals(expectedBranches, actualBranches);
|
||||||
|
@ -419,8 +419,8 @@ public class VersionCollectionTests extends GradleUnitTestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private VersionCollection getVersionCollection(String currentVersion) {
|
private BwcVersions getVersionCollection(String currentVersion) {
|
||||||
return new VersionCollection(
|
return new BwcVersions(
|
||||||
sampleVersions.get(currentVersion).stream()
|
sampleVersions.get(currentVersion).stream()
|
||||||
.map(this::formatVersionToLine)
|
.map(this::formatVersionToLine)
|
||||||
.collect(Collectors.toList()),
|
.collect(Collectors.toList()),
|
|
@ -20,7 +20,7 @@
|
||||||
import org.apache.tools.ant.taskdefs.condition.Os
|
import org.apache.tools.ant.taskdefs.condition.Os
|
||||||
import org.elasticsearch.gradle.LoggedExec
|
import org.elasticsearch.gradle.LoggedExec
|
||||||
import org.elasticsearch.gradle.Version
|
import org.elasticsearch.gradle.Version
|
||||||
import org.elasticsearch.gradle.VersionCollection
|
import org.elasticsearch.gradle.BwcVersions
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ import static org.elasticsearch.gradle.BuildPlugin.getJavaHome
|
||||||
* unreleased versions are when Gradle projects are set up, so we use "build-unreleased-version-*" as placeholders
|
* unreleased versions are when Gradle projects are set up, so we use "build-unreleased-version-*" as placeholders
|
||||||
* and configure them to build various versions here.
|
* and configure them to build various versions here.
|
||||||
*/
|
*/
|
||||||
bwcVersions.forPreviousUnreleased { VersionCollection.UnreleasedVersionInfo unreleasedVersion -> project("${unreleasedVersion.gradleProjectPath}") {
|
bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInfo unreleasedVersion -> project("${unreleasedVersion.gradleProjectPath}") {
|
||||||
Version bwcVersion = unreleasedVersion.version
|
Version bwcVersion = unreleasedVersion.version
|
||||||
String bwcBranch = unreleasedVersion.branch
|
String bwcBranch = unreleasedVersion.branch
|
||||||
apply plugin: 'distribution'
|
apply plugin: 'distribution'
|
||||||
|
|
Loading…
Reference in New Issue