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.elasticsearch.gradle.BuildPlugin
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.VersionCollection
|
||||
import org.elasticsearch.gradle.BwcVersions
|
||||
import org.elasticsearch.gradle.VersionProperties
|
||||
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
|
||||
import org.gradle.util.GradleVersion
|
||||
|
@ -105,7 +105,7 @@ subprojects {
|
|||
* 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('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
|
||||
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.LoggedExec
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.VersionCollection
|
||||
import org.elasticsearch.gradle.BwcVersions
|
||||
import org.elasticsearch.gradle.VersionProperties
|
||||
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
|
||||
import org.elasticsearch.gradle.plugin.PluginPropertiesExtension
|
||||
|
@ -210,7 +210,7 @@ class ClusterFormationTasks {
|
|||
snapshotProject = "oss-" + snapshotProject
|
||||
}
|
||||
boolean internalBuild = project.hasProperty('bwcVersions')
|
||||
VersionCollection.UnreleasedVersionInfo unreleasedInfo = null
|
||||
BwcVersions.UnreleasedVersionInfo unreleasedInfo = null
|
||||
if (project.hasProperty('bwcVersions')) {
|
||||
// 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)
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
|
|||
import org.elasticsearch.gradle.FileContentsTask
|
||||
import org.elasticsearch.gradle.LoggedExec
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.VersionCollection
|
||||
import org.elasticsearch.gradle.BwcVersions
|
||||
import org.gradle.api.*
|
||||
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
||||
import org.gradle.api.execution.TaskExecutionAdapter
|
||||
|
@ -194,7 +194,7 @@ class VagrantTestPlugin implements Plugin<Project> {
|
|||
if (project.ext.bwc_tests_enabled) {
|
||||
// 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
|
||||
VersionCollection.UnreleasedVersionInfo unreleasedInfo = project.bwcVersions.unreleasedInfo(upgradeFromVersion)
|
||||
BwcVersions.UnreleasedVersionInfo unreleasedInfo = project.bwcVersions.unreleasedInfo(upgradeFromVersion)
|
||||
if (unreleasedInfo != null) {
|
||||
// handle snapshots pointing to bwc build
|
||||
UPGRADE_FROM_ARCHIVES.each {
|
||||
|
|
|
@ -26,6 +26,8 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Matcher;
|
||||
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
|
||||
* 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(
|
||||
"\\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()));
|
||||
}
|
||||
|
||||
protected VersionCollection(List<String> versionLines, Version currentVersionProperty) {
|
||||
groupByMajor = versionLines.stream()
|
||||
protected BwcVersions(List<String> versionLines, Version currentVersionProperty) {
|
||||
SortedSet<Version> allVersions = versionLines.stream()
|
||||
.map(LINE_PATTERN::matcher)
|
||||
.filter(Matcher::matches)
|
||||
.map(match -> new Version(
|
||||
|
@ -115,19 +117,19 @@ public class VersionCollection {
|
|||
Integer.parseInt(match.group(2)),
|
||||
Integer.parseInt(match.group(3))
|
||||
))
|
||||
.sorted()
|
||||
.distinct()
|
||||
.collect(Collectors.groupingBy(Version::getMajor, Collectors.toList()));
|
||||
.collect(Collectors.toCollection(TreeSet::new));
|
||||
|
||||
if (groupByMajor.isEmpty()) {
|
||||
if (allVersions.isEmpty()) {
|
||||
throw new IllegalArgumentException("Could not parse any versions");
|
||||
}
|
||||
|
||||
currentVersion = getLatestVersionByKey(
|
||||
groupByMajor,
|
||||
groupByMajor.keySet().stream().max(Integer::compareTo)
|
||||
.orElseThrow(() -> new IllegalStateException("Unexpected number of versions in collection"))
|
||||
);
|
||||
currentVersion = allVersions.last();
|
||||
|
||||
groupByMajor = allVersions.stream()
|
||||
// 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);
|
||||
|
|
@ -33,7 +33,7 @@ import static java.util.Collections.singletonList;
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
public class VersionCollectionTests extends GradleUnitTestCase {
|
||||
public class BwcVersionsTests extends GradleUnitTestCase {
|
||||
|
||||
private static final Map<String, List<String>> sampleVersions = new HashMap<>();
|
||||
|
||||
|
@ -88,17 +88,17 @@ public class VersionCollectionTests extends GradleUnitTestCase {
|
|||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
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)
|
||||
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)
|
||||
public void testExceptionOnTooManyMajors() {
|
||||
new VersionCollection(
|
||||
new BwcVersions(
|
||||
asList(
|
||||
formatVersionToLine("5.6.12"),
|
||||
formatVersionToLine("6.5.0"),
|
||||
|
@ -348,7 +348,7 @@ public class VersionCollectionTests extends GradleUnitTestCase {
|
|||
.map(Version::fromString)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
VersionCollection vc = new VersionCollection(
|
||||
BwcVersions vc = new BwcVersions(
|
||||
listOfVersions.stream()
|
||||
.map(this::formatVersionToLine)
|
||||
.collect(Collectors.toList()),
|
||||
|
@ -363,7 +363,7 @@ public class VersionCollectionTests extends GradleUnitTestCase {
|
|||
.map(Version::fromString)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
VersionCollection vc = new VersionCollection(
|
||||
BwcVersions vc = new BwcVersions(
|
||||
listOfVersions.stream()
|
||||
.map(this::formatVersionToLine)
|
||||
.collect(Collectors.toList()),
|
||||
|
@ -379,7 +379,7 @@ public class VersionCollectionTests extends GradleUnitTestCase {
|
|||
List<Version> authoritativeReleasedVersions = Stream.of("7.0.0", "7.0.1")
|
||||
.map(Version::fromString)
|
||||
.collect(Collectors.toList());
|
||||
VersionCollection vc = new VersionCollection(
|
||||
BwcVersions vc = new BwcVersions(
|
||||
listOfVersions.stream()
|
||||
.map(this::formatVersionToLine)
|
||||
.collect(Collectors.toList()),
|
||||
|
@ -390,17 +390,17 @@ public class VersionCollectionTests extends GradleUnitTestCase {
|
|||
vc.compareToAuthoritative(authoritativeReleasedVersions);
|
||||
}
|
||||
|
||||
private void assertUnreleasedGradleProjectPaths(List<String> expectedNAmes, VersionCollection versionCollection) {
|
||||
private void assertUnreleasedGradleProjectPaths(List<String> expectedNAmes, BwcVersions bwcVersions) {
|
||||
List<String> actualNames = new ArrayList<>();
|
||||
versionCollection.forPreviousUnreleased(unreleasedVersion ->
|
||||
bwcVersions.forPreviousUnreleased(unreleasedVersion ->
|
||||
actualNames.add(unreleasedVersion.gradleProjectPath)
|
||||
);
|
||||
assertEquals(expectedNAmes, actualNames);
|
||||
}
|
||||
|
||||
private void assertUnreleasedBranchNames(List<String> expectedBranches, VersionCollection versionCollection) {
|
||||
private void assertUnreleasedBranchNames(List<String> expectedBranches, BwcVersions bwcVersions) {
|
||||
List<String> actualBranches = new ArrayList<>();
|
||||
versionCollection.forPreviousUnreleased(unreleasedVersionInfo ->
|
||||
bwcVersions.forPreviousUnreleased(unreleasedVersionInfo ->
|
||||
actualBranches.add(unreleasedVersionInfo.branch)
|
||||
);
|
||||
assertEquals(expectedBranches, actualBranches);
|
||||
|
@ -419,8 +419,8 @@ public class VersionCollectionTests extends GradleUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
private VersionCollection getVersionCollection(String currentVersion) {
|
||||
return new VersionCollection(
|
||||
private BwcVersions getVersionCollection(String currentVersion) {
|
||||
return new BwcVersions(
|
||||
sampleVersions.get(currentVersion).stream()
|
||||
.map(this::formatVersionToLine)
|
||||
.collect(Collectors.toList()),
|
|
@ -20,7 +20,7 @@
|
|||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.elasticsearch.gradle.LoggedExec
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.VersionCollection
|
||||
import org.elasticsearch.gradle.BwcVersions
|
||||
|
||||
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
|
||||
* 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
|
||||
String bwcBranch = unreleasedVersion.branch
|
||||
apply plugin: 'distribution'
|
||||
|
|
Loading…
Reference in New Issue