Update BWC version logic to support multiple bugfix versions (#117943)

This commit is contained in:
Mark Vieira 2024-12-05 09:43:18 -08:00 committed by GitHub
parent 4740b02a9b
commit 7070e95fa7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 326 additions and 213 deletions

View File

@ -56,7 +56,7 @@ steps:
timeout_in_minutes: 300
matrix:
setup:
BWC_VERSION: ["8.16.2", "8.17.0", "8.18.0", "9.0.0"]
BWC_VERSION: ["8.15.6", "8.16.2", "8.17.0", "8.18.0", "9.0.0"]
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004

View File

@ -448,7 +448,7 @@ steps:
setup:
ES_RUNTIME_JAVA:
- openjdk21
BWC_VERSION: ["8.16.2", "8.17.0", "8.18.0", "9.0.0"]
BWC_VERSION: ["8.15.6", "8.16.2", "8.17.0", "8.18.0", "9.0.0"]
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004
@ -490,7 +490,7 @@ steps:
ES_RUNTIME_JAVA:
- openjdk21
- openjdk23
BWC_VERSION: ["8.16.2", "8.17.0", "8.18.0", "9.0.0"]
BWC_VERSION: ["8.15.6", "8.16.2", "8.17.0", "8.18.0", "9.0.0"]
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004

View File

@ -1,4 +1,5 @@
BWC_VERSION:
- "8.15.6"
- "8.16.2"
- "8.17.0"
- "8.18.0"

View File

@ -9,9 +9,10 @@
package org.elasticsearch.gradle.internal
import spock.lang.Unroll
import org.elasticsearch.gradle.fixtures.AbstractGitAwareGradleFuncTest
import org.gradle.testkit.runner.TaskOutcome
import spock.lang.Unroll
class InternalDistributionBwcSetupPluginFuncTest extends AbstractGitAwareGradleFuncTest {
@ -23,8 +24,10 @@ class InternalDistributionBwcSetupPluginFuncTest extends AbstractGitAwareGradleF
apply plugin: 'elasticsearch.internal-distribution-bwc-setup'
"""
execute("git branch origin/8.x", file("cloned"))
execute("git branch origin/8.3", file("cloned"))
execute("git branch origin/8.2", file("cloned"))
execute("git branch origin/8.1", file("cloned"))
execute("git branch origin/7.16", file("cloned"))
execute("git branch origin/7.15", file("cloned"))
}
def "builds distribution from branches via archives extractedAssemble"() {
@ -48,10 +51,11 @@ class InternalDistributionBwcSetupPluginFuncTest extends AbstractGitAwareGradleF
assertOutputContains(result.output, "[$bwcDistVersion] > Task :distribution:archives:darwin-tar:${expectedAssembleTaskName}")
where:
bwcDistVersion | bwcProject | expectedAssembleTaskName
"8.0.0" | "minor" | "extractedAssemble"
"7.16.0" | "staged" | "extractedAssemble"
"7.15.2" | "bugfix" | "extractedAssemble"
bwcDistVersion | bwcProject | expectedAssembleTaskName
"8.4.0" | "minor" | "extractedAssemble"
"8.3.0" | "staged" | "extractedAssemble"
"8.2.1" | "bugfix" | "extractedAssemble"
"8.1.3" | "bugfix2" | "extractedAssemble"
}
@Unroll
@ -70,8 +74,8 @@ class InternalDistributionBwcSetupPluginFuncTest extends AbstractGitAwareGradleF
where:
bwcDistVersion | platform
"8.0.0" | "darwin"
"8.0.0" | "linux"
"8.4.0" | "darwin"
"8.4.0" | "linux"
}
def "bwc expanded distribution folder can be resolved as bwc project artifact"() {
@ -107,11 +111,11 @@ class InternalDistributionBwcSetupPluginFuncTest extends AbstractGitAwareGradleF
result.task(":resolveExpandedDistribution").outcome == TaskOutcome.SUCCESS
result.task(":distribution:bwc:minor:buildBwcDarwinTar").outcome == TaskOutcome.SUCCESS
and: "assemble task triggered"
result.output.contains("[8.0.0] > Task :distribution:archives:darwin-tar:extractedAssemble")
result.output.contains("[8.4.0] > Task :distribution:archives:darwin-tar:extractedAssemble")
result.output.contains("expandedRootPath /distribution/bwc/minor/build/bwc/checkout-8.x/" +
"distribution/archives/darwin-tar/build/install")
result.output.contains("nested folder /distribution/bwc/minor/build/bwc/checkout-8.x/" +
"distribution/archives/darwin-tar/build/install/elasticsearch-8.0.0-SNAPSHOT")
"distribution/archives/darwin-tar/build/install/elasticsearch-8.4.0-SNAPSHOT")
}
}

View File

@ -57,7 +57,7 @@ class InternalDistributionDownloadPluginFuncTest extends AbstractGradleFuncTest
elasticsearch_distributions {
test_distro {
version = "8.0.0"
version = "8.4.0"
type = "archive"
platform = "linux"
architecture = Architecture.current();
@ -87,7 +87,7 @@ class InternalDistributionDownloadPluginFuncTest extends AbstractGradleFuncTest
elasticsearch_distributions {
test_distro {
version = "8.0.0"
version = "8.4.0"
type = "archive"
platform = "linux"
architecture = Architecture.current();

View File

@ -40,7 +40,7 @@ class LegacyYamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTe
given:
internalBuild()
subProject(":distribution:bwc:staged") << """
subProject(":distribution:bwc:minor") << """
configurations { checkout }
artifacts {
checkout(new File(projectDir, "checkoutDir"))
@ -61,11 +61,11 @@ class LegacyYamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTe
result.task(transformTask).outcome == TaskOutcome.NO_SOURCE
}
def "yamlRestCompatTest executes and copies api and transforms tests from :bwc:staged"() {
def "yamlRestCompatTest executes and copies api and transforms tests from :bwc:minor"() {
given:
internalBuild()
subProject(":distribution:bwc:staged") << """
subProject(":distribution:bwc:minor") << """
configurations { checkout }
artifacts {
checkout(new File(projectDir, "checkoutDir"))
@ -98,8 +98,8 @@ class LegacyYamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTe
String api = "foo.json"
String test = "10_basic.yml"
//add the compatible test and api files, these are the prior version's normal yaml rest tests
file("distribution/bwc/staged/checkoutDir/rest-api-spec/src/main/resources/rest-api-spec/api/" + api) << ""
file("distribution/bwc/staged/checkoutDir/src/yamlRestTest/resources/rest-api-spec/test/" + test) << ""
file("distribution/bwc/minor/checkoutDir/rest-api-spec/src/main/resources/rest-api-spec/api/" + api) << ""
file("distribution/bwc/minor/checkoutDir/src/yamlRestTest/resources/rest-api-spec/test/" + test) << ""
when:
def result = gradleRunner("yamlRestCompatTest").build()
@ -145,7 +145,7 @@ class LegacyYamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTe
given:
internalBuild()
withVersionCatalogue()
subProject(":distribution:bwc:staged") << """
subProject(":distribution:bwc:minor") << """
configurations { checkout }
artifacts {
checkout(new File(projectDir, "checkoutDir"))
@ -186,7 +186,7 @@ class LegacyYamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTe
given:
internalBuild()
subProject(":distribution:bwc:staged") << """
subProject(":distribution:bwc:minor") << """
configurations { checkout }
artifacts {
checkout(new File(projectDir, "checkoutDir"))
@ -230,7 +230,7 @@ class LegacyYamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTe
setupRestResources([], [])
file("distribution/bwc/staged/checkoutDir/src/yamlRestTest/resources/rest-api-spec/test/test.yml" ) << """
file("distribution/bwc/minor/checkoutDir/src/yamlRestTest/resources/rest-api-spec/test/test.yml" ) << """
"one":
- do:
do_.some.key_to_replace:

View File

@ -10,9 +10,11 @@
rootProject.name = "root"
include ":distribution:bwc:bugfix"
include ":distribution:bwc:bugfix2"
include ":distribution:bwc:minor"
include ":distribution:bwc:major"
include ":distribution:bwc:staged"
include ":distribution:bwc:maintenance"
include ":distribution:archives:darwin-tar"
include ":distribution:archives:oss-darwin-tar"
include ":distribution:archives:darwin-aarch64-tar"

View File

@ -21,14 +21,15 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.Collections.reverseOrder;
import static java.util.Collections.unmodifiableList;
import static java.util.Comparator.comparing;
/**
* A container for elasticsearch supported version information used in BWC testing.
@ -73,11 +74,11 @@ public class BwcVersions implements Serializable {
private final transient List<Version> versions;
private final Map<Version, UnreleasedVersionInfo> unreleased;
public BwcVersions(List<String> versionLines) {
this(versionLines, Version.fromString(VersionProperties.getElasticsearch()));
public BwcVersions(List<String> versionLines, List<String> developmentBranches) {
this(versionLines, Version.fromString(VersionProperties.getElasticsearch()), developmentBranches);
}
public BwcVersions(Version currentVersionProperty, List<Version> allVersions) {
public BwcVersions(Version currentVersionProperty, List<Version> allVersions, List<String> developmentBranches) {
if (allVersions.isEmpty()) {
throw new IllegalArgumentException("Could not parse any versions");
}
@ -86,12 +87,12 @@ public class BwcVersions implements Serializable {
this.currentVersion = allVersions.get(allVersions.size() - 1);
assertCurrentVersionMatchesParsed(currentVersionProperty);
this.unreleased = computeUnreleased();
this.unreleased = computeUnreleased(developmentBranches);
}
// Visible for testing
BwcVersions(List<String> versionLines, Version currentVersionProperty) {
this(currentVersionProperty, parseVersionLines(versionLines));
BwcVersions(List<String> versionLines, Version currentVersionProperty, List<String> developmentBranches) {
this(currentVersionProperty, parseVersionLines(versionLines), developmentBranches);
}
private static List<Version> parseVersionLines(List<String> versionLines) {
@ -126,58 +127,77 @@ public class BwcVersions implements Serializable {
getUnreleased().stream().filter(version -> version.equals(currentVersion) == false).map(unreleased::get).forEach(consumer);
}
private String getBranchFor(Version version) {
if (version.equals(currentVersion)) {
// Just assume the current branch is 'main'. It's actually not important, we never check out the current branch.
return "main";
} else {
private String getBranchFor(Version version, List<String> developmentBranches) {
// If the current version matches a specific feature freeze branch, use that
if (developmentBranches.contains(version.getMajor() + "." + version.getMinor())) {
return version.getMajor() + "." + version.getMinor();
} else if (developmentBranches.contains(version.getMajor() + ".x")) { // Otherwise if an n.x branch exists and we are that major
return version.getMajor() + ".x";
} else { // otherwise we're the main branch
return "main";
}
}
private Map<Version, UnreleasedVersionInfo> computeUnreleased() {
Set<Version> unreleased = new TreeSet<>();
// The current version is being worked, is always unreleased
unreleased.add(currentVersion);
// Recurse for all unreleased versions starting from the current version
addUnreleased(unreleased, currentVersion, 0);
// Grab the latest version from the previous major if necessary as well, this is going to be a maintenance release
Version maintenance = versions.stream()
.filter(v -> v.getMajor() == currentVersion.getMajor() - 1)
.max(Comparator.naturalOrder())
.orElseThrow();
// This is considered the maintenance release only if we haven't yet encountered it
boolean hasMaintenanceRelease = unreleased.add(maintenance);
List<Version> unreleasedList = unreleased.stream().sorted(Comparator.reverseOrder()).toList();
private Map<Version, UnreleasedVersionInfo> computeUnreleased(List<String> developmentBranches) {
Map<Version, UnreleasedVersionInfo> result = new TreeMap<>();
boolean newMinor = false;
for (int i = 0; i < unreleasedList.size(); i++) {
Version esVersion = unreleasedList.get(i);
// This is either a new minor or staged release
if (currentVersion.equals(esVersion)) {
result.put(esVersion, new UnreleasedVersionInfo(esVersion, getBranchFor(esVersion), ":distribution"));
} else if (esVersion.getRevision() == 0) {
// If there are two upcoming unreleased minors then this one is the new minor
if (newMinor == false && unreleasedList.get(i + 1).getRevision() == 0) {
result.put(esVersion, new UnreleasedVersionInfo(esVersion, esVersion.getMajor() + ".x", ":distribution:bwc:minor"));
newMinor = true;
} else if (newMinor == false
&& unreleasedList.stream().filter(v -> v.getMajor() == esVersion.getMajor() && v.getRevision() == 0).count() == 1) {
// This is the only unreleased new minor which means we've not yet staged it for release
result.put(esVersion, new UnreleasedVersionInfo(esVersion, esVersion.getMajor() + ".x", ":distribution:bwc:minor"));
newMinor = true;
} else {
result.put(esVersion, new UnreleasedVersionInfo(esVersion, getBranchFor(esVersion), ":distribution:bwc:staged"));
}
} else {
// If this is the oldest unreleased version and we have a maintenance release
if (i == unreleasedList.size() - 1 && hasMaintenanceRelease) {
result.put(esVersion, new UnreleasedVersionInfo(esVersion, getBranchFor(esVersion), ":distribution:bwc:maintenance"));
} else {
result.put(esVersion, new UnreleasedVersionInfo(esVersion, getBranchFor(esVersion), ":distribution:bwc:bugfix"));
}
// The current version is always in development
String currentBranch = getBranchFor(currentVersion, developmentBranches);
result.put(currentVersion, new UnreleasedVersionInfo(currentVersion, currentBranch, ":distribution"));
// Check for an n.x branch as well
if (currentBranch.equals("main") && developmentBranches.stream().anyMatch(s -> s.endsWith(".x"))) {
// This should correspond to the latest new minor
Version version = versions.stream()
.sorted(Comparator.reverseOrder())
.filter(v -> v.getMajor() == (currentVersion.getMajor() - 1) && v.getRevision() == 0)
.findFirst()
.orElseThrow(() -> new IllegalStateException("Unable to determine development version for branch"));
String branch = getBranchFor(version, developmentBranches);
assert branch.equals(currentVersion.getMajor() - 1 + ".x") : "Expected branch does not match development branch";
result.put(version, new UnreleasedVersionInfo(version, branch, ":distribution:bwc:minor"));
}
// Now handle all the feature freeze branches
List<String> featureFreezeBranches = developmentBranches.stream()
.filter(b -> Pattern.matches("[0-9]+\\.[0-9]+", b))
.sorted(reverseOrder(comparing(s -> Version.fromString(s, Version.Mode.RELAXED))))
.toList();
boolean existingBugfix = false;
for (int i = 0; i < featureFreezeBranches.size(); i++) {
String branch = featureFreezeBranches.get(i);
Version version = versions.stream()
.sorted(Comparator.reverseOrder())
.filter(v -> v.toString().startsWith(branch))
.findFirst()
.orElse(null);
// If we don't know about this version we can ignore it
if (version == null) {
continue;
}
// If this is the current version we can ignore as we've already handled it
if (version.equals(currentVersion)) {
continue;
}
// We only maintain compatibility back one major so ignore anything older
if (currentVersion.getMajor() - version.getMajor() > 1) {
continue;
}
// This is the maintenance version
if (i == featureFreezeBranches.size() - 1) {
result.put(version, new UnreleasedVersionInfo(version, branch, ":distribution:bwc:maintenance"));
} else if (version.getRevision() == 0) { // This is the next staged minor
result.put(version, new UnreleasedVersionInfo(version, branch, ":distribution:bwc:staged"));
} else { // This is a bugfix
String project = existingBugfix ? "bugfix2" : "bugfix";
result.put(version, new UnreleasedVersionInfo(version, branch, ":distribution:bwc:" + project));
existingBugfix = true;
}
}

View File

@ -8,6 +8,9 @@
*/
package org.elasticsearch.gradle.internal.info;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.io.IOUtils;
import org.elasticsearch.gradle.VersionProperties;
import org.elasticsearch.gradle.internal.BwcVersions;
@ -44,11 +47,13 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Random;
@ -68,6 +73,7 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
private final JavaInstallationRegistry javaInstallationRegistry;
private final JvmMetadataDetector metadataDetector;
private final ProviderFactory providers;
private final ObjectMapper objectMapper;
private JavaToolchainService toolChainService;
private Project project;
@ -82,7 +88,7 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
this.javaInstallationRegistry = javaInstallationRegistry;
this.metadataDetector = new ErrorTraceMetadataDetector(metadataDetector);
this.providers = providers;
this.objectMapper = new ObjectMapper();
}
@Override
@ -190,12 +196,27 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
);
try (var is = new FileInputStream(versionsFilePath)) {
List<String> versionLines = IOUtils.readLines(is, "UTF-8");
return new BwcVersions(versionLines);
return new BwcVersions(versionLines, getDevelopmentBranches());
} catch (IOException e) {
throw new IllegalStateException("Unable to resolve to resolve bwc versions from versionsFile.", e);
}
}
private List<String> getDevelopmentBranches() {
List<String> branches = new ArrayList<>();
File branchesFile = new File(Util.locateElasticsearchWorkspace(project.getGradle()), "branches.json");
try (InputStream is = new FileInputStream(branchesFile)) {
JsonNode json = objectMapper.readTree(is);
for (JsonNode node : json.get("branches")) {
branches.add(node.get("branch").asText());
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return branches;
}
private void logGlobalBuildInfo(BuildParameterExtension buildParams) {
final String osName = System.getProperty("os.name");
final String osVersion = System.getProperty("os.version");

View File

@ -17,93 +17,9 @@ import org.elasticsearch.gradle.internal.BwcVersions.UnreleasedVersionInfo
class BwcVersionsSpec extends Specification {
List<String> versionLines = []
def "current version is next minor with next major and last minor both staged"() {
given:
addVersion('8.14.0', '9.9.0')
addVersion('8.14.1', '9.9.0')
addVersion('8.14.2', '9.9.0')
addVersion('8.15.0', '9.9.0')
addVersion('8.15.1', '9.9.0')
addVersion('8.15.2', '9.9.0')
addVersion('8.16.0', '9.10.0')
addVersion('8.16.1', '9.10.0')
addVersion('8.17.0', '9.10.0')
addVersion('9.0.0', '10.0.0')
addVersion('9.1.0', '10.1.0')
when:
def bwc = new BwcVersions(versionLines, v('9.1.0'))
def unreleased = bwc.unreleased.collectEntries { [it, bwc.unreleasedInfo(it)] }
then:
unreleased == [
(v('8.16.1')): new UnreleasedVersionInfo(v('8.16.1'), '8.16', ':distribution:bwc:bugfix'),
(v('8.17.0')): new UnreleasedVersionInfo(v('8.17.0'), '8.17', ':distribution:bwc:staged'),
(v('9.0.0')): new UnreleasedVersionInfo(v('9.0.0'), '9.x', ':distribution:bwc:minor'),
(v('9.1.0')): new UnreleasedVersionInfo(v('9.1.0'), 'main', ':distribution')
]
bwc.wireCompatible == [v('8.17.0'), v('9.0.0'), v('9.1.0')]
bwc.indexCompatible == [v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2'), v('8.16.0'), v('8.16.1'), v('8.17.0'), v('9.0.0'), v('9.1.0')]
}
def "current is next minor with upcoming minor staged"() {
given:
addVersion('8.14.0', '9.9.0')
addVersion('8.14.1', '9.9.0')
addVersion('8.14.2', '9.9.0')
addVersion('8.15.0', '9.9.0')
addVersion('8.15.1', '9.9.0')
addVersion('8.15.2', '9.9.0')
addVersion('8.16.0', '9.10.0')
addVersion('8.16.1', '9.10.0')
addVersion('8.17.0', '9.10.0')
addVersion('8.17.1', '9.10.0')
addVersion('9.0.0', '10.0.0')
addVersion('9.1.0', '10.1.0')
when:
def bwc = new BwcVersions(versionLines, v('9.1.0'))
def unreleased = bwc.unreleased.collectEntries { [it, bwc.unreleasedInfo(it)] }
then:
unreleased == [
(v('8.17.1')): new UnreleasedVersionInfo(v('8.17.1'), '8.17', ':distribution:bwc:bugfix'),
(v('9.0.0')): new UnreleasedVersionInfo(v('9.0.0'), '9.0', ':distribution:bwc:staged'),
(v('9.1.0')): new UnreleasedVersionInfo(v('9.1.0'), 'main', ':distribution')
]
bwc.wireCompatible == [v('8.17.0'), v('8.17.1'), v('9.0.0'), v('9.1.0')]
bwc.indexCompatible == [v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2'), v('8.16.0'), v('8.16.1'), v('8.17.0'), v('8.17.1'), v('9.0.0'), v('9.1.0')]
}
def "current version is staged major"() {
given:
addVersion('8.14.0', '9.9.0')
addVersion('8.14.1', '9.9.0')
addVersion('8.14.2', '9.9.0')
addVersion('8.15.0', '9.9.0')
addVersion('8.15.1', '9.9.0')
addVersion('8.15.2', '9.9.0')
addVersion('8.16.0', '9.10.0')
addVersion('8.16.1', '9.10.0')
addVersion('8.17.0', '9.10.0')
addVersion('8.17.1', '9.10.0')
addVersion('9.0.0', '10.0.0')
when:
def bwc = new BwcVersions(versionLines, v('9.0.0'))
def unreleased = bwc.unreleased.collectEntries { [it, bwc.unreleasedInfo(it)] }
then:
unreleased == [
(v('8.17.1')): new UnreleasedVersionInfo(v('8.17.1'), '8.17', ':distribution:bwc:bugfix'),
(v('9.0.0')): new UnreleasedVersionInfo(v('9.0.0'), 'main', ':distribution'),
]
bwc.wireCompatible == [v('8.17.0'), v('8.17.1'), v('9.0.0')]
bwc.indexCompatible == [v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2'), v('8.16.0'), v('8.16.1'), v('8.17.0'), v('8.17.1'), v('9.0.0')]
}
def "current version is major with unreleased next minor"() {
def "current version is next major"() {
given:
addVersion('7.17.10', '8.9.0')
addVersion('8.14.0', '9.9.0')
addVersion('8.14.1', '9.9.0')
addVersion('8.14.2', '9.9.0')
@ -116,11 +32,12 @@ class BwcVersionsSpec extends Specification {
addVersion('9.0.0', '10.0.0')
when:
def bwc = new BwcVersions(versionLines, v('9.0.0'))
def bwc = new BwcVersions(versionLines, v('9.0.0'), ['main', '8.x', '8.16', '8.15', '7.17'])
def unreleased = bwc.unreleased.collectEntries { [it, bwc.unreleasedInfo(it)] }
then:
unreleased == [
(v('8.15.2')): new UnreleasedVersionInfo(v('8.15.2'), '8.15', ':distribution:bwc:bugfix2'),
(v('8.16.1')): new UnreleasedVersionInfo(v('8.16.1'), '8.16', ':distribution:bwc:bugfix'),
(v('8.17.0')): new UnreleasedVersionInfo(v('8.17.0'), '8.x', ':distribution:bwc:minor'),
(v('9.0.0')): new UnreleasedVersionInfo(v('9.0.0'), 'main', ':distribution'),
@ -129,8 +46,9 @@ class BwcVersionsSpec extends Specification {
bwc.indexCompatible == [v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2'), v('8.16.0'), v('8.16.1'), v('8.17.0'), v('9.0.0')]
}
def "current version is major with staged next minor"() {
def "current version is next major with staged minor"() {
given:
addVersion('7.17.10', '8.9.0')
addVersion('8.14.0', '9.9.0')
addVersion('8.14.1', '9.9.0')
addVersion('8.14.2', '9.9.0')
@ -138,80 +56,218 @@ class BwcVersionsSpec extends Specification {
addVersion('8.15.1', '9.9.0')
addVersion('8.15.2', '9.9.0')
addVersion('8.16.0', '9.10.0')
addVersion('8.16.1', '9.10.0')
addVersion('8.17.0', '9.10.0')
addVersion('8.18.0', '9.10.0')
addVersion('9.0.0', '10.0.0')
when:
def bwc = new BwcVersions(versionLines, v('9.0.0'))
def bwc = new BwcVersions(versionLines, v('9.0.0'), ['main', '8.x', '8.17', '8.16', '8.15', '7.17'])
def unreleased = bwc.unreleased.collectEntries { [it, bwc.unreleasedInfo(it)] }
then:
unreleased == [
(v('8.15.2')): new UnreleasedVersionInfo(v('8.15.2'), '8.15', ':distribution:bwc:bugfix'),
(v('8.16.0')): new UnreleasedVersionInfo(v('8.16.0'), '8.16', ':distribution:bwc:staged'),
(v('8.17.0')): new UnreleasedVersionInfo(v('8.17.0'), '8.x', ':distribution:bwc:minor'),
(v('8.15.2')): new UnreleasedVersionInfo(v('8.15.2'), '8.15', ':distribution:bwc:bugfix2'),
(v('8.16.1')): new UnreleasedVersionInfo(v('8.16.1'), '8.16', ':distribution:bwc:bugfix'),
(v('8.17.0')): new UnreleasedVersionInfo(v('8.17.0'), '8.17', ':distribution:bwc:staged'),
(v('8.18.0')): new UnreleasedVersionInfo(v('8.18.0'), '8.x', ':distribution:bwc:minor'),
(v('9.0.0')): new UnreleasedVersionInfo(v('9.0.0'), 'main', ':distribution'),
]
bwc.wireCompatible == [v('8.17.0'), v('9.0.0')]
bwc.indexCompatible == [v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2'), v('8.16.0'), v('8.17.0'), v('9.0.0')]
bwc.wireCompatible == [v('8.18.0'), v('9.0.0')]
bwc.indexCompatible == [v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2'), v('8.16.0'), v('8.16.1'), v('8.17.0'), v('8.18.0'), v('9.0.0')]
}
def "current version is next bugfix"() {
def "current version is first new minor in major series"() {
given:
addVersion('8.14.0', '9.9.0')
addVersion('8.14.1', '9.9.0')
addVersion('8.14.2', '9.9.0')
addVersion('8.15.0', '9.9.0')
addVersion('8.15.1', '9.9.0')
addVersion('8.15.2', '9.9.0')
addVersion('7.17.10', '8.9.0')
addVersion('8.16.0', '9.10.0')
addVersion('8.16.1', '9.10.0')
addVersion('8.17.0', '9.10.0')
addVersion('8.17.1', '9.10.0')
addVersion('8.18.0', '9.10.0')
addVersion('9.0.0', '10.0.0')
addVersion('9.0.1', '10.0.0')
addVersion('9.1.0', '10.0.0')
when:
def bwc = new BwcVersions(versionLines, v('9.0.1'))
def bwc = new BwcVersions(versionLines, v('9.1.0'), ['main', '9.0', '8.18'])
def unreleased = bwc.unreleased.collectEntries { [it, bwc.unreleasedInfo(it)] }
then:
unreleased == [
(v('8.17.1')): new UnreleasedVersionInfo(v('8.17.1'), '8.17', ':distribution:bwc:maintenance'),
(v('9.0.1')): new UnreleasedVersionInfo(v('9.0.1'), 'main', ':distribution'),
(v('8.18.0')): new UnreleasedVersionInfo(v('8.18.0'), '8.18', ':distribution:bwc:maintenance'),
(v('9.0.0')): new UnreleasedVersionInfo(v('9.0.0'), '9.0', ':distribution:bwc:staged'),
(v('9.1.0')): new UnreleasedVersionInfo(v('9.1.0'), 'main', ':distribution'),
]
bwc.wireCompatible == [v('8.17.0'), v('8.17.1'), v('9.0.0'), v('9.0.1')]
bwc.indexCompatible == [v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2'), v('8.16.0'), v('8.16.1'), v('8.17.0'), v('8.17.1'), v('9.0.0'), v('9.0.1')]
bwc.wireCompatible == [v('8.18.0'), v('9.0.0'), v('9.1.0')]
bwc.indexCompatible == [v('8.16.0'), v('8.16.1'), v('8.17.0'), v('8.18.0'), v('9.0.0'), v('9.1.0')]
}
def "current version is next minor with no staged releases"() {
def "current version is new minor with single bugfix"() {
given:
addVersion('8.14.0', '9.9.0')
addVersion('8.14.1', '9.9.0')
addVersion('8.14.2', '9.9.0')
addVersion('8.15.0', '9.9.0')
addVersion('8.15.1', '9.9.0')
addVersion('8.15.2', '9.9.0')
addVersion('7.17.10', '8.9.0')
addVersion('8.16.0', '9.10.0')
addVersion('8.16.1', '9.10.0')
addVersion('8.17.0', '9.10.0')
addVersion('8.17.1', '9.10.0')
addVersion('8.18.0', '9.10.0')
addVersion('9.0.0', '10.0.0')
addVersion('9.0.1', '10.0.0')
addVersion('9.1.0', '10.1.0')
addVersion('9.1.0', '10.0.0')
when:
def bwc = new BwcVersions(versionLines, v('9.1.0'))
def bwc = new BwcVersions(versionLines, v('9.1.0'), ['main', '9.0', '8.18'])
def unreleased = bwc.unreleased.collectEntries { [it, bwc.unreleasedInfo(it)] }
then:
unreleased == [
(v('8.17.1')): new UnreleasedVersionInfo(v('8.17.1'), '8.17', ':distribution:bwc:maintenance'),
(v('8.18.0')): new UnreleasedVersionInfo(v('8.18.0'), '8.18', ':distribution:bwc:maintenance'),
(v('9.0.1')): new UnreleasedVersionInfo(v('9.0.1'), '9.0', ':distribution:bwc:bugfix'),
(v('9.1.0')): new UnreleasedVersionInfo(v('9.1.0'), 'main', ':distribution')
(v('9.1.0')): new UnreleasedVersionInfo(v('9.1.0'), 'main', ':distribution'),
]
bwc.wireCompatible == [v('8.17.0'), v('8.17.1'), v('9.0.0'), v('9.0.1'), v('9.1.0')]
bwc.indexCompatible == [v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2'), v('8.16.0'), v('8.16.1'), v('8.17.0'), v('8.17.1'), v('9.0.0'), v('9.0.1'), v('9.1.0')]
bwc.wireCompatible == [v('8.18.0'), v('9.0.0'), v('9.0.1'), v('9.1.0')]
bwc.indexCompatible == [v('8.16.0'), v('8.16.1'), v('8.17.0'), v('8.18.0'), v('9.0.0'), v('9.0.1'), v('9.1.0')]
}
def "current version is new minor with single bugfix and staged minor"() {
given:
addVersion('7.17.10', '8.9.0')
addVersion('8.16.0', '9.10.0')
addVersion('8.16.1', '9.10.0')
addVersion('8.17.0', '9.10.0')
addVersion('8.18.0', '9.10.0')
addVersion('9.0.0', '10.0.0')
addVersion('9.0.1', '10.0.0')
addVersion('9.1.0', '10.0.0')
addVersion('9.2.0', '10.0.0')
when:
def bwc = new BwcVersions(versionLines, v('9.2.0'), ['main', '9.1', '9.0', '8.18'])
def unreleased = bwc.unreleased.collectEntries { [it, bwc.unreleasedInfo(it)] }
then:
unreleased == [
(v('8.18.0')): new UnreleasedVersionInfo(v('8.18.0'), '8.18', ':distribution:bwc:maintenance'),
(v('9.0.1')): new UnreleasedVersionInfo(v('9.0.1'), '9.0', ':distribution:bwc:bugfix'),
(v('9.1.0')): new UnreleasedVersionInfo(v('9.1.0'), '9.1', ':distribution:bwc:staged'),
(v('9.2.0')): new UnreleasedVersionInfo(v('9.2.0'), 'main', ':distribution'),
]
bwc.wireCompatible == [v('8.18.0'), v('9.0.0'), v('9.0.1'), v('9.1.0'), v('9.2.0')]
bwc.indexCompatible == [v('8.16.0'), v('8.16.1'), v('8.17.0'), v('8.18.0'), v('9.0.0'), v('9.0.1'), v('9.1.0'), v('9.2.0')]
}
def "current version is next minor"() {
given:
addVersion('7.16.3', '8.9.0')
addVersion('7.17.0', '8.9.0')
addVersion('7.17.1', '8.9.0')
addVersion('8.14.0', '9.9.0')
addVersion('8.14.1', '9.9.0')
addVersion('8.14.2', '9.9.0')
addVersion('8.15.0', '9.9.0')
addVersion('8.15.1', '9.9.0')
addVersion('8.15.2', '9.9.0')
addVersion('8.16.0', '9.10.0')
addVersion('8.16.1', '9.10.0')
addVersion('8.17.0', '9.10.0')
addVersion('8.17.1', '9.10.0')
addVersion('8.18.0', '9.10.0')
when:
def bwc = new BwcVersions(versionLines, v('8.18.0'), ['main', '8.x', '8.17', '8.16', '7.17'])
def unreleased = bwc.unreleased.collectEntries { [it, bwc.unreleasedInfo(it)] }
then:
unreleased == [
(v('7.17.1')): new UnreleasedVersionInfo(v('7.17.1'), '7.17', ':distribution:bwc:maintenance'),
(v('8.16.1')): new UnreleasedVersionInfo(v('8.16.1'), '8.16', ':distribution:bwc:bugfix2'),
(v('8.17.1')): new UnreleasedVersionInfo(v('8.17.1'), '8.17', ':distribution:bwc:bugfix'),
(v('8.18.0')): new UnreleasedVersionInfo(v('8.18.0'), '8.x', ':distribution'),
]
bwc.wireCompatible == [v('7.17.0'), v('7.17.1'), v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2'), v('8.16.0'), v('8.16.1'), v('8.17.0'), v('8.17.1'), v('8.18.0')]
bwc.indexCompatible == [v('7.16.3'), v('7.17.0'), v('7.17.1'), v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2'), v('8.16.0'), v('8.16.1'), v('8.17.0'), v('8.17.1'), v('8.18.0')]
}
def "current version is new minor with staged minor"() {
given:
addVersion('7.16.3', '8.9.0')
addVersion('7.17.0', '8.9.0')
addVersion('7.17.1', '8.9.0')
addVersion('8.14.0', '9.9.0')
addVersion('8.14.1', '9.9.0')
addVersion('8.14.2', '9.9.0')
addVersion('8.15.0', '9.9.0')
addVersion('8.15.1', '9.9.0')
addVersion('8.15.2', '9.9.0')
addVersion('8.16.0', '9.10.0')
addVersion('8.16.1', '9.10.0')
addVersion('8.17.0', '9.10.0')
addVersion('8.18.0', '9.10.0')
when:
def bwc = new BwcVersions(versionLines, v('8.18.0'), ['main', '8.x', '8.17', '8.16', '8.15', '7.17'])
def unreleased = bwc.unreleased.collectEntries { [it, bwc.unreleasedInfo(it)] }
then:
unreleased == [
(v('7.17.1')): new UnreleasedVersionInfo(v('7.17.1'), '7.17', ':distribution:bwc:maintenance'),
(v('8.15.2')): new UnreleasedVersionInfo(v('8.15.2'), '8.15', ':distribution:bwc:bugfix2'),
(v('8.16.1')): new UnreleasedVersionInfo(v('8.16.1'), '8.16', ':distribution:bwc:bugfix'),
(v('8.17.0')): new UnreleasedVersionInfo(v('8.17.0'), '8.17', ':distribution:bwc:staged'),
(v('8.18.0')): new UnreleasedVersionInfo(v('8.18.0'), '8.x', ':distribution'),
]
bwc.wireCompatible == [v('7.17.0'), v('7.17.1'), v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2'), v('8.16.0'), v('8.16.1'), v('8.17.0'), v('8.18.0')]
bwc.indexCompatible == [v('7.16.3'), v('7.17.0'), v('7.17.1'), v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2'), v('8.16.0'), v('8.16.1'), v('8.17.0'), v('8.18.0')]
}
def "current version is first bugfix"() {
given:
addVersion('7.16.3', '8.9.0')
addVersion('7.17.0', '8.9.0')
addVersion('7.17.1', '8.9.0')
addVersion('8.14.0', '9.9.0')
addVersion('8.14.1', '9.9.0')
addVersion('8.14.2', '9.9.0')
addVersion('8.15.0', '9.9.0')
addVersion('8.15.1', '9.9.0')
addVersion('8.15.2', '9.9.0')
addVersion('8.16.0', '9.10.0')
addVersion('8.16.1', '9.10.0')
when:
def bwc = new BwcVersions(versionLines, v('8.16.1'), ['main', '8.x', '8.17', '8.16', '8.15', '7.17'])
def unreleased = bwc.unreleased.collectEntries { [it, bwc.unreleasedInfo(it)] }
then:
unreleased == [
(v('7.17.1')): new UnreleasedVersionInfo(v('7.17.1'), '7.17', ':distribution:bwc:maintenance'),
(v('8.15.2')): new UnreleasedVersionInfo(v('8.15.2'), '8.15', ':distribution:bwc:bugfix'),
(v('8.16.1')): new UnreleasedVersionInfo(v('8.16.1'), '8.16', ':distribution'),
]
bwc.wireCompatible == [v('7.17.0'), v('7.17.1'), v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2'), v('8.16.0'), v('8.16.1')]
bwc.indexCompatible == [v('7.16.3'), v('7.17.0'), v('7.17.1'), v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2'), v('8.16.0'), v('8.16.1')]
}
def "current version is second bugfix"() {
given:
addVersion('7.16.3', '8.9.0')
addVersion('7.17.0', '8.9.0')
addVersion('7.17.1', '8.9.0')
addVersion('8.14.0', '9.9.0')
addVersion('8.14.1', '9.9.0')
addVersion('8.14.2', '9.9.0')
addVersion('8.15.0', '9.9.0')
addVersion('8.15.1', '9.9.0')
addVersion('8.15.2', '9.9.0')
when:
def bwc = new BwcVersions(versionLines, v('8.15.2'), ['main', '8.x', '8.17', '8.16', '8.15', '7.17'])
def unreleased = bwc.unreleased.collectEntries { [it, bwc.unreleasedInfo(it)] }
then:
unreleased == [
(v('7.17.1')): new UnreleasedVersionInfo(v('7.17.1'), '7.17', ':distribution:bwc:maintenance'),
(v('8.15.2')): new UnreleasedVersionInfo(v('8.15.2'), '8.15', ':distribution'),
]
bwc.wireCompatible == [v('7.17.0'), v('7.17.1'), v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2')]
bwc.indexCompatible == [v('7.16.3'), v('7.17.0'), v('7.17.1'), v('8.14.0'), v('8.14.1'), v('8.14.2'), v('8.15.0'), v('8.15.1'), v('8.15.2')]
}
private void addVersion(String elasticsearch, String lucene) {

View File

@ -16,6 +16,7 @@ import org.gradle.testfixtures.ProjectBuilder;
import java.io.File;
import java.util.Arrays;
import java.util.List;
public class AbstractDistributionDownloadPluginTests {
protected static Project rootProject;
@ -28,22 +29,27 @@ public class AbstractDistributionDownloadPluginTests {
protected static final Version BWC_STAGED_VERSION = Version.fromString("1.0.0");
protected static final Version BWC_BUGFIX_VERSION = Version.fromString("1.0.1");
protected static final Version BWC_MAINTENANCE_VERSION = Version.fromString("0.90.1");
protected static final List<String> DEVELOPMENT_BRANCHES = Arrays.asList("main", "1.1", "1.0", "0.90");
protected static final BwcVersions BWC_MINOR = new BwcVersions(
BWC_MAJOR_VERSION,
Arrays.asList(BWC_BUGFIX_VERSION, BWC_MINOR_VERSION, BWC_MAJOR_VERSION)
Arrays.asList(BWC_BUGFIX_VERSION, BWC_MINOR_VERSION, BWC_MAJOR_VERSION),
DEVELOPMENT_BRANCHES
);
protected static final BwcVersions BWC_STAGED = new BwcVersions(
BWC_MAJOR_VERSION,
Arrays.asList(BWC_MAINTENANCE_VERSION, BWC_STAGED_VERSION, BWC_MINOR_VERSION, BWC_MAJOR_VERSION)
Arrays.asList(BWC_MAINTENANCE_VERSION, BWC_STAGED_VERSION, BWC_MINOR_VERSION, BWC_MAJOR_VERSION),
DEVELOPMENT_BRANCHES
);
protected static final BwcVersions BWC_BUGFIX = new BwcVersions(
BWC_MAJOR_VERSION,
Arrays.asList(BWC_BUGFIX_VERSION, BWC_MINOR_VERSION, BWC_MAJOR_VERSION)
Arrays.asList(BWC_BUGFIX_VERSION, BWC_MINOR_VERSION, BWC_MAJOR_VERSION),
DEVELOPMENT_BRANCHES
);
protected static final BwcVersions BWC_MAINTENANCE = new BwcVersions(
BWC_MINOR_VERSION,
Arrays.asList(BWC_MAINTENANCE_VERSION, BWC_BUGFIX_VERSION, BWC_MINOR_VERSION)
Arrays.asList(BWC_MAINTENANCE_VERSION, BWC_BUGFIX_VERSION, BWC_MINOR_VERSION),
DEVELOPMENT_BRANCHES
);
protected static String projectName(String base, boolean bundledJdk) {

View File

@ -156,12 +156,12 @@ abstract class AbstractGradleFuncTest extends Specification {
File internalBuild(
List<String> extraPlugins = [],
String bugfix = "7.15.2",
String bugfixLucene = "8.9.0",
String staged = "7.16.0",
String stagedLucene = "8.10.0",
String minor = "8.0.0",
String minorLucene = "9.0.0"
String maintenance = "7.16.10",
String bugfix2 = "8.1.3",
String bugfix = "8.2.1",
String staged = "8.3.0",
String minor = "8.4.0",
String current = "9.0.0"
) {
buildFile << """plugins {
id 'elasticsearch.global-build-info'
@ -172,15 +172,17 @@ abstract class AbstractGradleFuncTest extends Specification {
import org.elasticsearch.gradle.internal.BwcVersions
import org.elasticsearch.gradle.Version
Version currentVersion = Version.fromString("8.1.0")
Version currentVersion = Version.fromString("${current}")
def versionList = [
Version.fromString("$maintenance"),
Version.fromString("$bugfix2"),
Version.fromString("$bugfix"),
Version.fromString("$staged"),
Version.fromString("$minor"),
currentVersion
]
BwcVersions versions = new BwcVersions(currentVersion, versionList)
BwcVersions versions = new BwcVersions(currentVersion, versionList, ['main', '8.x', '8.3', '8.2', '8.1', '7.16'])
buildParams.getBwcVersionsProperty().set(versions)
"""
}

View File

View File

@ -73,6 +73,7 @@ List projects = [
'distribution:packages:aarch64-rpm',
'distribution:packages:rpm',
'distribution:bwc:bugfix',
'distribution:bwc:bugfix2',
'distribution:bwc:maintenance',
'distribution:bwc:minor',
'distribution:bwc:staged',