mirror of https://github.com/apache/lucene.git
SOLR-7470: Fix sample data to eliminate file order dependency for successful indexing, also fixed SolrCloudExampleTest to help catch this in the future
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1676337 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0534312b8c
commit
3c1130402a
|
@ -210,6 +210,9 @@ Bug Fixes
|
||||||
* SOLR-7449: solr/server/etc/jetty-https-ssl.xml hard codes the key store file and password rather
|
* 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}
|
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
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,11 @@ package org.apache.solr.cloud;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
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 java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
|
@ -96,19 +101,28 @@ public class SolrCloudExampleTest extends AbstractFullDistribZkTestBase {
|
||||||
File exampleDocsDir = new File(ExternalPaths.SOURCE_HOME, "example/exampledocs");
|
File exampleDocsDir = new File(ExternalPaths.SOURCE_HOME, "example/exampledocs");
|
||||||
assertTrue(exampleDocsDir.getAbsolutePath()+" not found!", exampleDocsDir.isDirectory());
|
assertTrue(exampleDocsDir.getAbsolutePath()+" not found!", exampleDocsDir.isDirectory());
|
||||||
|
|
||||||
File[] xmlFiles = exampleDocsDir.listFiles(new FilenameFilter() {
|
List<File> xmlFiles = Arrays.asList(exampleDocsDir.listFiles(new FilenameFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
return name.endsWith(".xml");
|
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
|
// if you add/remove example XML docs, you'll have to fix these expected values
|
||||||
int expectedXmlFileCount = 14;
|
int expectedXmlFileCount = 14;
|
||||||
int expectedXmlDocCount = 32;
|
int expectedXmlDocCount = 32;
|
||||||
|
|
||||||
assertTrue("Expected 14 example XML files in "+exampleDocsDir.getAbsolutePath(),
|
assertEquals("Unexpected # of example XML files in "+exampleDocsDir.getAbsolutePath(),
|
||||||
xmlFiles.length == expectedXmlFileCount);
|
expectedXmlFileCount, xmlFiles.size());
|
||||||
|
|
||||||
for (File xml : xmlFiles) {
|
for (File xml : xmlFiles) {
|
||||||
ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update");
|
ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update");
|
||||||
|
@ -121,7 +135,8 @@ public class SolrCloudExampleTest extends AbstractFullDistribZkTestBase {
|
||||||
|
|
||||||
QueryResponse qr = cloudClient.query(new SolrQuery("*:*"));
|
QueryResponse qr = cloudClient.query(new SolrQuery("*:*"));
|
||||||
int numFound = (int)qr.getResults().getNumFound();
|
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!");
|
log.info("testLoadDocsIntoGettingStartedCollection succeeded ... shutting down now!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
<field name="cat">electronics</field>
|
<field name="cat">electronics</field>
|
||||||
<field name="cat">memory</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="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="popularity">5</field>
|
||||||
<field name="inStock">true</field>
|
<field name="inStock">true</field>
|
||||||
<!-- San Francisco store -->
|
<!-- San Francisco store -->
|
||||||
|
|
Loading…
Reference in New Issue