lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [33/50] lucene-solr:jira/solr-11458-2: LUCENE-8059: Fix test bug.
Date Mon, 04 Dec 2017 17:49:17 GMT
LUCENE-8059: Fix test bug.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/75d11eaf
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/75d11eaf
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/75d11eaf

Branch: refs/heads/jira/solr-11458-2
Commit: 75d11eafacf490a25ef3827e33c1383efeee20d7
Parents: 8127114
Author: Adrien Grand <jpountz@gmail.com>
Authored: Wed Nov 29 19:52:06 2017 +0100
Committer: Adrien Grand <jpountz@gmail.com>
Committed: Wed Nov 29 19:52:06 2017 +0100

----------------------------------------------------------------------
 .../search/TestTopFieldCollectorEarlyTermination.java   | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/75d11eaf/lucene/core/src/test/org/apache/lucene/search/TestTopFieldCollectorEarlyTermination.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestTopFieldCollectorEarlyTermination.java
b/lucene/core/src/test/org/apache/lucene/search/TestTopFieldCollectorEarlyTermination.java
index 91f1720..f225d0c 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestTopFieldCollectorEarlyTermination.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestTopFieldCollectorEarlyTermination.java
@@ -90,18 +90,17 @@ public class TestTopFieldCollectorEarlyTermination extends LuceneTestCase
{
       }
     }
     if (singleSortedSegment) {
-      // because of deletions, there might still be a single flush segment in
-      // the index, although want want a sorted segment so it needs to be merged
-      iw.getReader().close(); // refresh
-      iw.addDocument(new Document());
-      iw.commit();
-      iw.addDocument(new Document());
       iw.forceMerge(1);
     }
     else if (random().nextBoolean()) {
       iw.forceMerge(FORCE_MERGE_MAX_SEGMENT_COUNT);
     }
     reader = iw.getReader();
+    if (reader.maxDoc() == 0) {
+      iw.addDocument(new Document());
+      reader.close();
+      reader = iw.getReader();
+    }
   }
   
   private void closeIndex() throws IOException {
@@ -131,6 +130,7 @@ public class TestTopFieldCollectorEarlyTermination extends LuceneTestCase
{
         final int numHits = TestUtil.nextInt(random(), 1, numDocs);
         FieldDoc after;
         if (paging) {
+          assert searcher.getIndexReader().maxDoc() > 0;
           TopFieldDocs td = searcher.search(new MatchAllDocsQuery(), 10, sort);
           after = (FieldDoc) td.scoreDocs[td.scoreDocs.length - 1];
         } else {


Mime
View raw message