From 07e00b4ffb54a845c087a1662abee65c9c23436b Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Tue, 23 Sep 2014 20:47:14 +0000 Subject: [PATCH] LUCENE-5974: Add check that backcompat indexes use default codecs git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1627158 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 3 +++ .../index/TestBackwardsCompatibility.java | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+) 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);