mirror of https://github.com/apache/lucene.git
SOLR-2540: Fixing commitWithin tests which timed out
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1171138 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4d6e8ad0d3
commit
44386401f6
|
@ -28,7 +28,10 @@ import org.apache.solr.handler.extraction.ExtractingDocumentLoader;
|
|||
import org.apache.solr.handler.extraction.ExtractingParams;
|
||||
import org.apache.solr.handler.extraction.ExtractingRequestHandler;
|
||||
import org.apache.solr.request.LocalSolrQueryRequest;
|
||||
import org.apache.solr.handler.BufferingRequestProcessor;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.update.AddUpdateCommand;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -39,6 +42,7 @@ import org.junit.Test;
|
|||
*
|
||||
**/
|
||||
public class ExtractingRequestHandlerTest extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("solrconfig.xml", "schema.xml", getFile("extraction/solr").getAbsolutePath());
|
||||
|
@ -290,20 +294,20 @@ public class ExtractingRequestHandlerTest extends SolrTestCaseJ4 {
|
|||
ExtractingRequestHandler handler = (ExtractingRequestHandler) h.getCore().getRequestHandler("/update/extract");
|
||||
assertTrue("handler is null and it shouldn't be", handler != null);
|
||||
|
||||
// Load plain text specifying filename
|
||||
loadLocal("extraction/version_control.txt", "fmap.created", "extractedDate", "fmap.producer", "extractedProducer",
|
||||
"fmap.creator", "extractedCreator", "fmap.Keywords", "extractedKeywords",
|
||||
"fmap.Author", "extractedAuthor",
|
||||
"literal.id", "one",
|
||||
"fmap.language", "extractedLanguage",
|
||||
"fmap.content", "extractedContent",
|
||||
ExtractingParams.RESOURCE_NAME, "extraction/version_control.txt",
|
||||
"commitWithin", "200"
|
||||
);
|
||||
assertQ(req("id:one"), "//*[@numFound='0']");
|
||||
// TODO: Find better way of testing commitWithin without sleeping?
|
||||
Thread.sleep(1000);
|
||||
assertQ(req("id:one"), "//*[@numFound='1']");
|
||||
SolrQueryRequest req = req("literal.id", "one",
|
||||
ExtractingParams.RESOURCE_NAME, "extraction/version_control.txt",
|
||||
"commitWithin", "200"
|
||||
);
|
||||
SolrQueryResponse rsp = new SolrQueryResponse();
|
||||
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
|
||||
|
||||
ExtractingDocumentLoader loader = (ExtractingDocumentLoader) handler.newLoader(req, p);
|
||||
loader.load(req, rsp, new ContentStreamBase.FileStream(getFile("extraction/version_control.txt")));
|
||||
|
||||
AddUpdateCommand add = p.addCommands.get(0);
|
||||
assertEquals(200, add.commitWithin);
|
||||
|
||||
req.close();
|
||||
}
|
||||
|
||||
// Note: If you load a plain text file specifying neither MIME type nor filename, extraction will silently fail. This is because Tika's
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.solr.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.solr.update.AddUpdateCommand;
|
||||
import org.apache.solr.update.CommitUpdateCommand;
|
||||
import org.apache.solr.update.DeleteUpdateCommand;
|
||||
import org.apache.solr.update.RollbackUpdateCommand;
|
||||
import org.apache.solr.update.processor.UpdateRequestProcessor;
|
||||
|
||||
public class BufferingRequestProcessor extends UpdateRequestProcessor
|
||||
{
|
||||
public List<AddUpdateCommand> addCommands = new ArrayList<AddUpdateCommand>();
|
||||
public List<DeleteUpdateCommand> deleteCommands = new ArrayList<DeleteUpdateCommand>();
|
||||
public List<CommitUpdateCommand> commitCommands = new ArrayList<CommitUpdateCommand>();
|
||||
public List<RollbackUpdateCommand> rollbackCommands = new ArrayList<RollbackUpdateCommand>();
|
||||
|
||||
public BufferingRequestProcessor(UpdateRequestProcessor next) {
|
||||
super(next);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processAdd(AddUpdateCommand cmd) throws IOException {
|
||||
addCommands.add( cmd );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processDelete(DeleteUpdateCommand cmd) throws IOException {
|
||||
deleteCommands.add( cmd );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommit(CommitUpdateCommand cmd) throws IOException {
|
||||
commitCommands.add( cmd );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processRollback(RollbackUpdateCommand cmd) throws IOException
|
||||
{
|
||||
rollbackCommands.add( cmd );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() throws IOException {
|
||||
// nothing?
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.solr.handler;
|
||||
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.util.ContentStreamBase;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.update.AddUpdateCommand;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class CSVRequestHandlerTest extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("solrconfig.xml", "schema.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommitWithin() throws Exception {
|
||||
CSVRequestHandler handler = new CSVRequestHandler();
|
||||
|
||||
String csvString = "id;name\n123;hello";
|
||||
SolrQueryRequest req = req("separator", ";",
|
||||
"commitWithin", "200");
|
||||
SolrQueryResponse rsp = new SolrQueryResponse();
|
||||
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
|
||||
|
||||
CSVLoader loader = (CSVLoader) handler.newLoader(req, p);
|
||||
loader.load(req, rsp, new ContentStreamBase.StringStream.StringStream(csvString));
|
||||
|
||||
AddUpdateCommand add = p.addCommands.get(0);
|
||||
assertEquals(200, add.commitWithin);
|
||||
|
||||
req.close();
|
||||
}
|
||||
}
|
|
@ -17,11 +17,6 @@
|
|||
|
||||
package org.apache.solr.handler;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.noggit.JSONParser;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.SolrInputField;
|
||||
|
@ -31,8 +26,6 @@ import org.apache.solr.response.SolrQueryResponse;
|
|||
import org.apache.solr.update.AddUpdateCommand;
|
||||
import org.apache.solr.update.CommitUpdateCommand;
|
||||
import org.apache.solr.update.DeleteUpdateCommand;
|
||||
import org.apache.solr.update.RollbackUpdateCommand;
|
||||
import org.apache.solr.update.processor.UpdateRequestProcessor;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -200,42 +193,3 @@ public class JsonLoaderTest extends SolrTestCaseJ4 {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class BufferingRequestProcessor extends UpdateRequestProcessor
|
||||
{
|
||||
List<AddUpdateCommand> addCommands = new ArrayList<AddUpdateCommand>();
|
||||
List<DeleteUpdateCommand> deleteCommands = new ArrayList<DeleteUpdateCommand>();
|
||||
List<CommitUpdateCommand> commitCommands = new ArrayList<CommitUpdateCommand>();
|
||||
List<RollbackUpdateCommand> rollbackCommands = new ArrayList<RollbackUpdateCommand>();
|
||||
|
||||
public BufferingRequestProcessor(UpdateRequestProcessor next) {
|
||||
super(next);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processAdd(AddUpdateCommand cmd) throws IOException {
|
||||
addCommands.add( cmd );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processDelete(DeleteUpdateCommand cmd) throws IOException {
|
||||
deleteCommands.add( cmd );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommit(CommitUpdateCommand cmd) throws IOException {
|
||||
commitCommands.add( cmd );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processRollback(RollbackUpdateCommand cmd) throws IOException
|
||||
{
|
||||
rollbackCommands.add( cmd );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() throws IOException {
|
||||
// nothing?
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,15 +113,6 @@ public class TestCSVLoader extends SolrTestCaseJ4 {
|
|||
assertQ(req("id:[100 TO 110]"),"//*[@numFound='3']");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommitWithin() throws Exception {
|
||||
makeFile("id\n100\n101\n102");
|
||||
loadLocal("stream.file",filename,"commitWithin","200");
|
||||
assertQ(req("id:[100 TO 110]"),"//*[@numFound='0']");
|
||||
Thread.sleep(1000);
|
||||
assertQ(req("id:[100 TO 110]"),"//*[@numFound='3']");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommitTrue() throws Exception {
|
||||
makeFile("id\n100\n101\n102");
|
||||
|
|
Loading…
Reference in New Issue