Apache Lucene open-source search software
improve term vector merging tests (#500)
Robert Muird74255a96c32
diff --git a/lucene/codecs/src/test/org/apache/lucene/codecs/simpletext/TestSimpleTextTermVectorsFormat.java b/lucene/codecs/src/test/org/apache/lucene/codecs/simpletext/TestSimpleTextTermVectorsFormat.javaindex 45719f0eece..b2ebc21c174 100644--- a/lucene/codecs/src/test/org/apache/lucene/codecs/simpletext/TestSimpleTextTermVectorsFormat.java+++ b/lucene/codecs/src/test/org/apache/lucene/codecs/simpletext/TestSimpleTextTermVectorsFormat.java@@ -16,10 +16,8 @@*/package org.apache.lucene.codecs.simpletext;-import java.io.IOException;import org.apache.lucene.codecs.Codec;import org.apache.lucene.index.BaseTermVectorsFormatTestCase;-import org.apache.lucene.util.LuceneTestCase;public class TestSimpleTextTermVectorsFormat extends BaseTermVectorsFormatTestCase {@Override@@ -31,18 +29,4 @@ public class TestSimpleTextTermVectorsFormat extends BaseTermVectorsFormatTestCaprotected Codec getCodec() {return new SimpleTextCodec();}-- // TODO: can we speed up the underlying base test?- @Override- @LuceneTestCase.Nightly- public void testMergeWithIndexSort() throws IOException {- super.testMergeWithIndexSort();- }-- // TODO: can we speed up the underlying base test?- @Override- @LuceneTestCase.Nightly- public void testMergeWithoutIndexSort() throws IOException {- super.testMergeWithoutIndexSort();- }}diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.javaindex 7b7bd48840f..114ea1f6f7b 100644--- a/lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java+++ b/lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java@@ -676,7 +676,7 @@ public abstract class BaseTermVectorsFormatTestCase extends BaseIndexFileFormatTprivate void doTestMerge(Sort indexSort, boolean allowDeletes) throws IOException {final RandomDocumentFactory docFactory = new RandomDocumentFactory(5, 20);- final int numDocs = atLeast(100);+ final int numDocs = TEST_NIGHTLY ? atLeast(100) : atLeast(10);for (Options options : validOptions()) {Map<String, RandomDocument> docs = new HashMap<>();for (int i = 0; i < numDocs; ++i) {@@ -750,18 +750,28 @@ public abstract class BaseTermVectorsFormatTestCase extends BaseIndexFileFormatT}}+ public void testMerge() throws IOException {+ doTestMerge(null, false);+ }++ public void testMergeWithDeletes() throws IOException {+ doTestMerge(null, true);+ }+public void testMergeWithIndexSort() throws IOException {SortField[] sortFields = new SortField[TestUtil.nextInt(random(), 1, 2)];for (int i = 0; i < sortFields.length; i++) {sortFields[i] = new SortField("sort_field_" + i, SortField.Type.LONG);}doTestMerge(new Sort(sortFields), false);- doTestMerge(new Sort(sortFields), true);}- public void testMergeWithoutIndexSort() throws IOException {- doTestMerge(null, false);- doTestMerge(null, true);+ public void testMergeWithIndexSortAndDeletes() throws IOException {+ SortField[] sortFields = new SortField[TestUtil.nextInt(random(), 1, 2)];+ for (int i = 0; i < sortFields.length; i++) {+ sortFields[i] = new SortField("sort_field_" + i, SortField.Type.LONG);+ }+ doTestMerge(new Sort(sortFields), true);}// run random tests from different threads to make sure the per-thread clones