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 yo...@apache.org on 2008/08/06 00:32:39 UTC

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

Author: yonik
Date: Tue Aug  5 15:32:39 2008
New Revision: 683003

URL: http://svn.apache.org/viewvc?rev=683003&view=rev
Log:
fix AutoCommitTest to wait some time for a new searcher

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?rev=683003&r1=683002&r2=683003&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java Tue Aug  5 15:32:39 2008
@@ -37,8 +37,8 @@
  *
  * It is tricky to be correctly notified when commits occur: Solr's post-commit
  * hook is called after commit has completed but before the search is opened.  The
- * best that can be done is wait for a post commit hook, then add a document (which
- * will block while the searcher is opened)
+ * best that can be done is wait for a post commit hook, and then wait for a little
+ * longer for a new searcher to be registered. 
  */
 class CommitListener implements SolrEventListener {
   public boolean triggered = false;
@@ -50,8 +50,13 @@
   public boolean waitForCommit(int timeout) {
     triggered = false;
     for (int towait=timeout; towait > 0; towait -= 250) {
-      if (triggered) break;
-      try { Thread.sleep( 250 ); } catch (InterruptedException e) {}
+      try {
+        if (triggered) {
+          Thread.sleep( 500 );
+          break;
+        }
+        Thread.sleep( 250 );
+      } catch (InterruptedException e) {}
     }
     return triggered;
   }
@@ -149,7 +154,7 @@
     assertQ("shouldn't find any", req("id:529") ,"//result[@numFound=0]" );
 
     // Wait longer than the autocommit time
-    assertTrue(trigger.waitForCommit(10000));
+    assertTrue(trigger.waitForCommit(20000));
     req.setContentStreams( toContentStreams(
       adoc("id", "530", "field_t", "what's inside?", "subject", "info"), null ) );
     handler.handleRequest( req, rsp );
@@ -163,7 +168,7 @@
     assertU( delI("529") );
     assertQ("deleted, but should still be there", req("id:529") ,"//result[@numFound=1]" );
     // Wait longer than the autocommit time
-    assertTrue(trigger.waitForCommit(10000));
+    assertTrue(trigger.waitForCommit(20000));
     req.setContentStreams( toContentStreams(
       adoc("id", "550", "field_t", "what's inside?", "subject", "info"), null ) );
     handler.handleRequest( req, rsp );
@@ -180,7 +185,7 @@
     assertQ("should not be there yet", req("id:500") ,"//result[@numFound=0]" );
     
     // Wait longer than the autocommit time
-    assertTrue(trigger.waitForCommit(10000));
+    assertTrue(trigger.waitForCommit(20000));
     req.setContentStreams( toContentStreams(
       adoc("id", "531", "field_t", "what's inside?", "subject", "info"), null ) );
     handler.handleRequest( req, rsp );