Apache Solr open-source search software
LUCENE-5974: Add check that backcompat indexes use default codecs
Ryan Ernst07e00b4ffb54
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 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<Integer>, todiff --git a/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java b/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.javaindex 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 testsTestUtil.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);