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

Michael Han commented on ZOOKEEPER-2137:
----------------------------------------

Add a canonical test case that fails pretty often for me locally to make life 
easier for those who want a easy reproduce. Also verified this is the only 
place in entire ReConfig test that will ever fail; other test cases in ReConfig 
test are solid.

{code}
@Test
    public void testPortChange() throws Exception {
        qu = new QuorumUtil(1); // create 3 servers
        qu.disableJMXTest = true;
        qu.startAll();
        ZooKeeper[] zkArr = createHandles(qu);

        List<String> joiningServers = new ArrayList<String>();

        int leaderIndex = getLeaderId(qu);
        int followerIndex = leaderIndex == 1 ? 2 : 1;

        testNormalOperation(zkArr[followerIndex], zkArr[leaderIndex]);

        // change leader's leading port - should renounce leadership

        int newQuorumPort = PortAssignment.unique();
        joiningServers.add("server." + leaderIndex + "=localhost:"
                + newQuorumPort
                + ":"
                + qu.getPeer(leaderIndex).peer.getElectionAddress().getPort()
                + ":participant;localhost:"
                + qu.getPeer(leaderIndex).peer.getClientPort());

        reconfig(zkArr[leaderIndex], joiningServers, null, null, -1);

        // Fails here.
        testNormalOperation(zkArr[followerIndex], zkArr[leaderIndex]);

        Assert.assertTrue(qu.getPeer(leaderIndex).peer.getQuorumAddress()
                .getPort() == newQuorumPort);
        Assert.assertTrue(getLeaderId(qu) != leaderIndex); // the leader changed

        joiningServers.clear();

        closeAllHandles(zkArr);
    }
{code}

> Make testPortChange() less flaky
> --------------------------------
>
>                 Key: ZOOKEEPER-2137
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2137
>             Project: ZooKeeper
>          Issue Type: Sub-task
>            Reporter: Hongchao Deng
>            Assignee: Michael Han
>             Fix For: 3.5.2, 3.6.0
>
>         Attachments: ZOOKEEPER-2137.patch
>
>
> The cause of flaky failure of testPortChange() is a race in sync().
> I figured out it could take some time to fix sync(). Meanwhile, we can make 
> testPortChange() less flaky by doing reconfig on the leader. We can change 
> this back in the fix of ZOOKEEPER-2136.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to