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 Fri, 19 Jan 2018 00:05:18 GMT
Repository: zookeeper
Updated Branches:
  refs/heads/branch-3.4 3fcf7bb46 -> c9da2e287


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/c9da2e28
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/c9da2e28
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/c9da2e28

Branch: refs/heads/branch-3.4
Commit: c9da2e287bc28ef05a62e5eb7f78f6dac2a864bd
Parents: 3fcf7bb
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:59:26 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/c9da2e28/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 2431683..0399c97 100644
--- a/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java
+++ b/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java
@@ -45,6 +45,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;
@@ -351,9 +352,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