mirror of https://github.com/apache/lucene.git
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
This commit is contained in:
parent
17cd0f00cc
commit
1d7379b680
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue