From dcbd42b804b3a9dc990ef31e6194eedc5f0c1212 Mon Sep 17 00:00:00 2001 From: Abraham Fine Date: Tue, 13 Jun 2017 12:04:13 -0700 Subject: [PATCH] ZOOKEEPER-2806: Flaky test: org.apache.zookeeper.server.quorum.FLEBackwardElectionRoundTest.testBackwardElectionRound --- .../quorum/FLEBackwardElectionRoundTest.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/java/test/org/apache/zookeeper/server/quorum/FLEBackwardElectionRoundTest.java b/src/java/test/org/apache/zookeeper/server/quorum/FLEBackwardElectionRoundTest.java index bb5aa8fd9e4..74e86974cfa 100644 --- a/src/java/test/org/apache/zookeeper/server/quorum/FLEBackwardElectionRoundTest.java +++ b/src/java/test/org/apache/zookeeper/server/quorum/FLEBackwardElectionRoundTest.java @@ -99,8 +99,6 @@ public void testBackwardElectionRound() throws Exception { port[i] = clientport; } - ByteBuffer initialMsg = FLETestUtils.createMsg(ServerState.FOLLOWING.ordinal(), 0, 0, 1); - /* * Start server 0 */ @@ -116,8 +114,8 @@ public void testBackwardElectionRound() throws Exception { cnxManagers[0] = mockPeer.createCnxnManager(); cnxManagers[0].listener.start(); - cnxManagers[0].toSend(0l, initialMsg); - + cnxManagers[0].toSend(0l, getMsg()); + /* * Start mock server 2 */ @@ -125,8 +123,8 @@ public void testBackwardElectionRound() throws Exception { cnxManagers[1] = mockPeer.createCnxnManager(); cnxManagers[1].listener.start(); - cnxManagers[1].toSend(0l, initialMsg); - + cnxManagers[1].toSend(0l, getMsg()); + /* * Run another instance of leader election. */ @@ -137,9 +135,10 @@ public void testBackwardElectionRound() throws Exception { /* * Send the same messages, this time should not make 0 the leader. */ - cnxManagers[0].toSend(0l, initialMsg); - cnxManagers[1].toSend(0l, initialMsg); - + cnxManagers[0].toSend(0l, getMsg()); + cnxManagers[1].toSend(0l, getMsg()); + + thread.join(5000); if (!thread.isAlive()) { @@ -147,4 +146,8 @@ public void testBackwardElectionRound() throws Exception { } } + + private ByteBuffer getMsg() { + return FLETestUtils.createMsg(ServerState.FOLLOWING.ordinal(), 0, 0, 1); + } }