You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2017/01/16 00:10:40 UTC
[22/50] [abbrv] lucene-solr:jira/solr-5944: SOLR-9934:
SolrTestCase.clearIndex has been improved to take advantage of low level test
specific logic that clears the index metadata more completely then a normal
*:* DBQ can due to update versioning
SOLR-9934: SolrTestCase.clearIndex has been improved to take advantage of low level test specific logic that clears the index metadata more completely then a normal *:* DBQ can due to update versioning
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/1d7379b6
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/1d7379b6
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/1d7379b6
Branch: refs/heads/jira/solr-5944
Commit: 1d7379b680062eca766f0410e3db7ff9e9b34cb0
Parents: 17cd0f0
Author: Chris Hostetter <ho...@apache.org>
Authored: Mon Jan 9 09:53:55 2017 -0700
Committer: Chris Hostetter <ho...@apache.org>
Committed: Mon Jan 9 09:54:56 2017 -0700
----------------------------------------------------------------------
solr/CHANGES.txt | 3 +++
.../org/apache/solr/search/TestRTGBase.java | 12 -----------
.../org/apache/solr/search/TestRecovery.java | 13 ------------
.../apache/solr/search/TestRecoveryHdfs.java | 11 ----------
.../apache/solr/update/CdcrUpdateLogTest.java | 17 ---------------
.../java/org/apache/solr/SolrTestCaseJ4.java | 22 ++++++++++++++++++--
6 files changed, 23 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1d7379b6/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 49d24df..b28df9c 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -408,6 +408,9 @@ Other Changes
* SOLR-9777: IndexFingerprinting should use getCombinedCoreAndDeletesKey() instead of getCoreCacheKey() for per-segment caching (Ishan Chattopadhyaya)
+* SOLR-9934: SolrTestCase.clearIndex has been improved to take advantage of low level test specific logic that
+ clears the index metadata more completely then a normal *:* DBQ can due to update versioning. (hossman)
+
================== 6.3.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1d7379b6/solr/core/src/test/org/apache/solr/search/TestRTGBase.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestRTGBase.java b/solr/core/src/test/org/apache/solr/search/TestRTGBase.java
index 13ecb32..bb1b08a 100644
--- a/solr/core/src/test/org/apache/solr/search/TestRTGBase.java
+++ b/solr/core/src/test/org/apache/solr/search/TestRTGBase.java
@@ -36,24 +36,12 @@ import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.update.UpdateLog;
import static org.apache.solr.update.processor.DistributedUpdateProcessor.DistribPhase;
-import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
public class TestRTGBase extends SolrTestCaseJ4 {
// means we've seen the leader and have version info (i.e. we are a non-leader replica)
public static String FROM_LEADER = DistribPhase.FROMLEADER.toString();
- // since we make up fake versions in these tests, we can get messed up by a DBQ with a real version
- // since Solr can think following updates were reordered.
- @Override
- public void clearIndex() {
- try {
- deleteByQueryAndGetVersion("*:*", params("_version_", Long.toString(-Long.MAX_VALUE), DISTRIB_UPDATE_PARAM,FROM_LEADER));
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
protected final ConcurrentHashMap<Integer,DocInfo> model = new ConcurrentHashMap<>();
protected Map<Integer,DocInfo> committedModel = new HashMap<>();
protected long snapshotCount;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1d7379b6/solr/core/src/test/org/apache/solr/search/TestRecovery.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestRecovery.java b/solr/core/src/test/org/apache/solr/search/TestRecovery.java
index 12d3ec3..9b88ec4 100644
--- a/solr/core/src/test/org/apache/solr/search/TestRecovery.java
+++ b/solr/core/src/test/org/apache/solr/search/TestRecovery.java
@@ -72,19 +72,6 @@ public class TestRecovery extends SolrTestCaseJ4 {
}
}
-
- // since we make up fake versions in these tests, we can get messed up by a DBQ with a real version
- // since Solr can think following updates were reordered.
- @Override
- public void clearIndex() {
- try {
- deleteByQueryAndGetVersion("*:*", params("_version_", Long.toString(-Long.MAX_VALUE), DISTRIB_UPDATE_PARAM,FROM_LEADER));
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
-
@Test
public void testLogReplay() throws Exception {
try {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1d7379b6/solr/core/src/test/org/apache/solr/search/TestRecoveryHdfs.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestRecoveryHdfs.java b/solr/core/src/test/org/apache/solr/search/TestRecoveryHdfs.java
index e7e60ec..e6bb9a6 100644
--- a/solr/core/src/test/org/apache/solr/search/TestRecoveryHdfs.java
+++ b/solr/core/src/test/org/apache/solr/search/TestRecoveryHdfs.java
@@ -109,17 +109,6 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
dfsCluster = null;
}
- // since we make up fake versions in these tests, we can get messed up by a DBQ with a real version
- // since Solr can think following updates were reordered.
- @Override
- public void clearIndex() {
- try {
- deleteByQueryAndGetVersion("*:*", params("_version_", Long.toString(-Long.MAX_VALUE), DISTRIB_UPDATE_PARAM,FROM_LEADER));
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
@Test
public void testReplicationFactor() throws Exception {
clearIndex();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1d7379b6/solr/core/src/test/org/apache/solr/update/CdcrUpdateLogTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/CdcrUpdateLogTest.java b/solr/core/src/test/org/apache/solr/update/CdcrUpdateLogTest.java
index 60dc9c3..b7409d1 100644
--- a/solr/core/src/test/org/apache/solr/update/CdcrUpdateLogTest.java
+++ b/solr/core/src/test/org/apache/solr/update/CdcrUpdateLogTest.java
@@ -31,20 +31,14 @@ import org.apache.lucene.util.LuceneTestCase.Nightly;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.update.processor.DistributedUpdateProcessor;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.noggit.ObjectBuilder;
-import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
-
@Nightly
public class CdcrUpdateLogTest extends SolrTestCaseJ4 {
- // means that we've seen the leader and have version info (i.e. we are a non-leader replica)
- private static String FROM_LEADER = DistributedUpdateProcessor.DistribPhase.FROMLEADER.toString();
-
private static int timeout = 60; // acquire timeout in seconds. change this to a huge number when debugging to prevent threads from advancing.
// TODO: fix this test to not require FSDirectory
@@ -66,17 +60,6 @@ public class CdcrUpdateLogTest extends SolrTestCaseJ4 {
}
}
- // since we make up fake versions in these tests, we can get messed up by a DBQ with a real version
- // since Solr can think following updates were reordered.
- @Override
- public void clearIndex() {
- try {
- deleteByQueryAndGetVersion("*:*", params("_version_", Long.toString(-Long.MAX_VALUE), DISTRIB_UPDATE_PARAM, FROM_LEADER));
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
private void clearCore() throws IOException {
clearIndex();
assertU(commit());
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1d7379b6/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
index 437679d..61de56d 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
@@ -132,6 +132,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
+import static org.apache.solr.update.processor.DistributedUpdateProcessor.DistribPhase;
+import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
+
import static java.util.Objects.requireNonNull;
/**
@@ -1148,9 +1151,24 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
@Override
public String toString() { return xml; }
}
-
+
+ /**
+ * Does a low level delete of all docs in the index.
+ *
+ * The behavior of this method is slightly different then doing a normal <code>*:*</code> DBQ because it
+ * takes advantage of internal methods to ensure all index data is wiped, regardless of optimistic
+ * concurrency version constraints -- making it suitable for tests that create synthetic versions,
+ * and/or require a completely pristine index w/o any field metdata.
+ *
+ * @see #deleteByQueryAndGetVersion
+ */
public void clearIndex() {
- assertU(delQ("*:*"));
+ try {
+ deleteByQueryAndGetVersion("*:*", params("_version_", Long.toString(-Long.MAX_VALUE),
+ DISTRIB_UPDATE_PARAM,DistribPhase.FROMLEADER.toString()));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
/** Send JSON update commands */