Modified AutoCommitTest to add an superfluous document when expecting a commit to occur. This

should block if by chance the commit is taking too long.  Possible caveat: delays might also 
cause extra commits.

 --This line, and those below, will be ignored--

M    src/test/org/apache/solr/update/AutoCommitTest.java


git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@503885 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mike Klaas 2007-02-05 21:32:02 +00:00
parent 64166984f6
commit 57fef31f73
1 changed files with 25 additions and 6 deletions

View File

@ -93,9 +93,16 @@ public class AutoCommitTest extends AbstractSolrTestCase {
handler.handleRequest( req, rsp );
// Wait longer then the autocommit time
Thread.sleep( 500 );
// blocks until commit is complete
req.setContentStreams( toContentStreams(
adoc("id", "A15", "subject", "info" ), null ) );
handler.handleRequest( req, rsp );
// Now make sure we can find it
assertQ("should find one", req("id:A1") ,"//result[@numFound=1]" );
assertQ("should find one", req("id:A14") ,"//result[@numFound=1]" );
assertEquals( 1, tracker.autoCommitCount );
// But not the one added afterward
assertQ("should find one", req("id:A15") ,"//result[@numFound=0]" );
assertEquals( 1, tracker.autoCommitCount );
// Now add some more
@ -113,7 +120,14 @@ public class AutoCommitTest extends AbstractSolrTestCase {
handler.handleRequest( req, rsp );
Thread.sleep( 500 );
assertQ("should find one", req("id:B1") ,"//result[@numFound=1]" );
// add request will block if commit has already started or completed
req.setContentStreams( toContentStreams(
adoc("id", "B15", "subject", "info" ), null ) );
handler.handleRequest( req, rsp );
assertQ("should find one", req("id:B14") ,"//result[@numFound=1]" );
assertEquals( 2, tracker.autoCommitCount );
assertQ("should find none", req("id:B15") ,"//result[@numFound=0]" );
assertEquals( 2, tracker.autoCommitCount );
}
@ -134,10 +148,7 @@ public class AutoCommitTest extends AbstractSolrTestCase {
SolrQueryResponse rsp = new SolrQueryResponse();
SolrQueryRequestBase req = new SolrQueryRequestBase( core, params ) {};
req.setContentStreams( toContentStreams(
adoc("id", "529",
"field_t", "what's inside?",
"subject", "info"
), null ) );
adoc("id", "529", "field_t", "what's inside?", "subject", "info"), null ) );
handler.handleRequest( req, rsp );
// Check it it is in the index
@ -145,9 +156,14 @@ public class AutoCommitTest extends AbstractSolrTestCase {
// Wait longer then the autocommit time
Thread.sleep( 1000 );
req.setContentStreams( toContentStreams(
adoc("id", "530", "field_t", "what's inside?", "subject", "info"), null ) );
handler.handleRequest( req, rsp );
// Now make sure we can find it
assertQ("should find one", req("id:529") ,"//result[@numFound=1]" );
// But not this one
assertQ("should find none", req("id:530") ,"//result[@numFound=0]" );
// now make the call 10 times really fast and make sure it
// only commits once
@ -161,8 +177,11 @@ public class AutoCommitTest extends AbstractSolrTestCase {
// Wait longer then the autocommit time
Thread.sleep( 1000 );
req.setContentStreams( toContentStreams(
adoc("id", "531", "field_t", "what's inside?", "subject", "info"), null ) );
assertQ("now it should", req("id:500") ,"//result[@numFound=1]" );
assertQ("but not this", req("id:531") ,"//result[@numFound=0]" );
assertEquals( 2, tracker.autoCommitCount );
}
}