You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2018/09/07 07:49:56 UTC
[47/50] [abbrv] lucene-solr:jira/http2: SOLR-12732: TestLogWatcher
failure on Jenkins
SOLR-12732: TestLogWatcher failure on Jenkins
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/9e04375d
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/9e04375d
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/9e04375d
Branch: refs/heads/jira/http2
Commit: 9e04375dc193d3815e9d755514a960f902c60cd2
Parents: 98611d3
Author: Erick Erickson <Er...@gmail.com>
Authored: Thu Sep 6 19:25:33 2018 -0700
Committer: Erick Erickson <Er...@gmail.com>
Committed: Thu Sep 6 19:25:33 2018 -0700
----------------------------------------------------------------------
solr/CHANGES.txt | 2 +
.../org/apache/solr/logging/TestLogWatcher.java | 40 +++++++++++++-------
2 files changed, 29 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e04375d/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index a975f06..78bfb33 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -323,6 +323,8 @@ Bug Fixes
* SOLR-12733: SolrMetricReporterTest failure (Erick Erickson, David Smiley)
+* SOLR-12732: TestLogWatcher failure on Jenkins (Erick Erickson)
+
Optimizations
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e04375d/solr/core/src/test/org/apache/solr/logging/TestLogWatcher.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/logging/TestLogWatcher.java b/solr/core/src/test/org/apache/solr/logging/TestLogWatcher.java
index 658bc34..a93a11b 100644
--- a/solr/core/src/test/org/apache/solr/logging/TestLogWatcher.java
+++ b/solr/core/src/test/org/apache/solr/logging/TestLogWatcher.java
@@ -39,37 +39,51 @@ public class TestLogWatcher extends SolrTestCaseJ4 {
// Create several log watchers and ensure that new messages go to the new watcher.
@Test
public void testLog4jWatcher() {
- LogWatcher watcher = null;
+ LogWatcher watcher;
int lim = random().nextInt(3) + 2;
for (int idx = 0; idx < lim; ++idx) {
String msg = "This is a test message: " + idx;
watcher = LogWatcher.newRegisteredLogWatcher(config, null);
// First ensure there's nothing in the new watcher.
- assertEquals(-1, watcher.getLastEvent());
+
+ // Every time you put a message in the queue, you wait for it to come out _before_ creating
+ // a new watcher so it should be fine.
+ if (looper(watcher, null) == false) {
+ fail("There should be no messages when a new watcher finally gets registered! In loop: " + idx);
+ }
// Now log a message and ensure that the new watcher sees it.
log.warn(msg);
// Loop to give the logger time to process the async message and notify the new watcher.
- boolean foundMsg = false;
- // In local testing this loop usually succeeds 1-2 tries.
- for (int msgIdx = 0; msgIdx < 100; ++msgIdx) {
+ if (looper(watcher, msg) == false) {
+ fail("Should have found message " + msg + ". In loop: " + idx);
+ }
+ }
+ }
+ private boolean looper(LogWatcher watcher, String msg) {
+ // In local testing this loop usually succeeds 1-2 tries.
+ boolean success = false;
+ boolean testingNew = msg == null;
+ for (int msgIdx = 0; msgIdx < 100 && success == false; ++msgIdx) {
+ if (testingNew) { // check that there are no entries registered for the watcher
+ success = watcher.getLastEvent() == -1;
+ } else { // check that the expected message is there.
// Returns an empty (but non-null) list even if there are no messages yet.
SolrDocumentList events = watcher.getHistory(-1, new AtomicBoolean());
for (SolrDocument doc : events) {
if (doc.get("message").equals(msg)) {
- foundMsg = true;
- break;
+ success = true;
}
}
- try {
- Thread.sleep(10);
- } catch (InterruptedException ie) {
- ;
- }
}
- assertTrue("Should have found message " + msg + " in loop: " + idx, foundMsg);
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException ie) {
+ ;
+ }
}
+ return success;
}
}