zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ph...@apache.org
Subject zookeeper git commit: ZOOKEEPER-2961: Fix testElectionFraud Flakyness
Date Thu, 18 Jan 2018 23:59:20 GMT
Repository: zookeeper
Updated Branches:
  refs/heads/branch-3.5 5fc4a8b8e -> 245d2333f


ZOOKEEPER-2961: Fix testElectionFraud Flakyness

This test relies on hooking into our logging system and creates a new appender using a PatternLayout
object shared with the CONSOLE appender. PatternLayout has some synchronization issues (https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html)
so we should create a new instance of it.

Author: Abraham Fine <afine@apache.org>

Reviewers: phunt@apache.org

Closes #437 from afine/ZOOKEEPER-2961_master

Change-Id: I1c81d37b94b12e0721a671deb2fc983773f88fd9
(cherry picked from commit 77d6b763a7772553ecfa81e3d3ef177452ad16a7)
Signed-off-by: Patrick Hunt <phunt@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/245d2333
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/245d2333
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/245d2333

Branch: refs/heads/branch-3.5
Commit: 245d2333f3839b3367e653dacc546fd8c402802b
Parents: 5fc4a8b
Author: Abraham Fine <afine@apache.org>
Authored: Thu Jan 18 15:52:43 2018 -0800
Committer: Patrick Hunt <phunt@apache.org>
Committed: Thu Jan 18 15:56:17 2018 -0800

----------------------------------------------------------------------
 .../org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zookeeper/blob/245d2333/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java b/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java
index a5e7c79..e6e613c 100644
--- a/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java
+++ b/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java
@@ -34,6 +34,7 @@ import java.util.regex.Pattern;
 import org.apache.log4j.Layout;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
 import org.apache.log4j.WriterAppender;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
@@ -346,9 +347,9 @@ public class QuorumPeerMainTest extends QuorumPeerTestBase {
     @Test
     public void testElectionFraud() throws IOException, InterruptedException {
         // capture QuorumPeer logging
-        Layout layout = Logger.getRootLogger().getAppender("CONSOLE").getLayout();
         ByteArrayOutputStream os = new ByteArrayOutputStream();
-        WriterAppender appender = new WriterAppender(layout, os);
+        String loggingPattern = ((PatternLayout) Logger.getRootLogger().getAppender("CONSOLE").getLayout()).getConversionPattern();
+        WriterAppender appender = new WriterAppender(new PatternLayout(loggingPattern), os);
         appender.setThreshold(Level.INFO);
         Logger qlogger = Logger.getLogger(QuorumPeer.class);
         qlogger.addAppender(appender);


Mime
View raw message