Only track released versions in `oldVersions`. (#13096)

This commit is contained in:
Adrien Grand 2024-02-13 10:48:30 +01:00 committed by GitHub
parent f6e065dc31
commit d7e0a7f0e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 45 additions and 10 deletions

View File

@ -27,6 +27,7 @@ import java.nio.file.Paths;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;
@ -61,8 +62,7 @@ public abstract class BackwardsCompatibilityTestBase extends LuceneTestCase {
"8.7.0", "8.7.0", "8.8.0", "8.8.0", "8.8.1", "8.8.1", "8.8.2", "8.8.2", "8.9.0", "8.9.0",
"8.10.0", "8.10.0", "8.10.1", "8.10.1", "8.11.0", "8.11.0", "8.11.1", "8.11.1", "8.11.2",
"8.11.2", "8.11.3", "8.11.3", "9.0.0", "9.1.0", "9.2.0", "9.3.0", "9.4.0", "9.4.1",
"9.4.2", "9.5.0", "9.6.0", "9.7.0", "9.8.0", "9.9.0", "9.9.1", "9.9.2", "9.10.0",
"10.0.0",
"9.4.2", "9.5.0", "9.6.0", "9.7.0", "9.8.0", "9.9.0", "9.9.1", "9.9.2"
};
Set<Version> binaryVersions = new HashSet<>();
@ -75,8 +75,8 @@ public abstract class BackwardsCompatibilityTestBase extends LuceneTestCase {
throw new RuntimeException(ex);
}
}
List<Version> allCurrentVersions = getAllCurrentVersions();
for (Version version : allCurrentVersions) {
for (Version version : getAllCurrentReleasedVersions()) {
// make sure we never miss a version.
assertTrue("Version: " + version + " missing", binaryVersions.remove(version));
}
@ -181,19 +181,54 @@ public abstract class BackwardsCompatibilityTestBase extends LuceneTestCase {
return versions;
}
private static List<Version> getAllCurrentReleasedVersions() {
List<Version> currentReleasedVersions = getAllCurrentVersions();
// The latest version from the current major is always under development.
assertTrue(currentReleasedVersions.remove(Version.LATEST));
if (Version.LATEST.minor == 0 && Version.LATEST.bugfix == 0) {
// If the current branch points to the next major, then the latest minor from the previous
// major is also under development.
assertTrue(currentReleasedVersions.remove(LATEST_PREVIOUS_MAJOR));
}
// In addition to those, we may need to remove one more version in case a release is in
// progress, and the version constant has been added but backward-compatibility indexes have not
// been checked in yet.
List<Version> missingVersions = new ArrayList<>();
for (Iterator<Version> it = currentReleasedVersions.iterator(); it.hasNext(); ) {
Version version = it.next();
String indexName = String.format(Locale.ROOT, "index.%s-cfs.zip", version);
if (TestAncientIndicesCompatibility.class.getResource(indexName) == null) {
missingVersions.add(version);
it.remove();
}
}
if (missingVersions.size() > 1) {
throw new AssertionError(
"More than one version is missing backward-compatibility data: " + missingVersions);
}
return currentReleasedVersions;
}
/** Get all versions that are released, plus the latest version which is unreleased. */
public static List<Version> getAllCurrentReleasedVersionsAndCurrent() {
List<Version> versions = new ArrayList<>(getAllCurrentReleasedVersions());
versions.add(Version.LATEST);
return versions;
}
public static Iterable<Object[]> allVersion(String name, String... suffixes) {
List<Object> patterns = new ArrayList<>();
for (String suffix : suffixes) {
patterns.add(createPattern(name, suffix));
}
List<Object[]> versionAndPatterns = new ArrayList<>();
List<Version> versionList = getAllCurrentVersions();
List<Version> versionList = getAllCurrentReleasedVersionsAndCurrent();
for (Version v : versionList) {
if (v.equals(LATEST_PREVIOUS_MAJOR)
== false) { // the latest prev-major has not yet been released
for (Object p : patterns) {
versionAndPatterns.add(new Object[] {v, p});
}
for (Object p : patterns) {
versionAndPatterns.add(new Object[] {v, p});
}
}
return versionAndPatterns;