|
@@ -199,23 +199,20 @@ public class IndexVersionTests extends ESTestCase {
|
|
|
|
|
|
public void testLuceneVersionOnUnknownVersions() {
|
|
|
// between two known versions, should use the lucene version of the previous version
|
|
|
- IndexVersion version = IndexVersionUtils.getPreviousVersion();
|
|
|
- final IndexVersion nextVersion = IndexVersion.fromId(version.id() + 100);
|
|
|
- if (IndexVersionUtils.allReleasedVersions().contains(nextVersion) == false) {
|
|
|
- // the version is not known, we make an assumption the Lucene version stays the same
|
|
|
- assertThat(version.luceneVersion(), equalTo(nextVersion.luceneVersion()));
|
|
|
- } else {
|
|
|
- // the version is known, the most we can assert is that the Lucene version is not earlier
|
|
|
- // Version does not implement Comparable :(
|
|
|
- assertTrue(nextVersion.luceneVersion().onOrAfter(version.luceneVersion()));
|
|
|
- }
|
|
|
+ IndexVersion previousVersion = IndexVersionUtils.getPreviousVersion();
|
|
|
+ IndexVersion currentVersion = IndexVersion.current();
|
|
|
+ int intermediateVersionId = previousVersion.id() + randomInt(currentVersion.id() - previousVersion.id() - 1);
|
|
|
+ IndexVersion intermediateVersion = IndexVersion.fromId(intermediateVersionId);
|
|
|
+ // the version is either the previous version or between the previous version and the current version excluded, so it is assumed to
|
|
|
+ // use the same Lucene version as the previous version
|
|
|
+ assertThat(intermediateVersion.luceneVersion(), equalTo(previousVersion.luceneVersion()));
|
|
|
|
|
|
// too old version, major should be the oldest supported lucene version minus 1
|
|
|
- version = IndexVersion.fromId(5020199);
|
|
|
- assertThat(version.luceneVersion().major, equalTo(IndexVersionUtils.getFirstVersion().luceneVersion().major - 1));
|
|
|
+ IndexVersion oldVersion = IndexVersion.fromId(5020199);
|
|
|
+ assertThat(oldVersion.luceneVersion().major, equalTo(IndexVersionUtils.getFirstVersion().luceneVersion().major - 1));
|
|
|
|
|
|
// future version, should be the same version as today
|
|
|
- version = IndexVersion.fromId(IndexVersion.current().id() + 100);
|
|
|
- assertThat(version.luceneVersion(), equalTo(IndexVersion.current().luceneVersion()));
|
|
|
+ IndexVersion futureVersion = IndexVersion.fromId(currentVersion.id() + 100);
|
|
|
+ assertThat(futureVersion.luceneVersion(), equalTo(currentVersion.luceneVersion()));
|
|
|
}
|
|
|
}
|