diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 191b7f239fc..76c29147938 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -179,6 +179,9 @@ Tests * LUCENE-5957: Add option for tests to not randomize codec (Ryan Ernst) +* LUCENE-5974: Add check that backcompat indexes use default codecs + (Ryan Ernst) + Optimizations * LUCENE-5960: Use a more efficient bitset, not a Set, to diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java b/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java index cb8fc196b3c..e6c19ca3de4 100644 --- a/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java +++ b/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java @@ -1002,6 +1002,24 @@ public class TestBackwardsCompatibility extends LuceneTestCase { r.close(); } } + + public void verifyUsesDefaultCodec(Directory dir, String name) throws Exception { + DirectoryReader r = DirectoryReader.open(dir); + for (AtomicReaderContext context : r.leaves()) { + SegmentReader air = (SegmentReader) context.reader(); + Codec codec = air.getSegmentInfo().info.getCodec(); + assertTrue("codec used in " + name + " (" + codec.getName() + ") is not a default codec (does not begin with Lucene)", + codec.getName().startsWith("Lucene")); + } + r.close(); + } + + public void testAllIndexesUseDefaultCodec() throws Exception { + for (String name : oldNames) { + Directory dir = oldIndexDirs.get(name); + verifyUsesDefaultCodec(dir, name); + } + } public void testNumericFields() throws Exception { for (String name : oldNames) { @@ -1203,6 +1221,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase { Path oldIndexDir = createTempDir("moreterms"); TestUtil.unzip(getDataInputStream(moreTermsIndex), oldIndexDir); Directory dir = newFSDirectory(oldIndexDir); + verifyUsesDefaultCodec(dir, moreTermsIndex); // TODO: more tests TestUtil.checkIndex(dir); dir.close(); @@ -1242,6 +1261,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase { Path oldIndexDir = createTempDir("dvupdates"); TestUtil.unzip(getDataInputStream(dvUpdatesIndex), oldIndexDir); Directory dir = newFSDirectory(oldIndexDir); + verifyUsesDefaultCodec(dir, dvUpdatesIndex); verifyDocValues(dir);