improve term vector merging tests (#500)

Use less iterations locally so that term vector merging doesn't dominate
the list of slowest tests.

Split out deletes/no-deletes into separate methods to improve
debuggability.

Remove nightly from SimpleText term vectors merging tests, now that they
run much faster.
This commit is contained in:
Robert Muir 2021-12-02 05:29:41 -05:00 committed by GitHub
parent efc713c9c5
commit d74255a96c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 21 deletions

View File

@ -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 BaseTermVectorsFormatTestCa
protected 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();
}
}

View File

@ -676,7 +676,7 @@ public abstract class BaseTermVectorsFormatTestCase extends BaseIndexFileFormatT
private 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