Skip to content

Commit

Permalink
Update the index version compatible test to only check the minimum (e…
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoop authored Jan 23, 2025
1 parent eae93a2 commit 787a16d
Showing 1 changed file with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package org.elasticsearch.test.index;

import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.test.ESTestCase;

Expand All @@ -19,26 +18,19 @@
import java.util.List;
import java.util.Set;

import static org.hamcrest.Matchers.equalTo;

public class IndexVersionUtilsTests extends ESTestCase {
/**
* Tests that {@link IndexVersions#MINIMUM_COMPATIBLE} and {@link IndexVersionUtils#allReleasedVersions()}
* agree with the list of index compatible versions we build in gradle.
* agree on the minimum version that should be tested.
*/
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/98054")
public void testGradleVersionsMatchVersionUtils() {
public void testIndexCompatibleVersionMatches() {
VersionsFromProperty indexCompatible = new VersionsFromProperty("tests.gradle_index_compat_versions");
List<IndexVersion> released = IndexVersionUtils.allReleasedVersions()
.stream()
/* Java lists all versions from the 5.x series onwards, but we only want to consider
* ones that we're supposed to be compatible with. */
.filter(v -> v.onOrAfter(IndexVersions.MINIMUM_COMPATIBLE))
.toList();

List<String> releasedIndexCompatible = released.stream()
.filter(v -> IndexVersion.current().equals(v) == false)
.map(Object::toString)
.toList();
assertEquals(releasedIndexCompatible, indexCompatible.released);
String minIndexVersion = IndexVersions.MINIMUM_COMPATIBLE.toReleaseVersion();
String lowestCompatibleVersion = indexCompatible.released.get(0);
assertThat(lowestCompatibleVersion, equalTo(minIndexVersion));
}

/**
Expand Down

0 comments on commit 787a16d

Please sign in to comment.