You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2020/08/30 15:34:46 UTC
[lucene-solr] branch branch_8x updated: LUCENE-9456: fix
DirectUpdateHandlerTest#testPrepareCommit (#1803)
This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new a04f691 LUCENE-9456: fix DirectUpdateHandlerTest#testPrepareCommit (#1803)
a04f691 is described below
commit a04f69147e8cc6fdd8a27c9763a509e6b68b1c1f
Author: David Smiley <ds...@apache.org>
AuthorDate: Sun Aug 30 11:32:56 2020 -0400
LUCENE-9456: fix DirectUpdateHandlerTest#testPrepareCommit (#1803)
Check for specific files being present or not or changing. Don't make assumptions about file count.
(cherry picked from commit 06903a40eefa619d0746d2351da6ce79d049b3b3)
---
.../apache/solr/update/DirectUpdateHandlerTest.java | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java b/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
index b3d3a5c..a839f5d 100644
--- a/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
@@ -27,6 +27,7 @@ import com.codahale.metrics.Gauge;
import com.codahale.metrics.Meter;
import com.codahale.metrics.Metric;
import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.store.Directory;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonParams;
@@ -38,6 +39,7 @@ import org.apache.solr.index.TieredMergePolicyFactory;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.util.LogLevel;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -47,10 +49,7 @@ import org.slf4j.LoggerFactory;
import static org.apache.solr.common.params.CommonParams.VERSION_FIELD;
-/**
- *
- *
- */
+@LogLevel("org.apache.solr.update=INFO")
public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@@ -392,7 +391,10 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
}
assertU(adoc("id", "1"));
- int nFiles = d.listAll().length;
+ assertFalse(Arrays.stream(d.listAll()).anyMatch(s -> s.startsWith(IndexFileNames.PENDING_SEGMENTS)));
+ String beforeSegmentsFile =
+ Arrays.stream(d.listAll()).filter(s -> s.startsWith(IndexFileNames.SEGMENTS)).findAny().get();
+
if (log.isInfoEnabled()) {
log.info("FILES before prepareCommit={}", Arrays.asList(d.listAll()));
}
@@ -402,8 +404,10 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
if (log.isInfoEnabled()) {
log.info("FILES after prepareCommit={}", Arrays.asList(d.listAll()));
}
- assertTrue( d.listAll().length > nFiles); // make sure new index files were actually written
-
+ assertTrue(Arrays.stream(d.listAll()).anyMatch(s -> s.startsWith(IndexFileNames.PENDING_SEGMENTS)));
+ assertEquals(beforeSegmentsFile,
+ Arrays.stream(d.listAll()).filter(s -> s.startsWith(IndexFileNames.SEGMENTS)).findAny().get());
+
assertJQ(req("q", "id:1")
, "/response/numFound==0"
);