lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r1350445 - in /lucene/dev/branches/branch_4x: ./ dev-tools/ lucene/ lucene/analysis/ lucene/analysis/common/ lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/std31/ lucene/analysis/common/src/java/org/apache/lucene/analys...
Date Fri, 15 Jun 2012 02:05:48 GMT
Author: hossman
Date: Fri Jun 15 02:05:45 2012
New Revision: 1350445

URL: http://svn.apache.org/viewvc?rev=1350445&view=rev
Log:
SOLR-3267: make TestSort.testRandomFieldNameSorts less wishy-washy about random strings that
might produce function names (merge r1350444)

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/dev-tools/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/BUILD.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/CHANGES.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/JRE_VERSION_MIGRATION.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/LICENSE.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/MIGRATE.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/README.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/analysis/   (props changed)
    lucene/dev/branches/branch_4x/lucene/analysis/common/   (props changed)
    lucene/dev/branches/branch_4x/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/std31/package.html
  (props changed)
    lucene/dev/branches/branch_4x/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/std34/package.html
  (props changed)
    lucene/dev/branches/branch_4x/lucene/backwards/   (props changed)
    lucene/dev/branches/branch_4x/lucene/benchmark/   (props changed)
    lucene/dev/branches/branch_4x/lucene/build.xml   (props changed)
    lucene/dev/branches/branch_4x/lucene/common-build.xml   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/   (props changed)
    lucene/dev/branches/branch_4x/lucene/demo/   (props changed)
    lucene/dev/branches/branch_4x/lucene/facet/   (props changed)
    lucene/dev/branches/branch_4x/lucene/grouping/   (props changed)
    lucene/dev/branches/branch_4x/lucene/highlighter/   (props changed)
    lucene/dev/branches/branch_4x/lucene/ivy-settings.xml   (props changed)
    lucene/dev/branches/branch_4x/lucene/join/   (props changed)
    lucene/dev/branches/branch_4x/lucene/memory/   (props changed)
    lucene/dev/branches/branch_4x/lucene/misc/   (props changed)
    lucene/dev/branches/branch_4x/lucene/module-build.xml   (props changed)
    lucene/dev/branches/branch_4x/lucene/queries/   (props changed)
    lucene/dev/branches/branch_4x/lucene/queryparser/   (props changed)
    lucene/dev/branches/branch_4x/lucene/sandbox/   (props changed)
    lucene/dev/branches/branch_4x/lucene/site/   (props changed)
    lucene/dev/branches/branch_4x/lucene/spatial/   (props changed)
    lucene/dev/branches/branch_4x/lucene/suggest/   (props changed)
    lucene/dev/branches/branch_4x/lucene/test-framework/   (props changed)
    lucene/dev/branches/branch_4x/lucene/tools/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/CHANGES.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/LICENSE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/README.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/build.xml   (props changed)
    lucene/dev/branches/branch_4x/solr/cloud-dev/   (props changed)
    lucene/dev/branches/branch_4x/solr/common-build.xml   (props changed)
    lucene/dev/branches/branch_4x/solr/contrib/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestSort.java
    lucene/dev/branches/branch_4x/solr/dev-tools/   (props changed)
    lucene/dev/branches/branch_4x/solr/example/   (props changed)
    lucene/dev/branches/branch_4x/solr/lib/   (props changed)
    lucene/dev/branches/branch_4x/solr/lib/httpclient-LICENSE-ASL.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/lib/httpclient-NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/lib/httpcore-LICENSE-ASL.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/lib/httpcore-NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/lib/httpmime-LICENSE-ASL.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/lib/httpmime-NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/scripts/   (props changed)
    lucene/dev/branches/branch_4x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_4x/solr/test-framework/   (props changed)
    lucene/dev/branches/branch_4x/solr/testlogging.properties   (props changed)
    lucene/dev/branches/branch_4x/solr/webapp/   (props changed)

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestSort.java?rev=1350445&r1=1350444&r2=1350445&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestSort.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestSort.java
Fri Jun 15 02:05:45 2012
@@ -74,29 +74,37 @@ public class TestSort extends SolrTestCa
     SolrQueryRequest req = lrf.makeRequest("q", "*:*");
 
     final int iters = atLeast(5000);
