From d74255a96c32f583a81941b7cf14c53bf39e85b1 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Thu, 2 Dec 2021 05:29:41 -0500 Subject: [PATCH] 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. --- .../TestSimpleTextTermVectorsFormat.java | 16 --------------- .../index/BaseTermVectorsFormatTestCase.java | 20 ++++++++++++++----- 2 files changed, 15 insertions(+), 21 deletions(-) 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.java index 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 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(); - } } 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.java index 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 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 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