s1monw commented on a change in pull request #2212:
URL: https://github.com/apache/lucene-solr/pull/2212#discussion_r559253990
##########
File path:
lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestBackwardsCompatibility.java
##########
@@ -1986,4 +1988,45 @@ static BytesRef toBytes(long value) {
bytes.bytes[bytes.length++] = (byte) value;
return bytes;
}
+
+ public void testFailOpenOldIndex() throws IOException {
+ for (String name : oldNames) {
+ Directory directory = oldIndexDirs.get(name);
+ IndexCommit commit = DirectoryReader.listCommits(directory).get(0);
+ IndexFormatTooOldException ex =
+ expectThrows(
+ IndexFormatTooOldException.class,
+ () -> StandardDirectoryReader.open(commit,
Version.LATEST.major));
+ assertTrue(
+ ex.getMessage()
+ .contains(
+ "only supports reading from version " + Version.LATEST.major
+ " upwards."));
+ // now open with allowed min version
+ StandardDirectoryReader.open(commit, Version.LATEST.major - 1).close();
+ }
+ }
+
+ public void testReadNMinusTwoCommit() throws IOException {
+ for (String name : this.unsupportedNames) {
+ if (name.startsWith(Version.MIN_SUPPORTED_MAJOR - 1 + ".")) {
+ Path oldIndexDir = createTempDir(name);
+ TestUtil.unzip(getDataInputStream("unsupported." + name + ".zip"),
oldIndexDir);
+ try (BaseDirectoryWrapper dir = newFSDirectory(oldIndexDir)) {
+ // don't checkindex, we don't have the codecs yet
+ dir.setCheckIndexOnClose(false);
+ IllegalArgumentException iae =
+ expectThrows(IllegalArgumentException.class, () ->
DirectoryReader.listCommits(dir));
+ // TODO fix this once we have the codec for 7.0 recreated
+ assertEquals(
+ "Could not load codec 'Lucene70'. Did you forget to add
lucene-backward-codecs.jar?",
Review comment:
it seems like we only had `LUCENE70` in this release
https://github.com/apache/lucene-solr/tree/branch_8x/lucene/backward-codecs/src/java/org/apache/lucene/codecs
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]