lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1466610 - /lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestSearcherTaxonomyManager.java
Date Wed, 10 Apr 2013 18:27:16 GMT
Author: mikemccand
Date: Wed Apr 10 18:27:15 2013
New Revision: 1466610

URL: http://svn.apache.org/r1466610
Log:
LUCENE-3786: fix test to not rely on wall clock

Modified:
    lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestSearcherTaxonomyManager.java

Modified: lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestSearcherTaxonomyManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestSearcherTaxonomyManager.java?rev=1466610&r1=1466609&r2=1466610&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestSearcherTaxonomyManager.java
(original)
+++ lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestSearcherTaxonomyManager.java
Wed Apr 10 18:27:15 2013
@@ -48,12 +48,15 @@ public class TestSearcherTaxonomyManager
     final FacetFields facetFields = new FacetFields(tw);
     final AtomicBoolean stop = new AtomicBoolean();
 
+    // How many unique facets to index before stopping:
+    final int ordLimit = TEST_NIGHTLY ? 100000 : 6000;
+
     Thread indexer = new Thread() {
         @Override
         public void run() {
           Set<String> seen = new HashSet<String>();
           List<String> paths = new ArrayList<String>();
-          while (!stop.get()) {
+          while (true) {
             Document doc = new Document();
             List<CategoryPath> docPaths = new ArrayList<CategoryPath>();
             int numPaths = _TestUtil.nextInt(random(), 1, 5);
@@ -82,6 +85,11 @@ public class TestSearcherTaxonomyManager
             } catch (IOException ioe) {
               throw new RuntimeException(ioe);
             }
+
+            if (tw.getSize() >= ordLimit) {
+              stop.set(true);
+              break;
+            }
           }
         }
       };
@@ -113,24 +121,16 @@ public class TestSearcherTaxonomyManager
       };
     reopener.start();
 
-    float runTimeSec = TEST_NIGHTLY ? 10.0f : 2.0f;
-
-    long stopTime = System.currentTimeMillis() + (int) (runTimeSec*1000);
-
     indexer.start();
 
     try {
-      while (System.currentTimeMillis() < stopTime) {
+      while (!stop.get()) {
         SearcherAndTaxonomy pair = mgr.acquire();
         try {
           //System.out.println("search maxOrd=" + pair.taxonomyReader.getSize());
-          int topN;
-          if (random().nextBoolean()) {
-            topN = _TestUtil.nextInt(random(), 1, 20);
-          } else {
-            topN = Integer.MAX_VALUE;
-          }
-          FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("field"),
topN));
+          int topN = _TestUtil.nextInt(random(), 1, 20);
+          CountFacetRequest cfr = new CountFacetRequest(new CategoryPath("field"), topN);
+          FacetSearchParams fsp = new FacetSearchParams(cfr);
           FacetsCollector fc = FacetsCollector.create(fsp, pair.searcher.getIndexReader(),
pair.taxonomyReader);
           pair.searcher.search(new MatchAllDocsQuery(), fc);
           List<FacetResult> results = fc.getFacetResults();
@@ -139,9 +139,11 @@ public class TestSearcherTaxonomyManager
           assertTrue(root.ordinal != 0);
 
           if (pair.searcher.getIndexReader().numDocs() > 0) { 
+            //System.out.println(pair.taxonomyReader.getSize());
             assertTrue(fr.getNumValidDescendants() > 0);
             assertFalse(root.subResults.isEmpty());
           }
+
           //if (VERBOSE) {
           //System.out.println("TEST: facets=" + FacetTestUtils.toSimpleString(results.get(0)));
           //}
@@ -150,7 +152,6 @@ public class TestSearcherTaxonomyManager
         }
       }
     } finally {
-      stop.set(true);
       indexer.join();
       reopener.join();
     }



Mime
View raw message