Apache Solr open-source search software
improve tests
Robert Muiraf59f5bf5641
diff --git a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.javaindex ea3ef07a51d..f151cc59488 100644--- a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java+++ b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java@@ -769,7 +769,7 @@ public class CheckIndex {break;}- checkBounds(term);+ assert term.isValid();// make sure terms arrive in order according to// the comp@@ -859,7 +859,7 @@ public class CheckIndex {lastPos = pos;BytesRef payload = postings.getPayload();if (payload != null) {- checkBounds(payload);+ assert payload.isValid();}if (payload != null && payload.length < 1) {throw new RuntimeException("term " + term + ": doc " + doc + ": pos " + pos + " payload length is out of bounds " + payload.length);@@ -1296,32 +1296,7 @@ public class CheckIndex {BytesRef scratch = new BytesRef();for (int i = 0; i < reader.maxDoc(); i++) {dv.get(i, scratch);- checkBounds(scratch);- }- }-- // basic value checks- private static void checkBounds(BytesRef b) {- if (b.bytes == null) {- throw new RuntimeException("bytes is null");- }- if (b.length < 0) {- throw new RuntimeException("length is negative: " + b.length);- }- if (b.length > b.bytes.length) {- throw new RuntimeException("length is out of bounds: " + b.length + ", bytes.length=" + b.bytes.length);- }- if (b.offset < 0) {- throw new RuntimeException("offset is negative: " + b.offset);- }- if (b.offset > b.bytes.length) {- throw new RuntimeException("offset out of bounds: " + b.offset + ", length=" + b.length);- }- if (b.offset + b.length < 0) {- throw new RuntimeException("offset+length is negative: offset=" + b.offset + ",length=" + b.length);- }- if (b.offset + b.length > b.bytes.length) {- throw new RuntimeException("offset+length out of bounds: offset=" + b.offset + ",length=" + b.length + ",bytes.length=" + b.bytes.length);+ assert scratch.isValid();}}@@ -1348,7 +1323,7 @@ public class CheckIndex {BytesRef scratch = new BytesRef();for (int i = 0; i <= maxOrd; i++) {dv.lookupOrd(i, scratch);- checkBounds(scratch);+ assert scratch.isValid();if (lastValue != null) {if (scratch.compareTo(lastValue) <= 0) {throw new RuntimeException("dv for field: " + fieldName + " has ords out of order: " + lastValue + " >=" + scratch);diff --git a/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java b/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.javaindex 39d2cfe941a..5b72f3dbe8e 100644--- a/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java+++ b/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java@@ -100,13 +100,11 @@ public final class SlowCompositeReaderWrapper extends AtomicReader {@Overridepublic NumericDocValues getNormValues(String field) throws IOException {ensureOpen();- // nocommit hmmreturn MultiDocValues.getNormValues(in, field);}@Override- public Fields getTermVectors(int docID)- throws IOException {+ public Fields getTermVectors(int docID) throws IOException {ensureOpen();return in.getTermVectors(docID);}diff --git a/lucene/core/src/java/org/apache/lucene/util/BytesRef.java b/lucene/core/src/java/org/apache/lucene/util/BytesRef.javaindex 0d829462c4f..6cdcae29cdc 100644--- a/lucene/core/src/java/org/apache/lucene/util/BytesRef.java+++ b/lucene/core/src/java/org/apache/lucene/util/BytesRef.java@@ -52,13 +52,10 @@ public final class BytesRef implements Comparable<BytesRef>,Cloneable {* bytes should not be null.*/public BytesRef(byte[] bytes, int offset, int length) {- assert bytes != null;- assert offset >= 0;- assert length >= 0;- assert bytes.length >= offset + length;this.bytes = bytes;this.offset = offset;this.length = length;+ assert isValid();}/** This instance will directly reference bytes w/o making a copy.@@ -340,4 +337,34 @@ public final class BytesRef implements Comparable<BytesRef>,Cloneable {copy.copyBytes(other);return copy;}++ /**+ * Performs internal consistency checks.+ * Always returns true (or throws IllegalStateException)+ */+ // TODO: also for the other *Ref classes+ public boolean isValid() {+ if (bytes == null) {+ throw new IllegalStateException("bytes is null");+ }+ if (length < 0) {+ throw new IllegalStateException("length is negative: " + length);+ }+ if (length > bytes.length) {+ throw new IllegalStateException("length is out of bounds: " + length + ", bytes.length=" + bytes.length);+ }+ if (offset < 0) {+ throw new IllegalStateException("offset is negative: " + offset);+ }+ if (offset > bytes.length) {+ throw new IllegalStateException("offset out of bounds: " + offset + ", length=" + bytes.length);+ }+ if (offset + length < 0) {+ throw new IllegalStateException("offset+length is negative: offset=" + offset + ",length=" + length);+ }+ if (offset + length > bytes.length) {+ throw new IllegalStateException("offset+length out of bounds: offset=" + offset + ",length=" + length + ",bytes.length=" + bytes.length);+ }+ return true;+ }}diff --git a/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java b/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.javaindex 49652a94ffe..0d3186cf0c2 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java@@ -64,8 +64,6 @@ import org.junit.AfterClass;import org.junit.BeforeClass;import org.junit.Ignore;-// nocommit fails: ant test -Dtestcase=TestBackwardsCompatibility -Dtests.method=testExactFileNames -Dtests.seed=F5A14C72AFCA024E -Dtests.slow=true -Dtests.locale=pl_PL -Dtests.timezone=America/Argentina/La_Rioja -Dtests.file.encoding=ISO-8859-1-/*Verify we can read the pre-5.0 file format, do searchesagainst it, and add documents to it.diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java b/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.javaindex 78a2f00b8de..80e1d09f23f 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java@@ -1019,7 +1019,6 @@ public class TestDocValuesIndexing extends LuceneTestCase {}public void testDocValuesUnstored() throws IOException {- //nocommit convert!Directory dir = newDirectory();IndexWriterConfig iwconfig = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));iwconfig.setMergePolicy(newLogMergePolicy());diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingCodec.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingCodec.javaindex 05902c347d3..19cad74151f 100644--- a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingCodec.java+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingCodec.java@@ -17,7 +17,9 @@ package org.apache.lucene.codecs.asserting;* limitations under the License.*/+import org.apache.lucene.codecs.DocValuesFormat;import org.apache.lucene.codecs.FilterCodec;+import org.apache.lucene.codecs.NormsFormat;import org.apache.lucene.codecs.PostingsFormat;import org.apache.lucene.codecs.StoredFieldsFormat;import org.apache.lucene.codecs.TermVectorsFormat;@@ -31,6 +33,8 @@ public final class AssertingCodec extends FilterCodec {private final PostingsFormat postings = new AssertingPostingsFormat();private final TermVectorsFormat vectors = new AssertingTermVectorsFormat();private final StoredFieldsFormat storedFields = new AssertingStoredFieldsFormat();+ private final DocValuesFormat docValues = new AssertingDocValuesFormat();+ private final NormsFormat norms = new AssertingNormsFormat();public AssertingCodec() {super("Asserting", new Lucene42Codec());@@ -50,4 +54,14 @@ public final class AssertingCodec extends FilterCodec {public StoredFieldsFormat storedFieldsFormat() {return storedFields;}++ @Override+ public DocValuesFormat docValuesFormat() {+ return docValues;+ }++ @Override+ public NormsFormat normsFormat() {+ return norms;+ }}diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.javanew file mode 100644index 00000000000..69763518810--- /dev/null+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.java@@ -0,0 +1,169 @@+package org.apache.lucene.codecs.asserting;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import java.io.IOException;++import org.apache.lucene.codecs.DocValuesConsumer;+import org.apache.lucene.codecs.DocValuesFormat;+import org.apache.lucene.codecs.DocValuesProducer;+import org.apache.lucene.codecs.lucene42.Lucene42DocValuesFormat;+import org.apache.lucene.index.AssertingAtomicReader;+import org.apache.lucene.index.BinaryDocValues;+import org.apache.lucene.index.FieldInfo;+import org.apache.lucene.index.NumericDocValues;+import org.apache.lucene.index.SegmentReadState;+import org.apache.lucene.index.SegmentWriteState;+import org.apache.lucene.index.SortedDocValues;+import org.apache.lucene.util.BytesRef;+import org.apache.lucene.util.FixedBitSet;++/**+ * Just like {@link Lucene42DocValuesFormat} but with additional asserts.+ */+public class AssertingDocValuesFormat extends DocValuesFormat {+ private final DocValuesFormat in = new Lucene42DocValuesFormat();++ public AssertingDocValuesFormat() {+ super("Asserting");+ }++ @Override+ public DocValuesConsumer fieldsConsumer(SegmentWriteState state) throws IOException {+ DocValuesConsumer consumer = in.fieldsConsumer(state);+ assert consumer != null;+ return new AssertingDocValuesConsumer(consumer, state.segmentInfo.getDocCount());+ }++ @Override+ public DocValuesProducer fieldsProducer(SegmentReadState state) throws IOException {+ assert state.fieldInfos.hasDocValues();+ DocValuesProducer producer = in.fieldsProducer(state);+ assert producer != null;+ return new AssertingDocValuesProducer(producer, state.segmentInfo.getDocCount());+ }++ static class AssertingDocValuesConsumer extends DocValuesConsumer {+ private final DocValuesConsumer in;+ private final int maxDoc;++ AssertingDocValuesConsumer(DocValuesConsumer in, int maxDoc) {+ this.in = in;+ this.maxDoc = maxDoc;+ }++ @Override+ public void addNumericField(FieldInfo field, Iterable<Number> values) throws IOException {+ int count = 0;+ for (Number v : values) {+ assert v != null;+ count++;+ }+ assert count == maxDoc;+ in.addNumericField(field, values);+ }++ @Override+ public void addBinaryField(FieldInfo field, Iterable<BytesRef> values) throws IOException {+ int count = 0;+ for (BytesRef b : values) {+ assert b != null;+ assert b.isValid();+ count++;+ }+ assert count == maxDoc;+ in.addBinaryField(field, values);+ }++ @Override+ public void addSortedField(FieldInfo field, Iterable<BytesRef> values, Iterable<Number> docToOrd) throws IOException {+ int valueCount = 0;+ BytesRef lastValue = null;+ for (BytesRef b : values) {+ assert b != null;+ assert b.isValid();+ if (valueCount > 0) {+ assert b.compareTo(lastValue) > 0;+ }+ lastValue = BytesRef.deepCopyOf(b);+ valueCount++;+ }+ assert valueCount <= maxDoc;++ FixedBitSet seenOrds = new FixedBitSet(valueCount);++ int count = 0;+ for (Number v : docToOrd) {+ assert v != null;+ int ord = v.intValue();+ assert ord >= 0 && ord < valueCount;+ seenOrds.set(ord);+ count++;+ }++ assert count == maxDoc;+ assert seenOrds.cardinality() == valueCount;+ in.addSortedField(field, values, docToOrd);+ }++ @Override+ public void close() throws IOException {+ in.close();+ }+ }++ static class AssertingDocValuesProducer extends DocValuesProducer {+ private final DocValuesProducer in;+ private final int maxDoc;++ AssertingDocValuesProducer(DocValuesProducer in, int maxDoc) {+ this.in = in;+ this.maxDoc = maxDoc;+ }++ @Override+ public NumericDocValues getNumeric(FieldInfo field) throws IOException {+ assert field.getDocValuesType() == FieldInfo.DocValuesType.NUMERIC ||+ field.getNormType() == FieldInfo.DocValuesType.NUMERIC;+ NumericDocValues values = in.getNumeric(field);+ assert values != null;+ return new AssertingAtomicReader.AssertingNumericDocValues(values, maxDoc);+ }++ @Override+ public BinaryDocValues getBinary(FieldInfo field) throws IOException {+ assert field.getDocValuesType() == FieldInfo.DocValuesType.BINARY;+ BinaryDocValues values = in.getBinary(field);+ assert values != null;+ return new AssertingAtomicReader.AssertingBinaryDocValues(values, maxDoc);+ }++ @Override+ public SortedDocValues getSorted(FieldInfo field) throws IOException {+ assert field.getDocValuesType() == FieldInfo.DocValuesType.SORTED;+ SortedDocValues values = in.getSorted(field);+ assert values != null;+ return new AssertingAtomicReader.AssertingSortedDocValues(values, maxDoc);+ }++ @Override+ public void close() throws IOException {+ in.close();+ }+ }+}diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingNormsFormat.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingNormsFormat.javanew file mode 100644index 00000000000..8b64401b452--- /dev/null+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingNormsFormat.java@@ -0,0 +1,51 @@+package org.apache.lucene.codecs.asserting;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import java.io.IOException;++import org.apache.lucene.codecs.DocValuesConsumer;+import org.apache.lucene.codecs.DocValuesProducer;+import org.apache.lucene.codecs.NormsFormat;+import org.apache.lucene.codecs.asserting.AssertingDocValuesFormat.AssertingDocValuesConsumer;+import org.apache.lucene.codecs.asserting.AssertingDocValuesFormat.AssertingDocValuesProducer;+import org.apache.lucene.codecs.lucene42.Lucene42NormsFormat;+import org.apache.lucene.index.SegmentReadState;+import org.apache.lucene.index.SegmentWriteState;++/**+ * Just like {@link Lucene42NormsFormat} but with additional asserts.+ */+public class AssertingNormsFormat extends NormsFormat {+ private final NormsFormat in = new Lucene42NormsFormat();++ @Override+ public DocValuesConsumer normsConsumer(SegmentWriteState state) throws IOException {+ DocValuesConsumer consumer = in.normsConsumer(state);+ assert consumer != null;+ return new AssertingDocValuesConsumer(consumer, state.segmentInfo.getDocCount());+ }++ @Override+ public DocValuesProducer normsProducer(SegmentReadState state) throws IOException {+ assert state.fieldInfos.hasNorms();+ DocValuesProducer producer = in.normsProducer(state);+ assert producer != null;+ return new AssertingDocValuesProducer(producer, state.segmentInfo.getDocCount());+ }+}diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/AssertingAtomicReader.java b/lucene/test-framework/src/java/org/apache/lucene/index/AssertingAtomicReader.javaindex 3e705fb83d5..c8fe97d7a90 100644--- a/lucene/test-framework/src/java/org/apache/lucene/index/AssertingAtomicReader.java+++ b/lucene/test-framework/src/java/org/apache/lucene/index/AssertingAtomicReader.java@@ -86,6 +86,7 @@ public class AssertingAtomicReader extends FilterAtomicReader {public TermsEnum intersect(CompiledAutomaton automaton, BytesRef bytes) throws IOException {TermsEnum termsEnum = super.intersect(automaton, bytes);assert termsEnum != null;+ assert bytes == null || bytes.isValid();return new AssertingTermsEnum(termsEnum);}@@ -145,6 +146,7 @@ public class AssertingAtomicReader extends FilterAtomicReader {if (result == null) {state = State.UNPOSITIONED;} else {+ assert result.isValid();state = State.POSITIONED;}return result;@@ -171,7 +173,9 @@ public class AssertingAtomicReader extends FilterAtomicReader {@Overridepublic BytesRef term() throws IOException {assert state == State.POSITIONED : "term() called on unpositioned TermsEnum";- return super.term();+ BytesRef ret = super.term();+ assert ret == null || ret.isValid();+ return ret;}@Override@@ -182,6 +186,7 @@ public class AssertingAtomicReader extends FilterAtomicReader {@Overridepublic SeekStatus seekCeil(BytesRef term, boolean useCache) throws IOException {+ assert term.isValid();SeekStatus result = super.seekCeil(term, useCache);if (result == SeekStatus.END) {state = State.UNPOSITIONED;@@ -193,6 +198,7 @@ public class AssertingAtomicReader extends FilterAtomicReader {@Overridepublic boolean seekExact(BytesRef text, boolean useCache) throws IOException {+ assert text.isValid();if (super.seekExact(text, useCache)) {state = State.POSITIONED;return true;@@ -210,6 +216,7 @@ public class AssertingAtomicReader extends FilterAtomicReader {@Overridepublic void seekExact(BytesRef term, TermState state) throws IOException {+ assert term.isValid();super.seekExact(term, state);this.state = State.POSITIONED;}@@ -352,10 +359,158 @@ public class AssertingAtomicReader extends FilterAtomicReader {assert state != DocsEnumState.FINISHED : "getPayload() called after NO_MORE_DOCS";assert positionCount > 0 : "getPayload() called before nextPosition()!";BytesRef payload = super.getPayload();- assert payload == null || payload.length > 0 : "getPayload() returned payload with invalid length!";+ assert payload == null || payload.isValid() && payload.length > 0 : "getPayload() returned payload with invalid length!";return payload;}}++ /** Wraps a NumericDocValues but with additional asserts */+ public static class AssertingNumericDocValues extends NumericDocValues {+ private final NumericDocValues in;+ private final int maxDoc;++ public AssertingNumericDocValues(NumericDocValues in, int maxDoc) {+ this.in = in;+ this.maxDoc = maxDoc;+ }++ @Override+ public long get(int docID) {+ assert docID >= 0 && docID < maxDoc;+ return in.get(docID);+ }+ }++ /** Wraps a BinaryDocValues but with additional asserts */+ public static class AssertingBinaryDocValues extends BinaryDocValues {+ private final BinaryDocValues in;+ private final int maxDoc;++ public AssertingBinaryDocValues(BinaryDocValues in, int maxDoc) {+ this.in = in;+ this.maxDoc = maxDoc;+ }++ @Override+ public void get(int docID, BytesRef result) {+ assert docID >= 0 && docID < maxDoc;+ assert result.isValid();+ in.get(docID, result);+ assert result.isValid();+ }+ }++ /** Wraps a SortedDocValues but with additional asserts */+ public static class AssertingSortedDocValues extends SortedDocValues {+ private final SortedDocValues in;+ private final int maxDoc;+ private final int valueCount;++ public AssertingSortedDocValues(SortedDocValues in, int maxDoc) {+ this.in = in;+ this.maxDoc = maxDoc;+ this.valueCount = in.getValueCount();+ assert valueCount >= 1 && valueCount <= maxDoc;+ }++ @Override+ public int getOrd(int docID) {+ assert docID >= 0 && docID < maxDoc;+ int ord = in.getOrd(docID);+ assert ord >= 0 && ord < valueCount;+ return ord;+ }++ @Override+ public void lookupOrd(int ord, BytesRef result) {+ assert ord >= 0 && ord < valueCount;+ assert result.isValid();+ in.lookupOrd(ord, result);+ assert result.isValid();+ }++ @Override+ public int getValueCount() {+ int valueCount = in.getValueCount();+ assert valueCount == this.valueCount; // should not change+ return valueCount;+ }++ @Override+ public void get(int docID, BytesRef result) {+ assert docID >= 0 && docID < maxDoc;+ assert result.isValid();+ in.get(docID, result);+ assert result.isValid();+ }++ @Override+ public int lookupTerm(BytesRef key, BytesRef spare) {+ assert key.isValid();+ assert spare.isValid();+ int result = in.lookupTerm(key, spare);+ assert result < valueCount;+ assert key.isValid();+ assert spare.isValid();+ return result;+ }+ }++ @Override+ public NumericDocValues getNumericDocValues(String field) throws IOException {+ NumericDocValues dv = super.getNumericDocValues(field);+ FieldInfo fi = getFieldInfos().fieldInfo(field);+ if (dv != null) {+ assert fi != null;+ assert fi.getDocValuesType() == FieldInfo.DocValuesType.NUMERIC;+ return new AssertingNumericDocValues(dv, maxDoc());+ } else {+ assert fi == null || fi.hasDocValues() == false;+ return null;+ }+ }++ @Override+ public BinaryDocValues getBinaryDocValues(String field) throws IOException {+ BinaryDocValues dv = super.getBinaryDocValues(field);+ FieldInfo fi = getFieldInfos().fieldInfo(field);+ if (dv != null) {+ assert fi != null;+ assert fi.getDocValuesType() == FieldInfo.DocValuesType.BINARY;+ return new AssertingBinaryDocValues(dv, maxDoc());+ } else {+ assert fi == null || fi.hasDocValues() == false;+ return null;+ }+ }++ @Override+ public SortedDocValues getSortedDocValues(String field) throws IOException {+ SortedDocValues dv = super.getSortedDocValues(field);+ FieldInfo fi = getFieldInfos().fieldInfo(field);+ if (dv != null) {+ assert fi != null;+ assert fi.getDocValuesType() == FieldInfo.DocValuesType.SORTED;+ return new AssertingSortedDocValues(dv, maxDoc());+ } else {+ assert fi == null || fi.hasDocValues() == false;+ return null;+ }+ }++ @Override+ public NumericDocValues getNormValues(String field) throws IOException {+ NumericDocValues dv = super.getNormValues(field);+ FieldInfo fi = getFieldInfos().fieldInfo(field);+ if (dv != null) {+ assert fi != null;+ assert fi.hasNorms();+ return new AssertingNumericDocValues(dv, maxDoc());+ } else {+ assert fi == null || fi.hasNorms() == false;+ return null;+ }+ }// this is the same hack as FCInvisible@Overridediff --git a/lucene/test-framework/src/java/org/apache/lucene/index/RandomCodec.java b/lucene/test-framework/src/java/org/apache/lucene/index/RandomCodec.javaindex 66ffea1e9ee..ba2c8677d91 100644--- a/lucene/test-framework/src/java/org/apache/lucene/index/RandomCodec.java+++ b/lucene/test-framework/src/java/org/apache/lucene/index/RandomCodec.java@@ -29,6 +29,7 @@ import java.util.Set;import org.apache.lucene.codecs.PostingsFormat;import org.apache.lucene.codecs.DocValuesFormat;+import org.apache.lucene.codecs.asserting.AssertingDocValuesFormat;import org.apache.lucene.codecs.asserting.AssertingPostingsFormat;import org.apache.lucene.codecs.lucene41.Lucene41PostingsFormat;import org.apache.lucene.codecs.lucene41ords.Lucene41WithOrds;@@ -144,7 +145,8 @@ public class RandomCodec extends Lucene42Codec {addDocValues(avoidCodecs,new Lucene42DocValuesFormat(),new DiskDocValuesFormat(),- new SimpleTextDocValuesFormat());+ new SimpleTextDocValuesFormat(),+ new AssertingDocValuesFormat());Collections.shuffle(formats, random);Collections.shuffle(dvFormats, random);diff --git a/lucene/test-framework/src/resources/META-INF/services/org.apache.lucene.codecs.DocValuesFormat b/lucene/test-framework/src/resources/META-INF/services/org.apache.lucene.codecs.DocValuesFormatnew file mode 100644index 00000000000..d1798334486--- /dev/null+++ b/lucene/test-framework/src/resources/META-INF/services/org.apache.lucene.codecs.DocValuesFormat@@ -0,0 +1,16 @@+# Licensed to the Apache Software Foundation (ASF) under one or more+# contributor license agreements. See the NOTICE file distributed with+# this work for additional information regarding copyright ownership.+# The ASF licenses this file to You under the Apache License, Version 2.0+# (the "License"); you may not use this file except in compliance with+# the License. You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.++org.apache.lucene.codecs.asserting.AssertingDocValuesFormat