-    int numberOfOddities = 0;
+
+    // infinite loop abort when trying to generate a non-blank sort "name"
+    final int nonBlankAttempts = 37;
 
     for (int i = 0; i < iters; i++) {
       final StringBuilder input = new StringBuilder();
       final String[] names = new String[_TestUtil.nextInt(r,1,10)];
       final boolean[] reverse = new boolean[names.length];
       for (int j = 0; j < names.length; j++) {
-        names[j] = _TestUtil.randomRealisticUnicodeString(r, 1, 20);
+        names[j] = null;
+        for (int k = 0; k < nonBlankAttempts && null == names[j]; k++) {
+          names[j] = _TestUtil.randomRealisticUnicodeString(r, 1, 100);
+
+          // munge anything that might make this a function
+          names[j] = names[j].replaceFirst("\\{","\\{\\{");
+          names[j] = names[j].replaceFirst("\\(","\\(\\(");
+          names[j] = names[j].replaceFirst("(\\\"|\\')","$1$1z");
+          names[j] = names[j].replaceFirst("(\\d)","$1x");
+
+          // eliminate pesky problem chars
+          names[j] = names[j].replaceAll("\\p{Cntrl}|\\p{javaWhitespace}","");
+          
+          if (0 == names[j].length()) {
+            names[j] = null;
+          }
+        }
+        // with luck this bad, never go to vegas
+        // alternatively: if (null == names[j]) names[j] = "never_go_to_vegas";
+        assertNotNull("Unable to generate a (non-blank) names["+j+"] after "
+                      + nonBlankAttempts + " attempts", names[j]);
 
-        // reduce the likelyhood that the random str is a valid query or func 
-        names[j] = names[j].replaceFirst("\\{","\\{\\{");
-        names[j] = names[j].replaceFirst("\\(","\\(\\(");
-        names[j] = names[j].replaceFirst("(\\\"|\\')","$1$1");
-        names[j] = names[j].replaceFirst("(\\d)","$1x");
-
-        // eliminate pesky problem chars
-        names[j] = names[j].replaceAll("\\p{Cntrl}|\\p{javaWhitespace}","");
-
-        if (0 == names[j].length()) {
-          numberOfOddities++;
-          // screw it, i'm taking my toys and going home
-          names[j] = "last_ditch_i_give_up";
-        }
         reverse[j] = r.nextBoolean();
 
         input.append(r.nextBoolean() ? " " : "");
@@ -120,38 +128,25 @@ public class TestSort extends SolrTestCa
         final Type type = sorts[j].getType();
 
         if (Type.SCORE.equals(type)) {
-          numberOfOddities++;
           assertEquals("sorts["+j+"] is (unexpectedly) type score : " + input,
                        "score", names[j]);
         } else if (Type.DOC.equals(type)) {
-          numberOfOddities++;
           assertEquals("sorts["+j+"] is (unexpectedly) type doc : " + input,
                        "_docid_", names[j]);
         } else if (Type.CUSTOM.equals(type) || Type.REWRITEABLE.equals(type)) {
-          numberOfOddities++;
 
-          // our orig string better be parsable as a func/query
-          QParser qp = 
-            QParser.getParser(names[j], FunctionQParserPlugin.NAME, req);
-          try { 
-            Query q = qp.getQuery();
-            assertNotNull("sorts["+j+"] had type " + type + 
-                          " but parsed to null func/query: " + input, q);
-          } catch (Exception e) {
-            assertNull("sorts["+j+"] had type " + type + 
-                       " but errored parsing as func/query: " + input, e);
-          }
+          fail("sorts["+j+"] resulted in a '" + type.toString()
+               + "', either sort parsing code is broken, or func/query " 
+               + "semantics have gotten broader and munging in this test "
+               + "needs improved: " + input);
+
         } else {
-          assertEquals("sorts["+j+"] had unexpected field: " + input,
+          assertEquals("sorts["+j+"] ("+type.toString()+
+                       ") had unexpected field in: " + input,
                        names[j], sorts[j].getField());
         }
       }
     }
-
-    assertTrue("Over 0.2% oddities in test: " +
-               numberOfOddities + "/" + iters +
-               " have func/query parsing semenatics gotten broader?",
-               numberOfOddities < 0.002 * iters);
   }
 
 



Mime
View raw message