SOLR-4525 Adding some verbosity to the test b/c it fails in some environments, how often I don't quite know.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1452048 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erick Erickson 2013-03-03 14:57:07 +00:00
parent c160fd0375
commit 2e7651f407
1 changed files with 22 additions and 13 deletions

View File

@ -76,13 +76,17 @@ public class OpenCloseCoreStressTest extends SolrTestCaseJ4 {
List<HttpSolrServer> queryServers = new ArrayList<HttpSolrServer>(queryThreads); List<HttpSolrServer> queryServers = new ArrayList<HttpSolrServer>(queryThreads);
static String savedFactory; static String savedFactory;
static String verbose = "false"; // EOE remove me.
// Keep the indexes from being randomly generated. // Keep the indexes from being randomly generated.
@BeforeClass @BeforeClass
public static void beforeClass() { public static void beforeClass() {
savedFactory = System.getProperty("solr.DirectoryFactory"); savedFactory = System.getProperty("solr.DirectoryFactory");
verbose = System.getProperty("tests.verbose", "false");
System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory"); System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");
System.setProperty("tests.verbose", "true");
} }
@AfterClass @AfterClass
public static void afterClass() { public static void afterClass() {
if (savedFactory == null) { if (savedFactory == null) {
@ -90,6 +94,7 @@ public class OpenCloseCoreStressTest extends SolrTestCaseJ4 {
} else { } else {
System.setProperty("solr.directoryFactory", savedFactory); System.setProperty("solr.directoryFactory", savedFactory);
} }
System.setProperty("tests.verbose", verbose);
} }
@Before @Before
@ -227,13 +232,13 @@ public class OpenCloseCoreStressTest extends SolrTestCaseJ4 {
// create directories in groups of 100 until you have enough. // create directories in groups of 100 until you have enough.
for (int idx = 0; idx < numCores; ++idx) { for (int idx = 0; idx < numCores; ++idx) {
String coreName = String.format(Locale.ROOT, "%05d_core", idx); String coreName = String.format(Locale.ROOT, "%05d_core", idx);
makeCore(new File(home, coreName), testSrcRoot, coreName); makeCore(new File(home, coreName), testSrcRoot, oldStyle);
coreCounts.put(coreName, 0L); coreCounts.put(coreName, 0L);
coreNames.add(coreName); coreNames.add(coreName);
} }
} }
private void makeCore(File coreDir, File testSrcRoot, String coreName) throws IOException { private void makeCore(File coreDir, File testSrcRoot, boolean oldStyle) throws IOException {
File conf = new File(coreDir, "conf"); File conf = new File(coreDir, "conf");
conf.mkdirs(); conf.mkdirs();
@ -243,9 +248,12 @@ public class OpenCloseCoreStressTest extends SolrTestCaseJ4 {
FileUtils.copyFile(new File(testConf, "solrconfig-minimal.xml"), new File(conf, "solrconfig-minimal.xml")); FileUtils.copyFile(new File(testConf, "solrconfig-minimal.xml"), new File(conf, "solrconfig-minimal.xml"));
if (!oldStyle) {
FileUtils.copyFile(new File(testSrcRoot, "conf/core.properties"), new File(coreDir, "core.properties")); FileUtils.copyFile(new File(testSrcRoot, "conf/core.properties"), new File(coreDir, "core.properties"));
} }
}
void deleteAllDocuments(HttpSolrServer server, Queries queries) { void deleteAllDocuments(HttpSolrServer server, Queries queries) {
verbose("Deleting data from last cycle, this may take a few minutes."); verbose("Deleting data from last cycle, this may take a few minutes.");
@ -406,27 +414,28 @@ class OneIndexer extends Thread {
UpdateRequest update = new UpdateRequest(); UpdateRequest update = new UpdateRequest();
update.add(doc); update.add(doc);
UpdateResponse response = new UpdateResponse(); // Just to keep a possible NPE from happening
try { try {
server.setBaseURL(baseUrl + core); server.setBaseURL(baseUrl + core);
UpdateResponse response = server.add(doc, OpenCloseCoreStressTest.COMMIT_WITHIN); response = server.add(doc, OpenCloseCoreStressTest.COMMIT_WITHIN);
if (response.getStatus() != 0) { if (response.getStatus() != 0) {
verbose("Failed to index a document with status " + response.getStatus()); verbose("Failed to index a document with status " + response.getStatus());
} else { } else {
Indexer.qTimesAccum.addAndGet(response.getQTime()); Indexer.qTimesAccum.addAndGet(response.getQTime());
Indexer.updateCounts.incrementAndGet(); Indexer.updateCounts.incrementAndGet();
} }
server.commit(true, true);
Thread.sleep(100L); // Let's not go crazy here. Thread.sleep(100L); // Let's not go crazy here.
break; // try loop. break; // try loop.
} catch (Exception e) { } catch (Exception e) {
if (e instanceof InterruptedException) return; if (e instanceof InterruptedException) return;
Indexer.errors.incrementAndGet(); Indexer.errors.incrementAndGet();
if (idx == 2) { if (idx == 2) {
fail("Could not reach server while querying for three tries, quitting " + e.getMessage()); fail("Could not reach server while indexing for three tries, quitting " + e.getMessage() + " " + response.toString());
} else { } else {
verbose("Indexing thread " + Thread.currentThread().getId() + " swallowed one exception " + e.getMessage()); verbose("Indexing thread " + Thread.currentThread().getId() + " swallowed one exception " + e.getMessage()
+ " " + response.toString());
try { try {
Thread.sleep(100); Thread.sleep(500);
} catch (InterruptedException tex) { } catch (InterruptedException tex) {
return; return;
} }
@ -503,23 +512,23 @@ class OneQuery extends Thread {
params.set("qt", "/select"); params.set("qt", "/select");
params.set("q", "*:*"); params.set("q", "*:*");
QueryResponse response = new QueryResponse(); // so we can use toString below with impunity
try { try {
// sleep between 250ms and 10000 ms // sleep between 250ms and 10000 ms
Thread.sleep(100L); // Let's not go crazy here. Thread.sleep(100L); // Let's not go crazy here.
server.setBaseURL(baseUrl + core); server.setBaseURL(baseUrl + core);
QueryResponse response = server.query(params); response = server.query(params);
long numFound = response.getResults().getNumFound();
// Perhaps collect some stats here in future. // Perhaps collect some stats here in future.
break; // retry loop break; // retry loop
} catch (Exception e) { } catch (Exception e) {
if (e instanceof InterruptedException) return; if (e instanceof InterruptedException) return;
Queries._errors.incrementAndGet(); Queries._errors.incrementAndGet();
if (idx == 2) { if (idx == 2) {
fail("Could not reach server while indexing for three tries, quitting " + e.getMessage()); fail("Could not reach server while indexing for three tries, quitting " + e.getMessage() + " " + response.toString());
} else { } else {
verbose("Querying thread: " + Thread.currentThread().getId() + " swallowed exception: " + e.getMessage()); verbose("Querying thread: " + Thread.currentThread().getId() + " swallowed exception: " + e.getMessage() + " " + response.toString());
try { try {
Thread.sleep(250L); Thread.sleep(500L);
} catch (InterruptedException tex) { } catch (InterruptedException tex) {
return; return;
} }