Skip to content

Apache Lucene open-source search software

harden test some

Mark Robert Millerf932976e993c
diff --git a/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java b/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java
index d5e2ea8d31b..2df8d6b18b7 100644
--- a/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java
+++ b/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java
@@ -373,9 +373,9 @@ public class AutoCommitTest extends AbstractSolrTestCase {
// too low of a number can cause a slow host to commit before the test code checks that it
// isn't there... causing a failure at "shouldn't find any"
- softTracker.setTimeUpperBound(200);
+ softTracker.setTimeUpperBound(100);
softTracker.setDocsUpperBound(-1);
- hardTracker.setTimeUpperBound(1000);
+ hardTracker.setTimeUpperBound(500);
hardTracker.setDocsUpperBound(-1);
// updater.commitCallbacks.add(trigger);
@@ -392,7 +392,7 @@ public class AutoCommitTest extends AbstractSolrTestCase {
trigger.reset();
handler.handleRequest( req, rsp );
- // Check it it is in the index
+ // Check if it is in the index
assertQ("shouldn't find any", req("id:529") ,"//result[@numFound=0]" );
// Wait longer than the autocommit time
@@ -416,7 +416,8 @@ public class AutoCommitTest extends AbstractSolrTestCase {
req.setContentStreams( toContentStreams(
adoc("id", "550", "field_t", "what's inside?", "subject", "info"), null ) );
handler.handleRequest( req, rsp );
- assertEquals( 2, softTracker.getCommitCount() );
+ int totalCommits = softTracker.getCommitCount() + hardTracker.getCommitCount();
+ assertTrue("expected:>=2 but got " + totalCommits, totalCommits >= 2);
assertQ("deleted and time has passed", req("id:529") ,"//result[@numFound=0]" );
// now make the call 5 times really fast and make sure it
@@ -440,7 +441,10 @@ public class AutoCommitTest extends AbstractSolrTestCase {
int softCommitCnt = softTracker.getCommitCount();
assertTrue("commit cnt:" + softCommitCnt, softCommitCnt == 2
|| softCommitCnt == 3);
- assertEquals(1, hardTracker.getCommitCount());
+ // depending on timing, you might see 1 or 2 hard commits
+ int hardCommitCnt = hardTracker.getCommitCount();
+ assertTrue("commit cnt:" + hardCommitCnt, hardCommitCnt == 1
+ || hardCommitCnt == 2);
assertQ("now it should", req("id:500") ,"//result[@numFound=1]" );
assertQ("but not this", req("id:531") ,"//result[@numFound=0]" );