SOLR-12728: RequestLoggingTest fails on occasion, not reproducible

This commit is contained in:
Erick Erickson 2018-09-03 10:19:33 -07:00
parent b4f9042a43
commit 74b53b1a67
3 changed files with 19 additions and 5 deletions

View File

@ -298,6 +298,8 @@ Bug Fixes
* SOLR-12704: Guard AddSchemaFieldsUpdateProcessorFactory against null field names and field values.
(Steve Rowe, Varun Thacker)
* SOLR-12728: RequestLoggingTest fails on occasion, not reproducible (Erick Erickson)
Optimizations
----------------------

View File

@ -82,10 +82,23 @@ public class RequestLoggingTest extends SolrTestCaseJ4 {
try {
assertQ(req("q", "*:*"));
String output = writer.toString();
Matcher matcher = Pattern.compile("DEBUG.*q=\\*:\\*.*").matcher(output);
assertTrue(matcher.find());
Matcher matcher = null;
boolean foundDebugMsg = false;
String output = "";
for (int msgIdx = 0; msgIdx < 100; ++msgIdx) {
output = writer.toString();
matcher = Pattern.compile("DEBUG.*q=\\*:\\*.*").matcher(output);
if (matcher.find()) {
foundDebugMsg = true;
break;
}
try {
Thread.sleep(10);
} catch (InterruptedException ie) {
;
}
}
assertTrue("Should have found debug-level message. Found " + output, foundDebugMsg);
final String group = matcher.group();
final String msg = "Should not have post query information";
assertFalse(msg, group.contains("hits"));

View File

@ -53,7 +53,6 @@ public class TestLogWatcher extends SolrTestCaseJ4 {
// Loop to give the logger time to process the async message and notify the new watcher.
boolean foundMsg = false;
long last = -1;
// In local testing this loop usually succeeds 1-2 tries.
for (int msgIdx = 0; msgIdx < 100; ++msgIdx) {
// Returns an empty (but non-null) list even if there are no messages yet.