zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (ZOOKEEPER-2953) Flaky Test: testNoLogBeforeLeaderEstablishment
Date Wed, 13 Dec 2017 13:44:00 GMT

    [ https://issues.apache.org/jira/browse/ZOOKEEPER-2953?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16289275#comment-16289275
] 

ASF GitHub Bot commented on ZOOKEEPER-2953:
-------------------------------------------

Github user anmolnar commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/432#discussion_r156658012
  
    --- Diff: src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java ---
    @@ -335,6 +336,100 @@ public void testHighestZxidJoinLate() throws Exception {
                     output[0], 2);
         }
     
    +    /**
    +     * This test validates that if a quorum member determines that it is leader without
the support of the rest of the
    +     * quorum (the other members do not believe it to be the leader) it will stop attempting
to lead and become a follower.
    +     *
    +     * @throws IOException
    +     * @throws InterruptedException
    +     */
    +    @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);
    +        appender.setThreshold(Level.INFO);
    +        Logger qlogger = Logger.getLogger(QuorumPeer.class);
    +        qlogger.addAppender(appender);
    +
    +        int numServers = 3;
    +
    +        // used for assertions later
    +        boolean foundLeading = false;
    +        boolean foundLooking = false;
    +        boolean foundFollowing = false;
    +
    +        try {
    +          // spin up a quorum, we use a small ticktime to make the test run faster
    +          Servers servers = LaunchServers(numServers, 500);
    +
    +          // find the leader
    +          int trueLeader = -1;
    +          for (int i = 0; i < numServers; i++) {
    +            if (servers.mt[i].main.quorumPeer.leader != null) {
    +              trueLeader = i;
    +            }
    +          }
    +          Assert.assertTrue("There should be a leader", trueLeader >= 0);
    +
    +          // find a follower
    +          int falseLeader = (trueLeader + 1) % numServers;
    +          Assert.assertTrue(servers.mt[falseLeader].main.quorumPeer.follower != null);
    --- End diff --
    
    Minor: I believe that it's generally a good idea to add a short message to asserts to
describe what could be the problem when assertion fails.


> Flaky Test: testNoLogBeforeLeaderEstablishment
> ----------------------------------------------
>
>                 Key: ZOOKEEPER-2953
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2953
>             Project: ZooKeeper
>          Issue Type: Bug
>    Affects Versions: 3.5.3, 3.4.11, 3.6.0
>            Reporter: Abraham Fine
>            Assignee: Abraham Fine
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message