You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by kl...@apache.org on 2007/02/05 22:32:03 UTC

svn commit: r503885 - /lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java

Author: klaas
Date: Mon Feb  5 13:32:02 2007
New Revision: 503885

URL: http://svn.apache.org/viewvc?view=rev&rev=503885
Log:
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

Modified:
    lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java

Modified: lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java?view=diff&rev=503885&r1=503884&r2=503885
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java Mon Feb  5 13:32:02 2007
@@ -93,9 +93,16 @@
     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 @@
     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 @@
     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 @@
 
     // 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 @@
     
     // 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 );
   }
 }