You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2015/04/27 19:09:27 UTC

svn commit: r1676337 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java example/exampledocs/mem.xml

Author: hossman
Date: Mon Apr 27 17:09:26 2015
New Revision: 1676337

URL: http://svn.apache.org/r1676337
Log:
SOLR-7470: Fix sample data to eliminate file order dependency for successful indexing, also fixed SolrCloudExampleTest to help catch this in the future

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java
    lucene/dev/trunk/solr/example/exampledocs/mem.xml

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1676337&r1=1676336&r2=1676337&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Mon Apr 27 17:09:26 2015
@@ -210,6 +210,9 @@ Bug Fixes
 * SOLR-7449: solr/server/etc/jetty-https-ssl.xml hard codes the key store file and password rather
   than pulling them from the sysprops defined in solr/bin/solr.in.{sh,cmd}
 
+* SOLR-7470: Fix sample data to eliminate file order dependency for successful indexing, also 
+  fixed SolrCloudExampleTest to help catch this in the future. (hossman)
+
 Optimizations
 ----------------------
 

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java?rev=1676337&r1=1676336&r2=1676337&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java Mon Apr 27 17:09:26 2015
@@ -19,6 +19,11 @@ package org.apache.solr.cloud;
 
 import java.io.File;
 import java.io.FilenameFilter;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Random;
 import java.util.Set;
 
 import org.apache.commons.cli.CommandLine;
@@ -96,20 +101,29 @@ public class SolrCloudExampleTest extend
     File exampleDocsDir = new File(ExternalPaths.SOURCE_HOME, "example/exampledocs");
     assertTrue(exampleDocsDir.getAbsolutePath()+" not found!", exampleDocsDir.isDirectory());
 
-    File[] xmlFiles = exampleDocsDir.listFiles(new FilenameFilter() {
+    List<File> xmlFiles = Arrays.asList(exampleDocsDir.listFiles(new FilenameFilter() {
       @Override
       public boolean accept(File dir, String name) {
         return name.endsWith(".xml");
       }
-    });
+    }));
+
+    // force a deterministic random ordering of the files so seeds reproduce regardless of platform/filesystem
+    Collections.sort(xmlFiles, new Comparator<File>() {
+        public int compare(File o1, File o2) {
+          // don't rely on File.compareTo, it's behavior varies by OS
+          return o1.getName().compareTo(o2.getName());
+        }
+      });
+    Collections.shuffle(xmlFiles, new Random(random().nextLong()));
 
     // if you add/remove example XML docs, you'll have to fix these expected values
     int expectedXmlFileCount = 14;
     int expectedXmlDocCount = 32;
 
-    assertTrue("Expected 14 example XML files in "+exampleDocsDir.getAbsolutePath(),
-        xmlFiles.length == expectedXmlFileCount);
-
+    assertEquals("Unexpected # of example XML files in "+exampleDocsDir.getAbsolutePath(),
+                 expectedXmlFileCount, xmlFiles.size());
+    
     for (File xml : xmlFiles) {
       ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update");
       req.addFile(xml, "application/xml");
@@ -121,7 +135,8 @@ public class SolrCloudExampleTest extend
 
     QueryResponse qr = cloudClient.query(new SolrQuery("*:*"));
     int numFound = (int)qr.getResults().getNumFound();
-    assertTrue("Expected "+expectedXmlDocCount+" docs but *:* found "+numFound, numFound == expectedXmlDocCount);
+    assertEquals("*:* found unexpected number of documents", expectedXmlDocCount, numFound);
+                 
 
     log.info("testLoadDocsIntoGettingStartedCollection succeeded ... shutting down now!");
   }

Modified: lucene/dev/trunk/solr/example/exampledocs/mem.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/exampledocs/mem.xml?rev=1676337&r1=1676336&r2=1676337&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/exampledocs/mem.xml (original)
+++ lucene/dev/trunk/solr/example/exampledocs/mem.xml Mon Apr 27 17:09:26 2015
@@ -25,7 +25,7 @@
   <field name="cat">electronics</field>
   <field name="cat">memory</field>
   <field name="features">CAS latency 2,	2-3-3-6 timing, 2.75v, unbuffered, heat-spreader</field>
-  <field name="price">185</field>
+  <field name="price">185.00</field>
   <field name="popularity">5</field>
   <field name="inStock">true</field>
   <!-- San Francisco store -->